示例#1
0
        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);
        }
示例#2
0
		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;
		}
示例#3
0
        private static void ShowMainMenu(Lcd lcd, Buttons btns)
        {
            List <IMenuItem> items = new List <IMenuItem>();

            items.Add(new MenuItemWithAction(lcd, "Start", () => Start(lcd, btns), MenuItemSymbole.None));

            int[] tasks    = { taskFind, taskEscape };
            int   curTask  = Array.IndexOf(tasks, taskID);
            var   itemMode = new MenuItemWithOptions <string>(lcd, "Mode", new string[] { "FIND", "ESCAPE" }, curTask);

            itemMode.OnOptionChanged += delegate(string selection) {
                if (selection == "FIND")
                {
                    taskID = taskFind;
                }
                if (selection == "ESCAPE")
                {
                    taskID = taskEscape;
                }
            };

            String red   = Color.Red.ToString().ToUpper();
            String green = Color.Green.ToString().ToUpper();
            String blue  = Color.Blue.ToString().ToUpper();
            String white = Color.White.ToString().ToUpper();

            String[] colors   = { red, green, blue, white };
            int      curColor = Array.IndexOf(colors, enemyColor.ToString().ToUpper());

            var itemEnemyColor = new MenuItemWithOptions <string>(lcd, "Enemy Color", colors, curColor);

            itemEnemyColor.OnOptionChanged += delegate(string selection) {
                if (selection == red)
                {
                    enemyColor = Color.Red;
                }
                if (selection == green)
                {
                    enemyColor = Color.Green;
                }
                if (selection == blue)
                {
                    enemyColor = Color.Blue;
                }
                if (selection == white)
                {
                    enemyColor = Color.White;
                }
            };

            items.Add(itemMode);
            items.Add(itemEnemyColor);

            items.Add(new MenuItemWithAction(lcd, "Exit", () => Exit(lcd, btns), MenuItemSymbole.None));
            Menu m = new Menu(font, lcd, btns, "Robot", items);

            m.Show();
        }
示例#4
0
        static bool ShowWiFiMenu()
        {
            List <IMenuItem> items = new List <IMenuItem> ();
            var ssidItem           = new MenuItemWithCharacterInput("SSID", "Enter SSID", settings.WiFiSettings.SSID);

            ssidItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.SSID = text;
                    settings.Save();
                }).Start();
            };
            var passwordItem = new MenuItemWithCharacterInput("Password", "Password", settings.WiFiSettings.Password, true);

            passwordItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.Password = text;
                    settings.Save();
                }).Start();
            };
            var encryptionItem = new MenuItemWithOptions <string>("Encryption", new string[] { "None", "WPA/2" }, settings.WiFiSettings.Encryption ? 1 : 0);

            encryptionItem.OnOptionChanged += delegate(string newOpstion) {
                new Thread(delegate() {
                    if (newOpstion == "None")
                    {
                        settings.WiFiSettings.Encryption = false;
                    }
                    else
                    {
                        settings.WiFiSettings.Encryption = true;
                    }
                    settings.Save();
                }).Start();
            };
            var connectItem = new MenuItemWithCheckBox("Connect", WiFiDevice.IsLinkUp(),
                                                       delegate(bool WiFiOn)
            {
                bool isOn          = WiFiOn;
                var createFileStep = new StepContainer
                                     (
                    delegate()
                {
                    WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                    return(true);
                },
                    "Creating file", "Error creating WPA file"
                                     );
                var progressDialog = new ProgressDialog("WiFi", createFileStep);
                progressDialog.Show();
                if (WiFiOn)
                {
                    var turnOffStep = new StepContainer(
                        delegate()
                    {
                        WiFiDevice.TurnOff();
                        return(true);
                    },
                        "Turning Off", "Error turning off WiFi", "WiFi Disabled");
                    var dialog = new ProgressDialog("WiFi", turnOffStep);
                    dialog.Show();
                    isOn = false;
                }
                else
                {
                    var turnOnStep = new StepContainer(
                        delegate()
                    {
                        return(WiFiDevice.TurnOn(60000));
                    },
                        "Connecting", "Failed to connect");
                    Dialog dialog = new ProgressDialog("WiFi", turnOnStep);
                    if (dialog.Show())
                    {
                        if (settings.WiFiSettings.ConnectAtStartUp == false)
                        {
                            var question = new QuestionDialog("Do you want to connect at start-up?", "Settings");
                            if (question.Show())
                            {
                                new Thread(delegate() {
                                    settings.WiFiSettings.ConnectAtStartUp = true;
                                    settings.Save();
                                }).Start();
                            }
                        }
                        dialog = new InfoDialog("Connected Successfully " + WiFiDevice.GetIpAddress(), true, "WiFi");
                        dialog.Show();
                        isOn = true;
                    }
                    else
                    {
                        isOn = false;
                    }
                }
                return(isOn);
            }
                                                       );

            items.Add(ssidItem);
            items.Add(passwordItem);
            items.Add(encryptionItem);
            items.Add(connectItem);
            //Show the menu
            Menu m = new Menu("WiFi Connection", items);

            m.Show();
            return(false);
        }
示例#5
0
文件: Main.cs 项目: RoninWest/monoev3
 static bool ShowWiFiMenu()
 {
     List<IMenuItem> items = new List<IMenuItem> ();
     var ssidItem = new MenuItemWithCharacterInput("SSID", "Enter SSID", settings.WiFiSettings.SSID);
     ssidItem.OnDialogExit += delegate(string text) {
         new Thread(delegate() {
             settings.WiFiSettings.SSID = text;
             settings.Save();
         }).Start();
     };
     var passwordItem = new MenuItemWithCharacterInput("Password", "Password", settings.WiFiSettings.Password, true);
     passwordItem.OnDialogExit += delegate(string text) {
         new Thread(delegate() {
             settings.WiFiSettings.Password = text;
             settings.Save();
         }).Start();
     };
     var encryptionItem = new MenuItemWithOptions<string>("Encryption", new string[]{"None","WPA/2"}, settings.WiFiSettings.Encryption ? 1 : 0);
     encryptionItem.OnOptionChanged += delegate(string newOpstion) {
         new Thread(delegate() {
             if(newOpstion == "None")
                 settings.WiFiSettings.Encryption = false;
             else
                 settings.WiFiSettings.Encryption = true;
             settings.Save();
         }).Start();
     };
     var connectItem = new MenuItemWithCheckBox("Connect", WiFiDevice.IsLinkUp(),
         delegate(bool WiFiOn)
      		{
             bool isOn = WiFiOn;
             var createFileStep = new StepContainer(
                 delegate()
                 {
                     WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID,settings.WiFiSettings.Password,settings.WiFiSettings.Encryption);
                     return true;
                 },
                 "Creating file", "Error creating WPA file");
             var progressDialog = new ProgressDialog("WiFi", createFileStep);
             progressDialog.Show();
             if(WiFiOn){
                 var turnOffStep = new StepContainer(
                 delegate()
                 {
                     WiFiDevice.TurnOff();
                     return true;
                 },
                 "Turning Off","Error turning off WiFi","WiFi Disabled");
                 var dialog = new ProgressDialog("WiFi", turnOffStep);
                 dialog.Show();
                 isOn = false;
             }
             else{
                 var turnOnStep = new StepContainer(
                 delegate()
                 {
                     return WiFiDevice.TurnOn(60000);
                 },
                 "Connecting", "Failed to connect");
                 Dialog dialog = new ProgressDialog("WiFi", turnOnStep);
                 if(dialog.Show()){
                     if(settings.WiFiSettings.ConnectAtStartUp == false){
                         var question = new QuestionDialog("Do you want to connect at start-up?", "Settings");
                         if(question.Show()){
                             new Thread(delegate() {
                                 settings.WiFiSettings.ConnectAtStartUp = true;
                                 settings.Save();
                             }).Start();
                         }
                     }
                     dialog = new InfoDialog("Connected Successfully " + WiFiDevice.GetIpAddress(), true, "WiFi");
                     dialog.Show();
                     isOn = true;
                 }
                 else{
                     isOn = false;
                 }
             }
             return isOn;
      		}
     );
     items.Add(ssidItem);
     items.Add(passwordItem);
     items.Add(encryptionItem);
     items.Add(connectItem);
     //Show the menu
     Menu m = new Menu ("WiFi Connection", items);
     m.Show ();
     return false;
 }
示例#6
0
文件: Main.cs 项目: thaiEv3/monoev3
        static bool ShowWiFiMenu(Lcd lcd, Buttons btns)
        {
            List <IMenuItem> items = new List <IMenuItem> ();
            var ssidItem           = new MenuItemWithCharacterInput(lcd, btns, "SSID", "Enter SSID", settings.WiFiSettings.SSID);

            ssidItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.SSID = text;
                    settings.Save();
                }).Start();
            };
            var passwordItem = new MenuItemWithCharacterInput(lcd, btns, "Password", "Password", settings.WiFiSettings.Password, true);

            passwordItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.Password = text;
                    settings.Save();
                }).Start();
            };
            var encryptionItem = new MenuItemWithOptions <string>(lcd, "Encryption", new string[] { "None", "WPA/2" }, settings.WiFiSettings.Encryption ? 1 : 0);

            encryptionItem.OnOptionChanged += delegate(string newOpstion) {
                new Thread(delegate() {
                    if (newOpstion == "None")
                    {
                        settings.WiFiSettings.Encryption = false;
                    }
                    else
                    {
                        settings.WiFiSettings.Encryption = true;
                    }
                    settings.Save();
                }).Start();
            };
            var connectItem = new MenuItemWithCheckBox(lcd, "Connect", WiFiDevice.IsLinkUp(),
                                                       delegate(bool WiFiOn)
            {
                bool isOn      = WiFiOn;
                var infoDialog = new InfoDialog(font, lcd, btns, "Creating Configuration file", false);
                infoDialog.Show();
                WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                if (WiFiOn)
                {
                    var dialog = new InfoDialog(font, lcd, btns, "Shutting down WiFi", false);
                    dialog.Show();
                    WiFiDevice.TurnOff();
                    dialog = new InfoDialog(font, lcd, btns, "WiFi Disabled!!", true);
                    dialog.Show();
                    isOn = false;
                }
                else
                {
                    var dialog = new InfoDialog(font, lcd, btns, "Connecting to WiFi Network Please Wait", false);
                    dialog.Show();
                    if (WiFiDevice.TurnOn(60000))
                    {
                        if (settings.WiFiSettings.ConnectAtStartUp == false)
                        {
                            var question = new QuestionDialog(font, lcd, btns, "Do you want to connect at start-up?", "Settings");
                            question.Show();
                            if (question.IsPositiveSelected)
                            {
                                new Thread(delegate() {
                                    settings.WiFiSettings.ConnectAtStartUp = true;
                                    settings.Save();
                                }).Start();
                            }
                        }
                        dialog = new InfoDialog(font, lcd, btns, "Connected Successfully " + WiFiDevice.GetIpAddress(), true);
                        dialog.Show();
                        isOn = true;
                    }
                    else
                    {
                        dialog = new InfoDialog(font, lcd, btns, "Failed to connect to WiFI Network", true);
                        dialog.Show();
                        isOn = false;
                    }
                }
                return(isOn);
            }
                                                       );

            items.Add(ssidItem);
            items.Add(passwordItem);
            items.Add(encryptionItem);
            items.Add(connectItem);
            //Show the menu
            Menu m = new Menu(font, lcd, btns, "WiFi Connection", items);

            m.Show();
            return(false);
        }