Extract AllowCancel
This commit is contained in:
parent
a7a53c6712
commit
2d3f71ba28
1 changed files with 17 additions and 5 deletions
|
|
@ -186,11 +186,7 @@ namespace MatterHackers.MatterControl
|
|||
// Add 'Close' event listener after derived types have had a chance to register event listeners
|
||||
cancelButton.Click += (s, e) =>
|
||||
{
|
||||
this.OnCancel(out bool pageAbortCancel);
|
||||
this.DialogWindow.OnCancel(out bool windowAbortCancel);
|
||||
|
||||
if (!pageAbortCancel
|
||||
&& !windowAbortCancel)
|
||||
if (this.AllowCancel())
|
||||
{
|
||||
this.DialogWindow?.ClosePage();
|
||||
}
|
||||
|
|
@ -205,6 +201,22 @@ namespace MatterHackers.MatterControl
|
|||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public bool AllowCancel()
|
||||
{
|
||||
bool windowAbortCancel = false;
|
||||
|
||||
this.OnCancel(out bool pageAbortCancel);
|
||||
|
||||
if (!pageAbortCancel)
|
||||
{
|
||||
this.DialogWindow.OnCancel(out windowAbortCancel);
|
||||
}
|
||||
|
||||
// Allow cancel if page and DialogWindow do not abort
|
||||
return !pageAbortCancel
|
||||
&& !windowAbortCancel;
|
||||
}
|
||||
|
||||
protected virtual void OnCancel(out bool abortCancel)
|
||||
{
|
||||
abortCancel = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue