Dispose previous wizard when switching between stages

- Issue MatterHackers/MCCentral#5202
SetupWizards should be modified to undo their changes if aborted/
cancelled
This commit is contained in:
jlewin 2019-03-22 11:58:00 -07:00
parent a5b9e475bc
commit 0163cf6849

View file

@ -56,9 +56,13 @@ namespace MatterHackers.MatterControl
if (_activeStage != null
&& stageButtons.TryGetValue(_activeStage, out WizardStageRow activeButton))
{
// Mark the leftnav widget as inactive
activeButton.Active = false;
}
// Shutdown the active Wizard
_activeStage?.Dispose();
_activeStage = value;
if (stageButtons.TryGetValue(_activeStage, out WizardStageRow stageButton))
@ -78,7 +82,6 @@ namespace MatterHackers.MatterControl
this.stages = stages;
this.homePageGenerator = homePageGenerator;
var activeStage = stages.First();
var theme = AppContext.Theme;
var row = new FlowLayoutWidget()
@ -155,6 +158,11 @@ namespace MatterHackers.MatterControl
this.ActiveStage = nextStage;
return;
}
else
{
// Shutdown the active wizard
this.ActiveStage?.Dispose();
}
// Move to next unfinished wizard or move to summary/home page
this.ChangeToPage(homePageGenerator());