private CalibrationControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; // add in the controls for configuring auto leveling { SettingsRow settingsRow; this.AddChild(settingsRow = new SettingsRow( "Printer Calibration".Localize(), null, theme)); // run leveling button var runWizardButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, Name = "Run Leveling Button", ToolTipText = "Run Calibration".Localize() }; runWizardButton.Click += (s, e) => { UiThread.RunOnIdle(() => { DialogWindow.Show(new PrinterCalibrationWizard(printer, theme)); }); }; settingsRow.AddChild(runWizardButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 16), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled) }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; // TODO: Why is this listener conditional? If the leveling changes somehow, shouldn't we be updated the UI to reflect that? // Register listeners printer.Settings.PrintLevelingEnabledChanged += Settings_PrintLevelingEnabledChanged; settingsRow.AddChild(printLevelingSwitch); } } // Register listeners printer.Connection.CommunicationStateChanged += PrinterStatusChanged; SetVisibleControls(); }
private static GuiWidget CreateToggleSwitch(ToggleSwitchConfig toggleSwitchConfig, ThemeConfig theme) { if (toggleSwitchConfig == null) { return(null); } var toggleSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Checked = toggleSwitchConfig.Checked, Name = toggleSwitchConfig.Name, Margin = new BorderDouble(left: 16), }; toggleSwitch.CheckedStateChanged += (sender, e) => { toggleSwitchConfig.ToggleAction?.Invoke(toggleSwitch.Checked); }; return(toggleSwitch); }
public FanControlsRow(int fanIndex, string fanName, PrinterConfig printer, ThemeConfig theme) : base(fanName, null, theme) { this.printer = printer; this.fanIndex = fanIndex; var timeSinceLastManualSend = new Stopwatch(); var container = new FlowLayoutWidget(); this.AddChild(container); this.BorderColor = Color.Transparent; fanSpeedDisplay = new MHNumberEdit(0, theme, minValue: 0, maxValue: 100, pixelWidth: 30 * GuiWidget.DeviceScale) { Value = printer.Connection.GetFanSpeed0To255(fanIndex) * 100 / 255, VAnchor = VAnchor.Center | VAnchor.Fit, Margin = new BorderDouble(right: 2), }; fanSpeedDisplay.ActuallNumberEdit.EditComplete += (sender, e) => { // limit the rate we can send this message to 2 per second so we don't get in a crazy toggle state. if (!timeSinceLastManualSend.IsRunning || timeSinceLastManualSend.ElapsedMilliseconds > 500) { timeSinceLastManualSend.Restart(); printer.Connection.SetFanSpeed0To255(fanIndex, (int)(fanSpeedDisplay.Value * 255 / 100 + .5)); } }; container.AddChild(fanSpeedDisplay); container.Selectable = true; // put in % container.AddChild(new TextWidget("%", pointSize: 10, textColor: theme.TextColor) { VAnchor = VAnchor.Center }); toggleSwitch = new RoundedToggleSwitch(theme) { Margin = new BorderDouble(5, 0), VAnchor = VAnchor.Center }; toggleSwitch.CheckedStateChanged += (s, e) => { if (!timeSinceLastManualSend.IsRunning || timeSinceLastManualSend.ElapsedMilliseconds > 500) { timeSinceLastManualSend.Restart(); if (toggleSwitch.Checked) { printer.Connection.SetFanSpeed0To255(fanIndex, 255); } else { printer.Connection.SetFanSpeed0To255(fanIndex, 0); } } }; container.AddChild(toggleSwitch); this.ActionWidget = toggleSwitch; // Register listeners printer.Connection.FanSpeedSet += Connection_FanSpeedSet; }
public PrinterCalibrationWizard(PrinterConfig printer, ThemeConfig theme) { var stages = new List <ISetupWizard>() { new ZCalibrationWizard(printer), new PrintLevelingWizard(printer), new LoadFilamentWizard(printer, extruderIndex: 0, showAlreadyLoadedButton: true), new LoadFilamentWizard(printer, extruderIndex: 1, showAlreadyLoadedButton: true), new XyCalibrationWizard(printer, 1) }; this.Stages = stages; this.printer = printer; this.HomePageGenerator = () => { var homePage = new WizardSummaryPage() { HeaderText = "Printer Setup & Calibration".Localize() }; var contentRow = homePage.ContentRow; if (!this.ReturnedToHomePage) { contentRow.AddChild( new WrappedTextWidget( @"Select the calibration task on the left to continue".Replace("\r\n", "\n"), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); } contentRow.BackgroundColor = Color.Transparent; foreach (var stage in this.Stages.Where(s => s.Enabled && s.Visible)) { GuiWidget rightWidget = null; var widget = new GuiWidget(); if (stage is ZCalibrationWizard probeWizard) { var column = CreateColumn(theme); column.FlowDirection = FlowDirection.LeftToRight; var offset = printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset); column.AddChild( new ValueTag( "Z Offset".Localize(), offset.Z.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); widget = column; } if (stage is PrintLevelingWizard levelingWizard) { PrintLevelingData levelingData = printer.Settings.Helpers.PrintLevelingData; // Always show leveling option if printer does not have hardware leveling if (!printer.Settings.GetValue <bool>(SettingsKey.has_hardware_leveling)) { var positions = levelingData.SampledPositions; var column = CreateColumn(theme); column.AddChild( new ValueTag( "Leveling Solution".Localize(), printer.Settings.GetValue(SettingsKey.print_leveling_solution), new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); var row = new FlowLayoutWidget() { VAnchor = VAnchor.Fit, HAnchor = HAnchor.Fit }; // Only show Edit button if data initialized if (levelingData?.SampledPositions.Count() > 0) { var editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme) { Name = "Edit Leveling Data Button", ToolTipText = "Edit Leveling Data".Localize(), }; editButton.Click += (s, e) => { DialogWindow.Show(new EditLevelingSettingsPage(printer, theme)); }; row.AddChild(editButton); } // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(theme.DefaultContainerPadding, 0), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled), ToolTipText = "Enable Software Leveling".Localize() }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; printLevelingSwitch.Closed += (s, e) => { // Unregister listeners printer.Settings.PrintLevelingEnabledChanged -= this.Settings_PrintLevelingEnabledChanged; }; // TODO: Why is this listener conditional? If the leveling changes somehow, shouldn't we be updated the UI to reflect that? // Register listeners printer.Settings.PrintLevelingEnabledChanged += this.Settings_PrintLevelingEnabledChanged; row.AddChild(printLevelingSwitch); } rightWidget = row; // Only visualize leveling data if initialized if (levelingData?.SampledPositions.Count() > 0) { var probeWidget = new ProbePositionsWidget(printer, positions.Select(v => new Vector2(v)).ToList(), theme) { HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Absolute, Height = 200, Width = 200, RenderLevelingData = true, RenderProbePath = false, SimplePoints = true, }; column.AddChild(probeWidget); } widget = column; } } if (stage is XyCalibrationWizard xyWizard) { var column = CreateColumn(theme); column.FlowDirection = FlowDirection.LeftToRight; var hotendOffset = printer.Settings.Helpers.ExtruderOffset(1); var tool2Column = new FlowLayoutWidget(FlowDirection.TopToBottom); column.AddChild(tool2Column); tool2Column.AddChild( new TextWidget("Tool".Localize() + " 2", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { Margin = new BorderDouble(bottom: 4) }); tool2Column.AddChild( new ValueTag( "X Offset".Localize(), hotendOffset.X.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); tool2Column.AddChild( new ValueTag( "Y Offset".Localize(), hotendOffset.Y.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { MinimumSize = new Vector2(125, 0) }); widget = column; } if (stage.SetupRequired) { var column = CreateColumn(theme); column.AddChild(new TextWidget("Setup Required".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); widget = column; } else if (stage is LoadFilamentWizard filamentWizard) { widget.Margin = new BorderDouble(left: theme.DefaultContainerPadding); } var section = new SectionWidget(stage.Title, widget, theme, rightAlignedContent: rightWidget, expandingContent: false); theme.ApplyBoxStyle(section); section.Margin = section.Margin.Clone(left: 0); section.ShowExpansionIcon = false; if (stage.SetupRequired) { section.BackgroundColor = Color.Red.WithAlpha(30); } contentRow.AddChild(section); } return(homePage); }; }
private CalibrationControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; // add in the controls for configuring auto leveling { SettingsRow settingsRow; this.AddChild(settingsRow = new SettingsRow( "Print Leveling Plane".Localize(), null, theme, AggContext.StaticData.LoadIcon("leveling_32x32.png", 16, 16, theme.InvertIcons))); // run leveling button var runWizardButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Print Leveling Wizard - Can be re-calculated anytime there seems to be a problem with initial layer consistency".Localize() }; runWizardButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowPrintLevelWizard(printer, theme); }); }; settingsRow.AddChild(runWizardButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch var printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 16), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled) }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; printer.Settings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); settingsRow.AddChild(printLevelingSwitch); } // add in the controls for configuring probe offset if (printer.Settings.GetValue <bool>(SettingsKey.has_z_probe) && printer.Settings.GetValue <bool>(SettingsKey.use_z_probe)) { this.AddChild(settingsRow = new SettingsRow( "Print Leveling Probe".Localize(), null, theme, AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons))); var runCalibrateProbeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Probe Calibration Wizard - needed for initial setup - normally should remain calibrated unless there are changes to hardware.".Localize() }; runCalibrateProbeButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowProbeCalibrationWizard(printer, theme); }); }; settingsRow.BorderColor = Color.Transparent; settingsRow.AddChild(runCalibrateProbeButton); } } printer.Connection.CommunicationStateChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); printer.Connection.EnableChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); SetVisibleControls(); }
public RenderOptionsButton(ThemeConfig theme, InteractionLayer interactionLayer) : base(theme) { this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; this.AddChild(new IconButton(AggContext.StaticData.LoadIcon("web.png", theme.InvertIcons), theme) { Selectable = false }); this.PopupContent = () => { var menuTheme = AppContext.MenuTheme; var subPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = theme.DefaultContainerPadding, BackgroundColor = menuTheme.BackgroundColor, HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Fit }; subPanel.BoundsChanged += (s, e) => { Console.WriteLine(); }; foreach (var drawable in ApplicationController.Instance.DragDropData.View3DWidget.InteractionLayer.Drawables) { var row = new SettingsRow(drawable.Title, drawable.Description, theme); subPanel.AddChild(row); var toggleSwitch = new RoundedToggleSwitch(theme) { Checked = drawable.Enabled }; toggleSwitch.CheckedStateChanged += (s, e) => { drawable.Enabled = toggleSwitch.Checked; }; row.AddChild(toggleSwitch); } foreach (var drawable in ApplicationController.Instance.DragDropData.View3DWidget.InteractionLayer.ItemDrawables) { var row = new SettingsRow(drawable.Title, drawable.Description, theme); subPanel.AddChild(row); var toggleSwitch = new RoundedToggleSwitch(theme) { Checked = drawable.Enabled }; toggleSwitch.CheckedStateChanged += (s, e) => { drawable.Enabled = toggleSwitch.Checked; }; row.AddChild(toggleSwitch); } subPanel.Width = 400; return(subPanel); }; }
private FanControls(PrinterConnection printerConnection, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.HAnchor = HAnchor.Stretch; //Matt's test editing to add a on/off toggle switch bool fanActive = printerConnection.FanSpeed0To255 != 0; Stopwatch timeSinceLastManualSend = new Stopwatch(); var settingsRow = new SettingsRow( "Part Cooling Fan".Localize(), null, theme, fullRowSelect: true); this.AddChild(settingsRow); var container = new FlowLayoutWidget(); settingsRow.AddChild(container); settingsRow.BorderColor = Color.Transparent; fanSpeedDisplay = new EditableNumberDisplay(0, "100") { DisplayFormat = "{0:0}", Value = printerConnection.FanSpeed0To255 * 100 / 255 }; fanSpeedDisplay.ValueChanged += (sender, e) => { // limit the rate we can send this message to 2 per second so we don't get in a crazy toggle state. if (!timeSinceLastManualSend.IsRunning || timeSinceLastManualSend.ElapsedMilliseconds > 500) { timeSinceLastManualSend.Restart(); printerConnection.FanSpeed0To255 = (int)(fanSpeedDisplay.Value * 255 / 100 + .5); } }; container.AddChild(fanSpeedDisplay); container.Selectable = true; // put in % container.AddChild(new TextWidget("%", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center }); var toggleSwitch = new RoundedToggleSwitch(theme) { Margin = new BorderDouble(5, 0), VAnchor = VAnchor.Center }; toggleSwitch.CheckedStateChanged += (s, e) => { if (!timeSinceLastManualSend.IsRunning || timeSinceLastManualSend.ElapsedMilliseconds > 500) { timeSinceLastManualSend.Restart(); if (toggleSwitch.Checked) { printerConnection.FanSpeed0To255 = 255; } else { printerConnection.FanSpeed0To255 = 0; } } }; container.AddChild(toggleSwitch); settingsRow.ActionWidget = toggleSwitch; // CreateFanControls printerConnection.FanSpeedSet.RegisterEvent((s, e) => { if ((int)printerConnection.FanSpeed0To255 > 0) { toggleSwitch.Checked = true; } else { toggleSwitch.Checked = false; } fanSpeedDisplay.Value = printerConnection.FanSpeed0To255 * 100 / 255; } , ref unregisterEvents); }
private CalibrationControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; // add in the controls for configuring auto leveling { SettingsRow settingsRow; this.AddChild(settingsRow = new SettingsRow( "Bed Leveling".Localize(), null, theme, AggContext.StaticData.LoadIcon("leveling_32x32.png", 16, 16, theme.InvertIcons))); // run leveling button var runWizardButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, Name = "Run Leveling Button", ToolTipText = "Run Calibration".Localize() }; runWizardButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowPrintLevelWizard(printer, theme); }); }; settingsRow.AddChild(runWizardButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch var printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 16), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled) }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e) { printLevelingSwitch.Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled); } printer.Settings.PrintLevelingEnabledChanged += Settings_PrintLevelingEnabledChanged; this.Closed += (s, e) => { printer.Settings.PrintLevelingEnabledChanged -= Settings_PrintLevelingEnabledChanged; }; settingsRow.AddChild(printLevelingSwitch); } // add in the controls for configuring probe offset if (printer.Settings.GetValue <bool>(SettingsKey.has_z_probe) && printer.Settings.GetValue <bool>(SettingsKey.use_z_probe)) { this.AddChild(settingsRow = new SettingsRow( "Calibrate Probe Offset".Localize(), null, theme, AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons))); var runCalibrateProbeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Run Calibration".Localize() }; runCalibrateProbeButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowProbeCalibrationWizard(printer, theme); }); }; settingsRow.BorderColor = Color.Transparent; settingsRow.AddChild(runCalibrateProbeButton); } } printer.Connection.CommunicationStateChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); printer.Connection.EnableChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); SetVisibleControls(); }
public PrinterCalibrationWizard(PrinterConfig printer, ThemeConfig theme) { var stages = new List <ISetupWizard>() { new ZCalibrationWizard(printer), new PrintLevelingWizard(printer), new LoadFilamentWizard(printer, extruderIndex: 0, showAlreadyLoadedButton: true), new LoadFilamentWizard(printer, extruderIndex: 1, showAlreadyLoadedButton: true), new XyCalibrationWizard(printer, 1) }; this.Stages = stages; this.printer = printer; this.HomePageGenerator = () => { var homePage = new WizardSummaryPage() { HeaderText = "Printer Setup & Calibration".Localize() }; var contentRow = homePage.ContentRow; if (!ReturnedToHomePage) { if (printer.Connection.IsConnected) { contentRow.AddChild( new WrappedTextWidget( @"Select the calibration task to continue".Replace("\r\n", "\n"), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); } else { contentRow.AddChild( new WrappedTextWidget( @"Connect the printer to complete the calibration tasks.".Replace("\r\n", "\n"), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); } } contentRow.BackgroundColor = Color.Transparent; foreach (var stage in this.Stages.Where(s => s.Visible)) { GuiWidget rightWidget = null; var widget = new GuiWidget(); if (stage is ZCalibrationWizard probeWizard) { var column = CreateColumn(theme); column.FlowDirection = FlowDirection.LeftToRight; var offset = printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset); column.AddChild( new ValueTag( "Z Offset".Localize(), offset.Z.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); column.AddChild(new HorizontalSpacer()); AddRunStageButton("Run Z Calibration".Localize(), theme, stage, column); widget = column; } if (stage is LoadFilamentWizard loadWizard) { var column = CreateColumn(theme); column.FlowDirection = FlowDirection.LeftToRight; var lastRow = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch }; column.AddChild(lastRow); lastRow.AddChild(new HorizontalSpacer()); AddRunStageButton("Load Filament".Localize(), theme, stage, lastRow).Margin = new BorderDouble(10); widget = column; } if (stage is PrintLevelingWizard levelingWizard) { PrintLevelingData levelingData = printer.Settings.Helpers.PrintLevelingData; var column = CreateColumn(theme); var lastRow = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch }; if (levelingData != null && printer.Settings?.GetValue <bool>(SettingsKey.print_leveling_enabled) == true) { var positions = levelingData.SampledPositions; var levelingSolution = printer.Settings.GetValue(SettingsKey.print_leveling_solution); column.AddChild( new ValueTag( "Leveling Solution".Localize(), levelingSolution, new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Edit Leveling Data Button", ToolTipText = "Edit Leveling Data".Localize(), }; editButton.Click += (s, e) => { DialogWindow.Show(new EditLevelingSettingsPage(printer, theme)); }; var row = new FlowLayoutWidget() { VAnchor = VAnchor.Fit, HAnchor = HAnchor.Fit }; row.AddChild(editButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(theme.DefaultContainerPadding, 0), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled), ToolTipText = "Enable Software Leveling".Localize() }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; printLevelingSwitch.Closed += (s, e) => { // Unregister listeners printer.Settings.PrintLevelingEnabledChanged -= Settings_PrintLevelingEnabledChanged; }; // TODO: Why is this listener conditional? If the leveling changes somehow, shouldn't we be updated the UI to reflect that? // Register listeners printer.Settings.PrintLevelingEnabledChanged += Settings_PrintLevelingEnabledChanged; row.AddChild(printLevelingSwitch); } rightWidget = row; column.AddChild(lastRow); var probeWidget = new ProbePositionsWidget(printer, positions.Select(v => new Vector2(v)).ToList(), theme) { HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Absolute, Height = 200, Width = 200, RenderLevelingData = true, RenderProbePath = false, SimplePoints = true, }; lastRow.AddChild(probeWidget); } else { column.AddChild(lastRow); if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { lastRow.AddChild(new WrappedTextWidget( @"Print Leveling is an optional feature for this printer that can help improve print quality. If the bed is uneven or cannot be mechanically leveled.".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); } else if (printer.Settings.GetValue <bool>(SettingsKey.validate_leveling)) { lastRow.AddChild(new WrappedTextWidget( @"Print Leveling will run automatically at the start of each print.".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); } else { lastRow.AddChild(new HorizontalSpacer()); } } lastRow.AddChild(new HorizontalSpacer()); AddRunStageButton("Run Print Leveling".Localize(), theme, stage, lastRow); widget = column; } if (stage is XyCalibrationWizard xyWizard) { var row = CreateColumn(theme); row.FlowDirection = FlowDirection.LeftToRight; var hotendOffset = printer.Settings.Helpers.ExtruderOffset(1); var tool2Column = new FlowLayoutWidget(FlowDirection.TopToBottom); row.AddChild(tool2Column); tool2Column.AddChild( new TextWidget("Tool".Localize() + " 2", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { Margin = new BorderDouble(bottom: 4) }); tool2Column.AddChild( new ValueTag( "X Offset".Localize(), hotendOffset.X.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { Margin = new BorderDouble(bottom: 4), MinimumSize = new Vector2(125, 0) }); tool2Column.AddChild( new ValueTag( "Y Offset".Localize(), hotendOffset.Y.ToString("0.###"), new BorderDouble(12, 5, 2, 5), 5, 11) { MinimumSize = new Vector2(125, 0) }); row.AddChild(new HorizontalSpacer()); AddRunStageButton("Run Nozzle Alignment".Localize(), theme, stage, row); widget = row; } if (stage is LoadFilamentWizard filamentWizard) { widget.Margin = new BorderDouble(left: theme.DefaultContainerPadding); } var sectionName = stage.Title; if (stage.SetupRequired) { sectionName += " - " + "Required".Localize(); } else if (stage.Completed) { sectionName += " - " + "Completed".Localize(); } else { sectionName += " - " + "Optional".Localize(); } var section = new SectionWidget(sectionName, widget, theme, rightAlignedContent: rightWidget, expandingContent: false); theme.ApplyBoxStyle(section); section.Margin = section.Margin.Clone(left: 0); section.ShowExpansionIcon = false; if (stage.SetupRequired) { section.BackgroundColor = Color.Red.WithAlpha(30); } contentRow.AddChild(section); } return(homePage); }; }