Integrate C # GUI Console Application

I have been developing C # from scratch in less than 3 months, and what I have got now is a console application created using Visual Studio 2015. This application uses a web service, XML is deserialized, formatted and stored in Access database and finally success or error. XML is sent back to the web server. The application includes 3 classes: the main stream class, the SOAP client class, and the DB class.

Now the reason I am posting this is because I need this console application to be integrated with a graphical interface in which some data received from deserialized XML should be displayed (this is an extension of the project, I think, before moving on to the developing stage) but I have no idea how to do this.

So far I have been reading “Building WPF Applications” and “Windows Forms,” but the documentation is stunning and I don’t know if I am on the right track so that you guys can give some recommendations before I start spending time, which may not be the best option for integrating my console application with a GUI ? Is there a way to make the console application become a GUI?

I would appreciate it if you would provide me with practical links to tutorials in which they quickly implement graphical interfaces, my time is running out and I need to start coding right now. Thank you so much for reading this and helping me.

+4
source share
4 answers

If you're just looking for a barebone GUI and not too worried that it looks polished, I suggest you right-click on your project -> add-> Windows Form.

Then turning your console application into a GUI based application is as simple as instantiating the Form class and calling .ShowDialog ().

Example:

using System.Windows.Forms;

//Note: if you create a new class by clicking PROJECT->Add Windows Form,
//then this class definition and the constructor are automatically created for you.
//Open MyFancyForm.cs, right click on the form, and click View Code to see it.
public partial class MyFancyForm : Form
{
    public MyFancyForm()
    {
        InitializeComponent();
    }
}

static void Main(string[] args)
{
     var guiForm = new MyFancyForm();

     guiForm.ShowDialog();//This "opens" the GUI on your screen
}

. WindowsForm, , . , .

: , project- > Windows.

+2

, , . Windows Forms WPF .

, CreateNoWindow true.

var processStartInfo = new ProcessStartInfo(fileName, arguments);
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = false;
processStartInfo.CreateNoWindow = true;
// etc.

, : #

GitHub, . , :

enter image description here

, .

+3

"", , Project → Properties → Application Class Library ( Widows).

, .

See attached image ...

0

You can put a TextBox inside your form and redirect everything in the console to the TextBox.

see this for more information Redirecting Console.WriteLine () to a text box

-1
source

Source: https://habr.com/ru/post/1650954/


All Articles