From d8375572ba6bba8f3b9ef3580a3b05cd4bdecae7 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 13 Aug 2020 11:15:30 -0700 Subject: [PATCH] Add buttons to calibration page to make it easier to run them issue: MatterHackers/MCCentral#5998 Have 'Do It' button on each calibration type --- .../ControlWidgets/IStagedSetupWizard.cs | 2 + .../PrinterCalibrationWizard.cs | 75 +++++++++++-------- MatterControlLib/SetupWizard/DialogWindow.cs | 1 + 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/MatterControlLib/PrinterControls/ControlWidgets/IStagedSetupWizard.cs b/MatterControlLib/PrinterControls/ControlWidgets/IStagedSetupWizard.cs index 53e41eb88..dd4128295 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/IStagedSetupWizard.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/IStagedSetupWizard.cs @@ -43,6 +43,8 @@ namespace MatterHackers.MatterControl bool AutoAdvance { get; set; } + StagedSetupWindow StagedSetupWindow { get; set; } + Func HomePageGenerator { get; } } } \ No newline at end of file diff --git a/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs b/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs index a404b1759..b888020c5 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs @@ -27,9 +27,6 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using System.Collections.Generic; -using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; @@ -40,11 +37,15 @@ using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.PrinterControls; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; +using System; +using System.Collections.Generic; +using System.Linq; namespace MatterHackers.MatterControl { public class PrinterCalibrationWizard : IStagedSetupWizard { + private PrinterConfig printer; private RoundedToggleSwitch printLevelingSwitch; public PrinterCalibrationWizard(PrinterConfig printer, ThemeConfig theme) @@ -105,8 +106,7 @@ namespace MatterHackers.MatterControl MinimumSize = new Vector2(125, 0) }); - column.AddChild(new HorizontalSpacer()); - column.AddChild(new TextButton("Run Z Calibration".Localize(), theme)); + AddRunStageButton("Run Z Calibration".Localize(), theme, stage, column); widget = column; } @@ -124,7 +124,6 @@ namespace MatterHackers.MatterControl var levelingSolution = printer.Settings.GetValue(SettingsKey.print_leveling_solution); - column.AddChild( new ValueTag( "Leveling Solution".Localize(), @@ -204,11 +203,7 @@ namespace MatterHackers.MatterControl }; leftToRight.AddChild(probeWidget); - leftToRight.AddChild(new HorizontalSpacer()); - leftToRight.AddChild(new TextButton("Run Print Leveling".Localize(), theme) - { - VAnchor = VAnchor.Bottom - }); + AddRunStageButton("Run Print Leveling".Localize(), theme, stage, leftToRight); } else if (!printer.Settings.GetValue(SettingsKey.print_leveling_required_to_print)) { @@ -260,11 +255,7 @@ namespace MatterHackers.MatterControl MinimumSize = new Vector2(125, 0) }); - row.AddChild(new HorizontalSpacer()); - row.AddChild(new TextButton("Run Nozzle Alignment".Localize(), theme) - { - VAnchor = VAnchor.Bottom - }); + AddRunStageButton("Run Nozzle Alignment".Localize(), theme, stage, row); widget = row; } @@ -299,36 +290,38 @@ namespace MatterHackers.MatterControl }; } - private void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e) + private void AddRunStageButton(string title, ThemeConfig theme, ISetupWizard stage, FlowLayoutWidget leftToRight) { - if (printLevelingSwitch != null) + leftToRight.AddChild(new HorizontalSpacer()); + var runStage = leftToRight.AddChild(new TextButton(title, theme) { - printLevelingSwitch.Checked = printer.Settings.GetValue(SettingsKey.print_leveling_enabled); - } - } + VAnchor = VAnchor.Bottom + }); - private static FlowLayoutWidget CreateColumn(ThemeConfig theme) - { - return new FlowLayoutWidget(FlowDirection.TopToBottom) + runStage.Click += (s, e) => { - Margin = new BorderDouble(theme.DefaultContainerPadding, theme.DefaultContainerPadding, theme.DefaultContainerPadding, 4) + // Only allow leftnav when not running SetupWizard + if (StagedSetupWindow?.ActiveStage == null) + { + StagedSetupWindow.ActiveStage = stage; + } }; } public bool AutoAdvance { get; set; } - public string Title { get; } = "Printer Calibration".Localize(); - - public Vector2 WindowSize { get; } = new Vector2(1200, 700); - - public IEnumerable Stages { get; } - - private PrinterConfig printer; - public Func HomePageGenerator { get; } public bool ReturnedToHomePage { get; set; } = false; + public StagedSetupWindow StagedSetupWindow { get; set; } + + public IEnumerable Stages { get; } + + public string Title { get; } = "Printer Calibration".Localize(); + + public Vector2 WindowSize { get; } = new Vector2(1200, 700); + public static bool SetupRequired(PrinterConfig printer, bool requiresLoadedFilament) { return printer == null @@ -338,5 +331,21 @@ namespace MatterHackers.MatterControl || (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun1(printer)) || XyCalibrationWizard.NeedsToBeRun(printer); } + + private static FlowLayoutWidget CreateColumn(ThemeConfig theme) + { + return new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Margin = new BorderDouble(theme.DefaultContainerPadding, theme.DefaultContainerPadding, theme.DefaultContainerPadding, 4) + }; + } + + private void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e) + { + if (printLevelingSwitch != null) + { + printLevelingSwitch.Checked = printer.Settings.GetValue(SettingsKey.print_leveling_enabled); + } + } } } \ No newline at end of file diff --git a/MatterControlLib/SetupWizard/DialogWindow.cs b/MatterControlLib/SetupWizard/DialogWindow.cs index 2b067a688..66cae1908 100644 --- a/MatterControlLib/SetupWizard/DialogWindow.cs +++ b/MatterControlLib/SetupWizard/DialogWindow.cs @@ -93,6 +93,7 @@ namespace MatterHackers.MatterControl var instanceIndex = 0; var wizardWindow = new StagedSetupWindow(setupWizard); + setupWizard.StagedSetupWindow = wizardWindow; wizardWindow.Closed += (s, e) => allWindows.Remove((type, instanceIndex)); allWindows[(type, instanceIndex)] = wizardWindow;