Sunday, August 25, 2019

Windows text user interface - gui.cs

Windows 10 has the support for open ssh, which allow user to remote command line log in to Windows PC through Putty or Tera Term.

This is a good new as it allow the console application to be executed from remote system. Which in turn, it is a good news as well for text based application to chime in the area where simple user interface and fast respond application are needed.

Nice GUI ------> Test UI ------> Command line
GUI for normal user, command line for programmer.
Sometimes normal user need to operate certain software in CMD, it might seem hard for them when all your input method is keyboard and lines of text. CMD is tedious for user who are not so familiar with CMD command list.

In this situation, Test UI come in handy, it provides user interface with keyboard & mouse input, and fast respond & control over network.

Migueldeicaza has created a library for Windows UI, it seem intuitive,

The setup is for someone who is not familiar with Visual Studio, luckily I have many C#, C++ experts to consult.
First, open at console application.
File -> New -> New Project -> Templates -> Visual C# -> Console Application


Second, right click on project properties and open it. Then change the dot net frame work  version.


Now to the manage nuget,


Search for terminal.gui and install it.


 Replace the Program.cs code with:

using Terminal.Gui;

class Demo {
    static int Main ()
    {
        Application.Init ();

        var n = MessageBox.Query (50, 7, 
            "Question", "Do you like console apps?", "Yes", "No");

        return n;
    }
}

Build -> Build Solution
Then
Debug -> Start without Debugging

you get this, you can use keyboard to navigate, or use mouse click to click on "Y" and "N" to see what happened.

Exe file is generated, and it is located in C:\Users\XXXXX\Documents\Visual Studio 2015\Projects\ConsoleApplication6\ConsoleApplication6\bin\Debug

Note: In order for it to run on other PC, copy the whole Debug folder and the application is heavily depending on DLL, the library.




No comments:

Post a Comment