From 4f3fbba14de22ee41026537b700ea26b32d8dc3b Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 4 Apr 2019 16:54:33 -0700 Subject: [PATCH] Replace RunAnyRequiredPrinterSetup with Wizard.NextIncompleteStage() --- .../ApplicationView/ApplicationController.cs | 47 ------------------- .../CalibrateProbeLastPageInstructions.cs | 6 --- .../WizardPages/LastPageInstructions.cs | 8 ---- .../WizardPages/SelectMaterialPage.cs | 1 + .../PrintLeveling/WizardPages/WizardPage.cs | 9 +++- .../SetupWizard/StagedSetupWindow.cs | 14 ++++++ 6 files changed, 23 insertions(+), 62 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 7b5ef8156..a686cab26 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1621,53 +1621,6 @@ namespace MatterHackers.MatterControl || ProbeCalibrationWizard.NeedsToBeRun(printer); } - public bool RunAnyRequiredPrinterSetup(PrinterConfig printer, ThemeConfig theme) - { - // run probe calibration first if we need to - if (ProbeCalibrationWizard.NeedsToBeRun(printer)) - { - UiThread.RunOnIdle(() => - { - DialogWindow.Show(new ProbeCalibrationWizard(printer)); - }); - return true; - } - - // run the leveling wizard if we need to - if (LevelingValidation.NeedsToBeRun(printer)) - { - UiThread.RunOnIdle(() => - { - DialogWindow.Show(new PrintLevelingWizard(printer)); - }); - return true; - } - - // run load filament if we need to - if (LoadFilamentWizard.NeedsToBeRun0(printer)) - { - UiThread.RunOnIdle(() => - { - DialogWindow.Show( - new LoadFilamentWizard(printer, extruderIndex: 0, showAlreadyLoadedButton: true)); - }); - return true; - } - - // run load filament for extruder 1 if we need to - if (LoadFilamentWizard.NeedsToBeRun1(printer)) - { - UiThread.RunOnIdle(() => - { - DialogWindow.Show( - new LoadFilamentWizard(printer, extruderIndex: 1, showAlreadyLoadedButton: true)); - }); - return true; - } - - return false; - } - public void Shutdown() { // Ensure all threads shutdown gracefully on close diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs index 6a952e3eb..a4a12c46e 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs @@ -77,11 +77,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling base.OnLoad(args); } - - public override void OnClosed(EventArgs e) - { - // move from this wizard to the print leveling wizard if needed - ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs index a36452ed5..54a86877e 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs @@ -106,13 +106,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling base.OnLoad(args); } - - public override void OnClosed(EventArgs e) - { - // give instruction about how to load filament if the user has not gotten them - ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); - - base.OnClosed(e); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs index ff08f69d4..d0ef101f0 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs @@ -82,6 +82,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling alreadyLoadedButton.Click += (s, e) => { this.DialogWindow.ClosePage(); + switch (extruderIndex) { case 0: diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs index b997a9360..d46de43b4 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs @@ -118,7 +118,14 @@ namespace MatterHackers.MatterControl doneButton.Click += (s, e) => { - this.DialogWindow.ClosePage(); + if (this.DialogWindow is StagedSetupWindow setupWindow) + { + setupWindow.NextIncompleteStage(); + } + else + { + this.DialogWindow.ClosePage(); + } }; this.AddPageAction(doneButton); diff --git a/MatterControlLib/SetupWizard/StagedSetupWindow.cs b/MatterControlLib/SetupWizard/StagedSetupWindow.cs index 041fa71c5..f1ac0a8ed 100644 --- a/MatterControlLib/SetupWizard/StagedSetupWindow.cs +++ b/MatterControlLib/SetupWizard/StagedSetupWindow.cs @@ -157,6 +157,20 @@ namespace MatterHackers.MatterControl this.Invalidate(); } + public void NextIncompleteStage() + { + ISetupWizard nextStage = stages.FirstOrDefault(s => s.SetupRequired); + + if (nextStage != null) + { + this.ActiveStage = nextStage; + } + else + { + this.ClosePage(); + } + } + public override void ClosePage() { // Move to the summary/home page