public static bool ShowSubMenu () { List<IMenuItem> items = new List<IMenuItem> (); var nameItem = new MenuItemWithCharacterInput("Name", "Enter Name", "Anders"); var ageItem = new MenuItemWithNumericInput("Age", 29, 0, 100); var genderItem = new MenuItemWithOptions<string>("Option", new string[]{"Male","Female"}); var programItem = new MenuItemWithCheckBox("Loves C#", true); var checkBoxWithActionItem = new MenuItemWithCheckBox("Execute", true, TurnCheckBoxOnOff); items.Add(nameItem); items.Add(ageItem); items.Add(genderItem); items.Add(programItem); items.Add(checkBoxWithActionItem); //Show the menu Menu m = new Menu ("Sub Menu", items); m.Show (); Console.WriteLine("Your name is " + nameItem.Text); Console.WriteLine("Your genger is " + genderItem.GetSelection().ToString()); Console.WriteLine("Your age is " + ageItem.Value); if(programItem.Checked) Console.WriteLine(nameItem.Text + " loves C#"); Console.WriteLine("Is checked: " + checkBoxWithActionItem.Checked); return false; }
static bool ShowWebServerMenu() { List<IMenuItem> items = new List<IMenuItem> (); var portItem = new MenuItemWithNumericInput("Port", settings.WebServerSettings.Port, 1, ushort.MaxValue); portItem.OnValueChanged+= delegate(int value) { new Thread(delegate() { settings.WebServerSettings.Port = value; settings.Save(); }).Start(); }; var startItem = new MenuItemWithCheckBox("Start server", WebServer.IsRunning(), delegate(bool running) { bool isRunning = running; if(running){ var step = new StepContainer( delegate() { WebServer.StopAll(); System.Threading.Thread.Sleep(2000); return true; }, "Stopping", "Failed to stop"); var dialog = new ProgressDialog("Web Server",step); dialog.Show(); isRunning = WebServer.IsRunning(); } else{ var step1 = new StepContainer(()=>{return WebServer.StartFastCGI();}, "Init CGI Server", "Failed to start CGI Server"); var step2 = new StepContainer(()=>{return WebServer.StartLighttpd();}, "Initializing", "Failed to start server"); var step3 = new StepContainer(()=>{return WebServer.LoadPage();}, "Loading page", "Failed to load page"); var stepDialog = new StepDialog("Web Server", new List<IStep>{step1,step2,step3}, "Webserver started"); isRunning = stepDialog.Show(); } return isRunning; } ); //items.Add(portItem); items.Add(startItem); //Show the menu Menu m = new Menu ("Web Server", items); m.Show (); return false; }
static bool ShowSettings() { //Create the settings items and apply the settings List<IMenuItem> items = new List<IMenuItem> (); var terminateWithEscapeItem = new MenuItemWithCheckBox("Debug termination",settings.DebugSettings.TerminateWithEscape); var debugPortItem = new MenuItemWithNumericInput("Debug port",settings.DebugSettings.Port,1, ushort.MaxValue); var checkForUpdate = new MenuItemWithCheckBox("Update check",settings.GeneralSettings.CheckForSwUpdatesAtStartUp); var wifiConnect = new MenuItemWithCheckBox("WiFi auto connect",settings.WiFiSettings.ConnectAtStartUp); //var soundVolume = new MenuItemWithNumericInput("Volume",settings.SoundSettings.Volume); //var enableSound = new MenuItemWithCheckBox("Enable sound", settings.SoundSettings.EnableSound); items.Add(wifiConnect); items.Add(checkForUpdate); items.Add(terminateWithEscapeItem); items.Add (debugPortItem); //items.Add(soundVolume); //items.Add(enableSound); //Show the menu Menu m = new Menu ("Settings", items); m.Show (); new Thread(delegate() { settings.DebugSettings.TerminateWithEscape = terminateWithEscapeItem.Checked; settings.DebugSettings.Port = debugPortItem.Value; settings.GeneralSettings.CheckForSwUpdatesAtStartUp = checkForUpdate.Checked; settings.WiFiSettings.ConnectAtStartUp = wifiConnect.Checked; //settings.SoundSettings.Volume = soundVolume.Value; //settings.SoundSettings.EnableSound = enableSound.Checked; settings.Save(); }).Start(); return false; }