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); } }
internal ControlContentExtruder(PrinterConfig printer, int extruderIndex, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.printer = printer; GuiWidget loadUnloadButtonRow = null; // We do not yet support loading filament into extruders other than 0 & 1, fix it when needed. if (extruderIndex < 2) { // add in load and unload buttons loadUnloadButtonRow = new FlowLayoutWidget() { Padding = theme.ToolbarPadding, }; var loadButton = theme.CreateDialogButton("Load".Localize()); loadButton.ToolTipText = "Load filament".Localize(); loadButton.Name = "Load Filament Button"; loadButton.Click += (s, e) => UiThread.RunOnIdle(() => { DialogWindow.Show( new LoadFilamentWizard(printer, extruderIndex, showAlreadyLoadedButton: false)); }); loadUnloadButtonRow.AddChild(loadButton); var unloadButton = theme.CreateDialogButton("Unload".Localize()); unloadButton.ToolTipText = "Unload filament".Localize(); unloadButton.Click += (s, e) => UiThread.RunOnIdle(() => { DialogWindow.Show(new UnloadFilamentWizard(printer, extruderIndex)); }); loadUnloadButtonRow.AddChild(unloadButton); this.AddChild(new SettingsItem("Filament".Localize(), loadUnloadButtonRow, theme, enforceGutter: false)); } // Add the Extrude buttons var extrudeRetractButtonRow = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Padding = theme.ToolbarPadding, }; int extruderButtonTopMargin = loadUnloadButtonRow == null ? 8 : 0; var extrudeButton = theme.CreateDialogButton("Extrude".Localize()); extrudeButton.Name = "Extrude Button"; extrudeButton.ToolTipText = "Extrude filament".Localize(); extrudeButton.Click += (s, e) => { printer.Connection.MoveExtruderRelative(moveAmount, printer.Settings.EFeedRate(extruderIndex), extruderIndex); }; extrudeRetractButtonRow.AddChild(extrudeButton); var retractButton = theme.CreateDialogButton("Retract".Localize()); retractButton.ToolTipText = "Retract filament".Localize(); retractButton.Click += (s, e) => { printer.Connection.MoveExtruderRelative(moveAmount * -1, printer.Settings.EFeedRate(extruderIndex), extruderIndex); }; extrudeRetractButtonRow.AddChild(retractButton); this.AddChild(new SettingsItem( loadUnloadButtonRow == null ? "Filament".Localize() : "", // Don't put the name if we put in a load and unload button (it has the name) extrudeRetractButtonRow, theme, enforceGutter: false)); var moveButtonsContainer = new FlowLayoutWidget() { VAnchor = VAnchor.Fit | VAnchor.Center, HAnchor = HAnchor.Fit, Padding = theme.ToolbarPadding, }; var oneButton = theme.CreateMicroRadioButton("1"); oneButton.CheckedStateChanged += (s, e) => { if (oneButton.Checked) { moveAmount = 1; } }; moveButtonsContainer.AddChild(oneButton); var tenButton = theme.CreateMicroRadioButton("10"); tenButton.CheckedStateChanged += (s, e) => { if (tenButton.Checked) { moveAmount = 10; } }; moveButtonsContainer.AddChild(tenButton); var oneHundredButton = theme.CreateMicroRadioButton("100"); oneHundredButton.CheckedStateChanged += (s, e) => { if (oneHundredButton.Checked) { moveAmount = 100; } }; moveButtonsContainer.AddChild(oneHundredButton); switch (moveAmount) { case 1: oneButton.Checked = true; break; case 10: tenButton.Checked = true; break; case 100: oneHundredButton.Checked = true; break; } moveButtonsContainer.AddChild(new TextWidget("mm", textColor: theme.TextColor, pointSize: 8) { VAnchor = VAnchor.Center, Margin = new BorderDouble(3, 0) }); this.AddChild(new SettingsItem("Distance".Localize(), moveButtonsContainer, theme, enforceGutter: false)); }
public GenerateSupportPanel(ThemeConfig theme, InteractiveScene scene, double minimumSupportHeight) : base(FlowDirection.TopToBottom) { supportGenerator = new SupportGenerator(scene, minimumSupportHeight); this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Absolute; this.Width = 300 * GuiWidget.DeviceScale; this.BackgroundColor = theme.BackgroundColor; this.Padding = theme.DefaultContainerPadding; // Add an editor field for the SupportGenerator.SupportType PropertyInfo propertyInfo = typeof(SupportGenerator).GetProperty(nameof(SupportGenerator.SupportType)); var editor = PublicPropertyEditor.CreatePropertyEditor( new EditableProperty(propertyInfo, supportGenerator), null, new PPEContext(), theme); if (editor != null) { this.AddChild(editor); } // put in support pillar size var pillarSizeField = new DoubleField(theme); pillarSizeField.Initialize(0); pillarSizeField.DoubleValue = supportGenerator.PillarSize; pillarSizeField.ValueChanged += (s, e) => { supportGenerator.PillarSize = pillarSizeField.DoubleValue; // in case it was corrected set it back again if (pillarSizeField.DoubleValue != supportGenerator.PillarSize) { pillarSizeField.DoubleValue = supportGenerator.PillarSize; } }; // pillar rows this.AddChild( new SettingsRow( "Pillar Size".Localize(), "The width and depth of the support pillars".Localize(), pillarSizeField.Content, theme)); // put in the angle setting var overHangField = new DoubleField(theme); overHangField.Initialize(0); overHangField.DoubleValue = supportGenerator.MaxOverHangAngle; overHangField.ValueChanged += (s, e) => { supportGenerator.MaxOverHangAngle = overHangField.DoubleValue; // in case it was corrected set it back again if (overHangField.DoubleValue != supportGenerator.MaxOverHangAngle) { overHangField.DoubleValue = supportGenerator.MaxOverHangAngle; } }; // overhang row this.AddChild( new SettingsRow( "Overhang Angle".Localize(), "The angle to generate support for".Localize(), overHangField.Content, theme)); // Button Row var buttonRow = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = new BorderDouble(top: 5) }; this.AddChild(buttonRow); buttonRow.AddChild(new HorizontalSpacer()); // add 'Remove Auto Supports' button var removeButton = theme.CreateDialogButton("Remove".Localize()); removeButton.ToolTipText = "Remove all auto generated supports".Localize(); removeButton.Click += (s, e) => supportGenerator.RemoveExisting(); buttonRow.AddChild(removeButton); // add 'Generate Supports' button var generateButton = theme.CreateDialogButton("Generate".Localize()); generateButton.Name = "Generate Support Button"; generateButton.ToolTipText = "Find and create supports where needed".Localize(); generateButton.Click += (s, e) => Rebuild(); buttonRow.AddChild(generateButton); theme.ApplyPrimaryActionStyle(generateButton); }