https://github.com/distantcam/cui
A simple Console UI
https://github.com/distantcam/cui
Last synced: 8 months ago
JSON representation
A simple Console UI
- Host: GitHub
- URL: https://github.com/distantcam/cui
- Owner: distantcam
- License: mit
- Created: 2017-03-02T03:09:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-06T02:53:05.000Z (about 9 years ago)
- Last Synced: 2025-01-15T05:39:44.652Z (over 1 year ago)
- Language: C#
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# CUI
**CUI** provides a simple state based console UI with screens and a menu system for creating sample applications.
### Example code
```
using System;
using System.Threading.Tasks;
using CUI;
class Program
{
enum Screens
{
MainScreen,
Processes,
Process1,
Process2
}
static void Main(string[] args)
{
var app = new ConsoleApplication(Screens.MainScreen);
app.AddMenuScreen(Screens.MainScreen)
.WithMenuOption('p', "Select Process to run", Screens.Processes)
.WithMenuOption('q', "Quit");
app.AddMenuScreen(Screens.Processes)
.WithMenuOption("Task 1 (long)", Screens.Process1)
.WithMenuOption("Task 2 (short)", Screens.Process2);
app.AddFunctionScreen(Screens.Process1)
.SetAction(async () =>
{
Console.WriteLine("Running...");
await Task.Delay(1000);
Console.WriteLine("Almost done...");
await Task.Delay(1000);
Console.WriteLine("Just finishing up...");
await Task.Delay(1000);
Console.WriteLine("Done!");
});
app.AddFunctionScreen(Screens.Process2)
.SetAction(() =>
{
Console.WriteLine("I'm done already!");
return Task.CompletedTask;
});
app.Run();
// Or app.RunAsync().GetAwaiter().GetResult();
}
}
```