-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
79 lines (63 loc) · 1.99 KB
/
Program.cs
File metadata and controls
79 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Nim.Console;
using System;
using System.Text;
namespace MenuTest
{
class Program
{
static Menu Menu;
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.Default;
Menu = new Menu
(
"Main",
new[]
{
new Menu.Item("Static", new[]
{
new Menu.Item("Sub-0", Print),
new Menu.Item("Sub-1", Print),
new Menu.Item("Sub-2", Print),
new Menu.Item("Sub-3", Print)
}),
new Menu.Item("Dynamic", Generate),
new Menu.InputItem("Input Test", "Please input you name", InputTest),
new Menu.Item("Confirm", Print){ ActionIfConfirmed = true },
new Menu.Item("Exit", Exit),
}
);
Menu.Main.MaxColumns = 1;
Menu.WriteLine("Use ←↑↓→ for navigation.");
Menu.WriteLine("Press Esc for return to main menu.");
Menu.WriteLine("Press Backspace for return to parent menu.");
Menu.WriteLine("Press Del for clear log.");
Menu.Begin();
}
static void Print()
{
Menu.WriteLine("Selected: " + Menu.Selected.Name);
}
static void Generate()
{
if (Menu.Selected.Items.Count > 0)
{
return;
}
for (var i = 0; i < 50; ++i)
{
var sub = new Menu.Item("Dynamic - " + i, Print);
Menu.Selected.Add(sub);
}
}
static void InputTest(string str)
{
var inp = Menu.Selected as Menu.InputItem;
Menu.WriteLine("You wrote: " + inp.Value);
}
static void Exit()
{
Menu.Close();
}
}
}