I'm wondering if there are any useful (free) libraries out there to
help the development of Console applications.
Just a simple example:
What about a library that encapsulates all the behaviour to
select files in a console application (aka the OpenFileDialog for Console applications).
There's MonoCurses of course, but I'm wondering if there are others?
Thnx.
UPDATE:
I know you can simply use the OpenFileDialog of course. But I'm talking about pure console applications. No Windows Forms or WPF elements. Pure console only. (For example to run on a Linux system without a graphical user interface).
This is one Good code I have used for Parsing the Command Line Arguments while using the Console Application Command Line Parser
Related
This question already has answers here:
Porting WinForms Application to Mac OS
(2 answers)
Closed 2 years ago.
I'm just new in C# Windows Form. Now I have a project that Uploads a txt file and output into a PDF file. Now I need to use C# windows form for this but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows? Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?
I'm just new in C# Windows Form.
Hi!
Now I have a project that Uploads a txt file and output into a PDF file.
Go on...
Now I need to use C# windows form for this
No, you don't need to use WinForms to simply upload a text file and download a PDF.
but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows?
No, you cannot. WinForms is tightly coupled to the Microsoft Windows operating-system (the biggest clue is in the name: Windows Forms. WinForms' is a thin wrapper around Windows' default windowed controls and widgets (also called User32 and Common Controls) as well as OLE, COM + ActiveX, and other Windows-centric APIs.
There are attempts to make a subset of WinForms work on other operating systems, but because WinForms is not natively cross-platform you won't have things like support for macOS's main menu and your users will be able to tell that your program doesn't look and feel like a native program.
Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?
No, it won't work.
Alternative Approaches:
Make your application using WinForms System.Windows.Forms and make it available to macOS users through some form of application remoting:
Run it on a Windows box accessed using macOS' Remote Desktop app.
Run it on a Windows box accessed using a browser-based RDP gateway.
Run it in a Windows virtual-machine running on an Apple Mac (Parallels Fusion, VirtualBox, etc).
Using only natively supported cross-platform features in .NET Core:
Make your application with a built-in http://localhost ASP.NET web-server that hosts a GUI web-application accessed with a web-browser that interacts with the rest of your application code.
Make a command-line only application.
Make a text-mode GUI application using a library like ncurses for .NET.
Make a platform-specific GUI while still sharing the rest of your application code (e.g. using Xamarin to use Cocoa from .NET, use WinForms or WPF on Windows, GTK# for Linux/BSD, etc).
I have an winForms application fully written in VB.NET. I have to start importing this application into WPF written C#. For the starting, I want to do this only for one module of the application. Is there any way I can pass VB.NET objects to a C# code, call a WPF application from a WinForms application and vice-versa ?
How should I approach this problem? Any help would be appreciated.
There is no easy way to migrate winform applications to Wpf.
You should carefully consider the reasons why would you like to do it and the effort it will take vs the profit.
that being said you can start by hosting your winform by a wpf application using WindowsFormHost then you can start by rewriting your controls one at a time and using ElementHost to host them in the winform.
Since you would like your application to be robust and use MVVM I personally think that it will take too much effort to migrate and it will be more reasonable to rewrite the application using already existing modules(logic not ui modules)
Regarding using Vb.net object in c# it can be done easily because they are both managed languages and are being compiled to CIL:
During compilation of CLI programming languages, the source code is
translated into CIL code rather than platform or processor-specific
object code. CIL is a CPU- and platform-independent instruction set
that can be executed in any environment supporting the Common Language
Infrastructure, such as the .NET runtime on Windows
Yes u can call wpf application in windows and vice-versa.For that u have to configure in .config file
In Through ElementHost u can access the controls
I would like to rewrite an application that currently works as a Windows GUI in C#. The problem is, it works well on Windows, but is not adapted for Mac and Linux because of GUI issues with Mono.
So my idea, was to continue with C# (needed because of an essential sub program that needs to run C# and cannot be ported) and try to rewrite it as a web application that any user on Windows, Mac or Linux could access easily and make it work.
It is also important that my application remains working "out-of-the-box" because it aims high accessibility.
I've looked for solutions like :
KayakHTTP but it does not support POST data ! (needed for a web GUI)
XSP2 from Mono and make an ASP.NET MVC web app, but will it really work with my web app to make an out-of-the-box application ?
Alternatively, do you have any other idea for me to have a C# web app working out of the box for the end users ? The only thing needed would be to install Mono on Mac and Linux.
Thank you very much for your help.
EDIT 1 : I realize that I have not explained all aspects correctly. In fact, there are 2 applications in my project :
The CORE application which is written in C# and is too big to be ported or rewritten and thus must use Mono for running on Mac and Linux
My GUI application using Windows Forms which is written in C# too and controls the CORE application
My goal is to convert my GUI application into a web app application so there's no more the Windows Forms GUI hassle on Mac and Linux.
Is it necessary for your core application to run on the client?
If NOT, then the best approach is to rewrite everything as a web (ASP.NET) application which is going to run on a Windows server. Users on all your target platforms will then access this app through a web browser.
If YES, then a web app is not a good idea. You really don't want to require a web server on your clients. You have two possibilities:
Take a look at the GUI toolkits available for mono and select one that is available on all your target platforms to avoid having different front ends for each of your platforms.
To ensure best user experience on all platforms you should choose the native GUI toolkit for each of the platforms and write a different front end for them: either using Mono or using a native development environment as long as your core application has an interface that can be accessed from it (e.g. command line or similar).
This is a duplicate question, but I don't have time to find the duplicate.
Briefly, the answer is: don't do this. You cannot translate a desktop application to a web application on a one to one basis: the two paradigms are too different.
I recommend instead refactoring your current application to remove all dependencies on the GUI. Then, write a totally new web application to meet the requirements, and have the web application call the code you refactored out of the desktop application.
Be aware of the big, hidden difference between the two platforms: the web application will be running on a server. It will be used by multiple users at the same time, and by multiple threads at the same time. While you are refactoring, be certain to note any code that would be sensitive to the difference. For instance, code that uses static member fields now could work in the desktop application because there is only one user at a time. In a web application, that static will be shared across all users and all threads.
This may not be what you had in mind.
I have a terminal application written in C# which I run with mono.
Now, I would like to write a GUI for this application. How can I use buttons to pass commands to this application, and how can I receive output from the terminal window?
Is there any possible way to do this? and if, how?
Thank you very much.
I think it is possible, but if you have the source code for the application, you would be much better off incorporating that source code into your new application and providing a GUI directly rather than trying to work with the command interface.
Based on your reply to competent_tech what you want to do is create the GUI using MonoMac.
MonoMac, a new foundation for building Cocoa applications on OSX using Mono.
MonoMac is the result of years of experimentation in blending .NET with Objective-C and is inspired by the same design principles that we used for MonoTouch.
You can use MonoMac to publish applications to the Mac AppStore, to learn about this see the MonoMacPackager page.
What you are describing as a windows 95 looking window, is winforms which is the native .Net API for building GUI applications. With MonoMac you will be able to build a GUI application that uses your current applications source code and looks and feels just like a normal Mac application.
Again trying to call commands on your application is not an ideal way to go about this.
If you have a command line program that you cannot modify then you probably want to invoke it directly as a subprocess and capture it's text output.
You can then write whatever GUI you like (MonoMac/GTK#) to drive the app directly.
I know that you can create a separate console application, however, I am in the final stages of testing and my application does not have an interface. Is there a way to simply open a console and interact with that inside the desktop application? This would be in a test method. (I am using C#, in Visual Studio 2008).
Thanks,
badPanda
You might be able to do what you want using AllocConsole (creates a new console) or AttachConsole (attaches to an existing console), but I think there are some limitations to what you can do with them.
See here for the API documentation for AllocConsole and here's the PInvoke page.
Here's a list of lots of Console functions, might be something else useful there too.
This may or may not be helpful, but some of the same techniques of GUI testing can be applied to a console app too, of course.
Here is an article and example code in C# for a user interface test.
Or there are totally different tools/languages that can be used for UI testing, such as AutoIt v3, which is easy to learn and apply. AutoIt does have a DLL/COM control that you can access from your preferred programming language (but I haven't used it that way so I can't comment on how well it works).