public RunningMacroPage(MacroCommandData macroData) : base("Cancel", macroData.title) { //TextWidget syncingText = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor); //contentRow.AddChild(syncingText); cancelButton.Click += (s, e) => { PrinterConnectionAndCommunication.Instance.MacroCancel(); }; if (macroData.showMaterialSelector) { int extruderIndex = 0; var materialSelector = new PresetSelectorWidget(string.Format($"{"Material".Localize()} {extruderIndex + 1}"), RGBA_Bytes.Transparent, NamedSettingsLayers.Material, extruderIndex); materialSelector.BackgroundColor = RGBA_Bytes.Transparent; materialSelector.Margin = new BorderDouble(0, 0, 0, 15); contentRow.AddChild(materialSelector); } PrinterConnectionAndCommunication.Instance.WroteLine.RegisterEvent(LookForTempRequest, ref unregisterEvents); if (macroData.waitOk | macroData.expireTime > 0) { Button okButton = textImageButtonFactory.Generate("Continue".Localize()); okButton.Click += (s, e) => { PrinterConnectionAndCommunication.Instance.MacroContinue(); UiThread.RunOnIdle(() => WizardWindow?.Close()); }; footerRow.AddChild(okButton); } if (macroData.image != null) { var imageWidget = new ImageWidget(macroData.image) { HAnchor = HAnchor.ParentCenter, Margin = new BorderDouble(5, 15), }; contentRow.AddChild(imageWidget); } var holder = new FlowLayoutWidget(); progressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale)) { FillColor = ActiveTheme.Instance.PrimaryAccentColor, BorderColor = ActiveTheme.Instance.PrimaryTextColor, BackgroundColor = RGBA_Bytes.White, Margin = new BorderDouble(3, 0, 0, 10), }; progressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor) { AutoExpandBoundsToText = true, Margin = new BorderDouble(5, 0, 0, 0), }; holder.AddChild(progressBar); holder.AddChild(progressBarText); contentRow.AddChild(holder); progressBar.Visible = false; if (macroData.countDown > 0) { timeToWaitMs = (long)(macroData.countDown * 1000); startTimeMs = UiThread.CurrentTimerMs; UiThread.RunOnIdle(CountDownTime); } footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); }
public RunningMacroPage(PrinterConfig printer, MacroCommandData macroData, ThemeConfig theme) : base("Cancel") { this.printer = printer; this.WindowTitle = "Running Macro".Localize(); this.HeaderText = macroData.title; if (macroData.showMaterialSelector) { contentRow.AddChild(new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material, theme) { BackgroundColor = Color.Transparent, Margin = new BorderDouble(0, 0, 0, 15) }); } printer.Connection.LineSent.RegisterEvent(LookForTempRequest, ref unregisterEvents); if (macroData.waitOk | macroData.expireTime > 0) { var okButton = theme.CreateDialogButton("Continue".Localize()); okButton.Click += (s, e) => { printer.Connection.MacroContinue(); }; this.AddPageAction(okButton); } if (macroData.image != null) { var imageWidget = new ImageWidget(macroData.image) { HAnchor = HAnchor.Center, Margin = new BorderDouble(5, 15), }; contentRow.AddChild(imageWidget); } var holder = new FlowLayoutWidget(); progressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale)) { FillColor = ActiveTheme.Instance.PrimaryAccentColor, BorderColor = ActiveTheme.Instance.PrimaryTextColor, BackgroundColor = Color.White, Margin = new BorderDouble(3, 0, 0, 10), }; progressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor) { AutoExpandBoundsToText = true, Margin = new BorderDouble(5, 0, 0, 0), }; holder.AddChild(progressBar); holder.AddChild(progressBarText); contentRow.AddChild(holder); progressBar.Visible = false; if (macroData.countDown > 0) { timeToWaitMs = (long)(macroData.countDown * 1000); startTimeMs = UiThread.CurrentTimerMs; runningInterval = UiThread.SetInterval(CountDownTime, .2); } }
public static void Show(MacroCommandData macroData) { WizardWindow.Show("Macro", "Running Macro", new RunningMacroPage(macroData)); }