diff --git a/MatterControlLib/SetupWizard/StagedSetupWindow.cs b/MatterControlLib/SetupWizard/StagedSetupWindow.cs index f436a8559..9108f72d0 100644 --- a/MatterControlLib/SetupWizard/StagedSetupWindow.cs +++ b/MatterControlLib/SetupWizard/StagedSetupWindow.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.UI; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl { @@ -46,6 +47,7 @@ namespace MatterHackers.MatterControl private Dictionary rowsByStage = new Dictionary(); private IStagedSetupWizard setupWizard; + private bool closeConfirmed; public ISetupWizard ActiveStage { @@ -147,6 +149,24 @@ namespace MatterHackers.MatterControl this.AddChild(row); } + public override void OnClosing(ClosingEventArgs eventArgs) + { + if (this.ActiveStage != null + && !closeConfirmed) + { + // We need to show an interactive dialog to determine if the original Close request should be honored, thus cancel the current Close request + eventArgs.Cancel = true; + + ConditionalAbort("Are you sure you want to abort calibration?".Localize(), () => + { + closeConfirmed = true; + this.CloseOnIdle(); + }); + } + + base.OnClosing(eventArgs); + } + private void ConditionalAbort(string message, Action exitConfirmedAction) { UiThread.RunOnIdle(() =>