/// <summary>Close the application.</summary> /// <param name="askToSave">Flag to turn on the request to save</param> public void Close(bool askToSave) { if (askToSave && AllowClose != null) { AllowCloseArgs args = new AllowCloseArgs(); AllowClose.Invoke(this, args); if (!args.AllowClose) { return; } } _mainWidget.Destroy(); // Let all the destruction stuff be carried out, just in // case we've got any unmanaged resources that should be // cleaned up. while (GLib.MainContext.Iteration()) { ; } // If we're running a script passed as a command line argument, // we've never called Application.Run, so we don't want to call // Application.Quit. We test this by seeing whether the event // loop is active. If we're not running the Application loop, // call Exit instead. if (Application.CurrentEvent != null) { Application.Quit(); } else { Environment.Exit(0); } }
/// <summary>User is trying to close the application - allow that to happen?</summary> /// <param name="e">Event arguments.</param> protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); if (AllowClose != null) { AllowCloseArgs args = new AllowCloseArgs(); AllowClose.Invoke(this, args); e.Cancel = !args.AllowClose; } e.Cancel = false; }
/// <summary>User is trying to close the application - allow that to happen?</summary> /// <param name="e">Event arguments.</param> protected void OnClosing(object o, DeleteEventArgs e) { if (AllowClose != null) { AllowCloseArgs args = new AllowCloseArgs(); AllowClose.Invoke(this, args); e.RetVal = !args.AllowClose; } else { e.RetVal = false; } if ((bool)e.RetVal == false) { Close(false); } }
/// <summary>User is trying to close the application - allow that to happen?</summary> /// <param name="o">Sender object.</param> /// <param name="e">Event arguments.</param> protected void OnClosing(object o, DeleteEventArgs e) { try { if (AllowClose != null) { AllowCloseArgs args = new AllowCloseArgs(); AllowClose.Invoke(this, args); e.RetVal = !args.AllowClose; } else { e.RetVal = false; } if ((bool)e.RetVal == false) { Close(false); } } catch (Exception err) { ShowError(err); } }