Replace RunAnyRequiredPrinterSetup with Wizard.NextIncompleteStage()

This commit is contained in:
jlewin 2019-04-04 16:54:33 -07:00
parent d88b82ddb2
commit 4f3fbba14d
6 changed files with 23 additions and 62 deletions

View file

@ -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

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -82,6 +82,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
alreadyLoadedButton.Click += (s, e) =>
{
this.DialogWindow.ClosePage();
switch (extruderIndex)
{
case 0:

View file

@ -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);

View file

@ -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