Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
92 lines (70 loc) · 2.43 KB
/
Copy pathProgram.cs
File metadata and controls
92 lines (70 loc) · 2.43 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
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using MonoBrickFirmware.Display.Dialogs;
using MonoBrickFirmware.Display.Menus;
namespace MenuExample
{
class MainClass
{
public static void Main (string[] args)
{
MenuContainer container;
Menu mainMenu = new Menu("Main menu");
Menu subMenu = new Menu("Sub menu");
Menu subSubMenu = new Menu ("sub sub Menu");
IStep turnOnStep = new StepContainer (TurnOn, "Turning On", "Error turning on", "Turned on sucesfully");
IStep turnOffStep = new StepContainer (TurnOff, "Turning Off", "Error turning off");
subSubMenu.AddItem( new ItemWithCheckBoxStep("Turned on", false, "Device", new CheckBoxStep(turnOnStep, turnOffStep), OnTurnOnChanged ));
subSubMenu.AddItem (new MonoBrickQuestion());
subSubMenu.AddItem( new ItemWithBrickInfo());
subMenu.AddItem (subSubMenu);
subMenu.AddItem( new ItemWithCharacterInput("Name", "Enter Name", "Anders", OnNameChanged, false, true, true));
subMenu.AddItem( new ItemWithNumericInput("Age", 29, OnAgeChanged, 0, 100));
subMenu.AddItem( new ItemWithCheckBox("Loves C#", true, OnCheckedChanged));
mainMenu.AddItem (subMenu);
mainMenu.AddItem (new ItemWithProgramList ("Programs"));
container = new MenuContainer(mainMenu);
container.Show (true);
}
private static void OnTurnOnChanged(bool isOn)
{
Console.WriteLine ("Turn on set to " + isOn);
}
private static void OnCheckedChanged(bool isChecked)
{
Console.WriteLine ("Loves C# is set to " + isChecked);
}
private static void OnNameChanged(string newName)
{
Console.WriteLine ("Name was changed to" + newName);
}
private static void OnAgeChanged(int newAge)
{
Console.WriteLine ("Your new age is " + newAge);
}
private static bool TurnOn()
{
System.Threading.Thread.Sleep (2000);
return true; //return false if it fails
}
private static bool TurnOff()
{
System.Threading.Thread.Sleep (500);
return true; //return false if it fails
}
}
public class MonoBrickQuestion : ChildItemWithParent
{
private ItemWithDialog<QuestionDialog> questionDialog = new ItemWithDialog<QuestionDialog>(new QuestionDialog ("Do you Like MonoBrick?", "MonoBrick"));
public MonoBrickQuestion() : base("Question")
{
}
public override void OnEnterPressed ()
{
questionDialog.SetFocus(this, OnExit);
}
public void OnExit (QuestionDialog dialog)
{
Console.WriteLine ("Do you like MonoBrick is set to " + dialog.IsPositiveSelected);
}
}
}