private void OnStartProgramCompileExit(StepDialog dialog) { if (dialog.ExecutedOk) { var start = new ExecuteProgramDialog (this.programInformation, true, useEscToStop); start.Start (Parent); } }
public static bool ExecuteSteps () { List<IStep> steps = new List<IStep>(); steps.Add( new StepContainer(DummyStep, "Dummy step 1", "Error executing step 1") ); steps.Add( new StepContainer(DummyStep, "Dummy step 2", "Error executing step 2") ); Dialog stepDialog = new StepDialog("Doing steps", steps); stepDialog.Show(); return false; }
private void OnUpdateCompleted(StepDialog dialog) { if (dialog.ExecutedOk) { Parent.SuspendButtonEvents (); Lcd.Clear (); Lcd.WriteText (Font.MediumFont, new Point (0, 0), "Shutting down...", true); Lcd.Update (); Buttons.LedPattern (2); Brick.TurnOff (); var whyAreYouHereDialog = new InfoDialog ("Cut the power", "Reboot failed"); whyAreYouHereDialog.Show (); Lcd.Clear (); new ManualResetEvent (false).WaitOne (); } }
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 AOTCompileAndShowDialog(string programFolder) { List<IStep> steps = new List<IStep> (); foreach (string file in Directory.EnumerateFiles(programFolder,"*.*").Where(s => s.EndsWith(".exe") || s.EndsWith(".dll"))) { steps.Add (new StepContainer (delegate() { return AOTHelper.Compile (file); }, new FileInfo(file).Name, "Failed to compile")); } var dialog = new StepDialog("Compiling",steps); return dialog.Show(); }
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; }