Ask if printing on a printer tab before closing

This commit is contained in:
Lars Brubaker 2018-01-31 13:35:16 -08:00
parent 28bf5adf53
commit e014694bea

View file

@ -286,12 +286,39 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
closeButton.Name = "Close Tab Button";
closeButton.ToolTipText = "Close".Localize();
closeButton.Click += (sender, e) =>
{
UiThread.RunOnIdle(() =>
{
if (TabContent is PrinterTabPage printerTab
&& printerTab.printer.Connection.PrinterIsPrinting)
{
StyledMessageBox.ShowMessageBox(
(bool response) =>
{
if (response)
{
UiThread.RunOnIdle(() =>
{
this.parentTabControl.RemoveTab(this);
this.CloseClicked?.Invoke(this, null);
});
}
},
"Cancel the current print?".Localize(),
"Cancel Print?".Localize(),
StyledMessageBox.MessageType.YES_NO,
"Cancel Print".Localize(),
"Continue Printing".Localize());
}
else // need to handle asking about saving a
{
UiThread.RunOnIdle(() =>
{
this.parentTabControl.RemoveTab(this);
this.CloseClicked?.Invoke(this, null);
});
}
});
};
this.AddChild(closeButton);