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.




Monday, August 5, 2019

Labview - int to enum conversion

Just started on Labview, even for simple function googling, it is hard to understand, and there is a long list to read from NI forum.

Stackoverflow help a bit, but lack of details, need to try and error.

After some trying, the conversion from int to enum is easy and it doesn't worth time googling and reading the forum.

The VI is as follow:
Type Cast need to compare 2 entry of same type.
Enum is type of U16, that why I have to change the "i" from type I32 to U16.

I did a simple conversion:
i = 0, enum = zero
i = 1, enum = one
i = 2, enum = two
i = 3, enum = three
i = 4, enum = four
i = 5, enum = five

the example is put over here - https://github.com/hayview/labview