Esempio n. 1
0
        public void Run()
        {
            var dialog = new QuestionDialog("Staat de robot op de startpositie?", "Positie", "Ja", "Nee", false);

            while (!dialog.IsPositiveSelected)
            {
                dialog.Show();
            }


            RobotControl.Hefvork.Reset();

            RobotControl.Movement.Forward(2250);

            RobotControl.Movement.Left(105);

            RobotControl.Hefvork.MoveDown(100);

            RobotControl.Movement.Backward(200);

            RobotControl.Hefvork.Reset();

            RobotControl.Movement.Forward(200);

            RobotControl.Movement.Left(105);

            RobotControl.Movement.Forward(2250);

            RobotControl.Hefvork.MoveDown(100);

            RobotControl.Movement.Forward(100);
            RobotControl.Hefvork.Reset();
        }
Esempio n. 2
0
    private void DropItemOutsideUI()
    {
        if (dragItemSlot == null)
        {
            return;
        }

        reallyDropItemDialog.Show();
        BaseItemSlot slot = dragItemSlot;

        reallyDropItemDialog.OnYesEvent += () => DestroyItemInSlot(slot);
    }
Esempio n. 3
0
    private void DropItemOutsideUI()
    {
        if (dragItemSlot == null)
        {
            return;
        }

        questionDialog.Show();
        BaseItemSlot baseItemSlot = dragItemSlot;

        questionDialog.OnYesEvent += () => DestroyItemInSlot(baseItemSlot);
    }
Esempio n. 4
0
        static bool Shutdown()
        {
            var dialog = new QuestionDialog("Are you sure?", "Shutdown EV3");

            if (dialog.Show())
            {
                Lcd.Instance.Clear();
                Lcd.Instance.WriteText(Font.MediumFont, new Point(0, 0), "Shutting down...", true);
                Lcd.Instance.Update();

                Buttons.Instance.LedPattern(2);
                ProcessHelper.RunAndWaitForProcess("/sbin/shutdown", "-h now");
                Thread.Sleep(120000);
            }
            return(false);
        }
Esempio n. 5
0
        static bool Shutdown(Lcd lcd, Buttons btns)
        {
            var dialog = new QuestionDialog(Font.MediumFont, lcd, btns, "Are you sure?", "Shutdown EV3");

            dialog.Show();
            if (dialog.IsPositiveSelected)
            {
                lcd.Clear();
                lcd.WriteText(font, new Point(0, 0), "Shutting down...", true);
                lcd.Update();

                using (UnixDevice dev = new UnixDevice("/dev/lms_power"))
                {
                    dev.IoCtl(0, new byte[0]);
                }
                btns.LedPattern(2);
                MenuAction = () => ProcessHelper.RunAndWaitForProcess("/lejos/bin/exit");
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
 private void DropItemOutsideUI()
 {
     if (dragItemSlot == null && dragSkillSlot == null)
     {
         return;
     }
     if (dragItemSlot)
     {
         //if dragging item, ask if you want to destroy it
         reallyDropItemDialog.Show();
         BaseItemSlot slot = dragItemSlot;
         reallyDropItemDialog.OnYesEvent += () => DestroyItemInSlot(slot);
     }
     else if (dragSkillSlot)
     {
         //if dragging skill from usable skill slot, unequip it
         if (dragSkillSlot is UsableSkillSlot)
         {
             SkillWindow.RemoveSkill(dragSkillSlot.Skill as ActiveSkill);
         }
     }
 }
Esempio n. 7
0
        public void Run()
        {
            var dialog = new QuestionDialog("Staat de robot op de startpositie?", "Positie", "Ja", "Nee", false);

            while (!dialog.IsPositiveSelected)
            {
                dialog.Show();
            }

            RobotControl.Movement.Forward(1000);

            RobotControl.Movement.Left(36);

            RobotControl.Movement.Forward(550);

            RobotControl.Movement.Right(45);

            RobotControl.Movement.Forward(250);

            RobotControl.Movement.Backward(20);

            RobotControl.Movement.Right(45);
        }
Esempio n. 8
0
        static bool ShowProgramOptions(string programFolder)
        {
            string fileName = "";

            try {
                fileName = Directory.EnumerateFiles(programFolder, "*.exe").First();
            } catch {
                var info = new InfoDialog(programFolder + "is not executable", true, "Program");
                info.Show();
                Directory.Delete(programFolder, true);
                updateProgramList = true;
                return(true);
            }

            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Debug Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Normal);
                    break;

                case 1:
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Debug);
                    break;

                case 2:
                    if (!AOTHelper.IsFileCompiled(fileName))
                    {
                        if (AOTCompileAndShowDialog(programFolder))
                        {
                            programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                        }
                    }
                    else
                    {
                        programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                    }
                    break;

                case 3:

                    if (AOTHelper.IsFileCompiled(fileName))
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(programFolder);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(programFolder);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step = new StepContainer(() => {
                            Directory.Delete(programFolder, true);
                            return(true);
                        }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
Esempio n. 9
0
 static bool ShowUpdatesDialogs()
 {
     if (WiFiDevice.IsLinkUp())
     {
         bool        newImage       = false;
         bool        newFirmwareApp = false;
         bool        newAddin       = false;
         VersionInfo versionInfo    = null;
         var         step           = new StepContainer(
             delegate() {
             try {
                 versionInfo         = VersionHelper.AvailableVersions();
                 newImage            = versionInfo.Image != VersionHelper.CurrentImageVersion();
                 newFirmwareApp      = versionInfo.Fimrware != firmwareVersion;
                 string addInVersion = VersionHelper.CurrentAddInVersion();
                 if (addInVersion != null)
                 {
                     newAddin = versionInfo.AddIn != VersionHelper.CurrentAddInVersion();
                 }
             } catch {
                 return(false);
             }
             return(true);
         },
             "Checking server", "Failed to check for Updates");
         var dialog = new ProgressDialog("Updates", step);
         dialog.Show();
         if (newImage)
         {
             var visitWebsiteDialog = new InfoDialog("New image available. Download it at monobrick.dk", true);
             visitWebsiteDialog.Show();
         }
         else
         {
             if (newFirmwareApp)
             {
                 var updateQuestion = new QuestionDialog("New firmware available. Update?", "New Fiwmware");
                 if (updateQuestion.Show())
                 {
                     var          updateHelper = new UpdateHelper(versionInfo.Fimrware);
                     List <IStep> steps        = new List <IStep> ();
                     steps.Add(new StepContainer(updateHelper.DownloadFirmware, "Downloading...", "Failed to download files"));
                     steps.Add(new StepContainer(updateHelper.UpdateBootFile, "Updating system", "Failed to update boot file"));
                     var updateDialog = new StepDialog("Updating", steps);
                     if (updateDialog.Show())
                     {
                         for (int seconds = 10; seconds > 0; seconds--)
                         {
                             var rebootDialog = new InfoDialog("Update completed. Rebooting in  " + seconds, false);
                             rebootDialog.Show();
                             System.Threading.Thread.Sleep(1000);
                         }
                         ProcessHelper.RunAndWaitForProcess("/sbin/shutdown", "-h now");
                         Thread.Sleep(120000);
                         var whyAreYouHereDialog = new InfoDialog("Cut the power", false, "Reboot failed");
                         whyAreYouHereDialog.Show();
                         new ManualResetEvent(false).WaitOne();
                     }
                 }
             }
             else
             {
                 if (newAddin)
                 {
                     var visitWebsiteDialog = new InfoDialog("New Xamarin Add-in. Download it at monobrick.dk", true);
                     visitWebsiteDialog.Show();
                 }
                 else
                 {
                     var noUpdateDialog = new InfoDialog("No updates available", true);
                     noUpdateDialog.Show();
                 }
             }
         }
     }
     else
     {
         var dialog = new InfoDialog("WiFi device is not pressent", true);
         dialog.Show();
     }
     return(false);
 }
Esempio n. 10
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);
        }
Esempio n. 11
0
        static bool ShowProgramOptions(ProgramInformation program)
        {
            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => ProgramManager.Instance.StartProgram(program, false);
                    break;

                case 1:
                    if (!program.IsAOTCompiled)
                    {
                        if (AOTCompileAndShowDialog(program))
                        {
                            programAction = () => ProgramManager.Instance.StartProgram(program, true);
                        }
                    }
                    else
                    {
                        programAction = () => ProgramManager.Instance.StartProgram(program, true);
                    }
                    break;

                case 3:

                    if (program.IsAOTCompiled)
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(program);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(program);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step           = new StepContainer(() => { ProgramManager.Instance.DeleteProgram(program); return(true); }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
Esempio n. 12
0
        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);
        }