/// <summary> Attempts to close all of a forms covering (child-modal) "children". </summary> /// <returns> True if any covering forms were closed. </returns> public bool UncoverForm(IFormInterface form, CloseBehavior behavior) { Frontend.Client.Forms.FormStack formStack = Forms.First; int i; while (formStack != null) { for (i = 0; i < formStack.Forms.Count; i++) { if (formStack.Forms[i] == form) { for (int j = formStack.Forms.Count - 1; j > i; j--) { if (!formStack.Forms[j].Close(behavior)) { return(false); } } return(true); } } formStack = formStack.Next; } return(true); }
public void RequestClose(CloseBehavior behavior) { if (CloseRequested != null) { CloseRequested(this, behavior); } }
/// <summary> Requests that the form close. </summary> /// <returns> True if the form is closed. </returns> public bool Close(CloseBehavior behavior) { try { if (Accepting != null) { Accepting(this, EventArgs.Empty); } } catch (Exception AException) { this.HandleException(AException); return(false); } if (AcceptEnabled) { if (Closing(behavior)) { return(Closed(behavior)); } else { return(false); } } else { return(false); } }
/// <summary> Attempts to close the session's forms and returns true if they closed. </summary> /// <param name="exclude"> When true, the given root form is omitted. </param> public bool CloseAllForms(IHost exclude, CloseBehavior behavior) { Frontend.Client.Forms.FormStack formStack; Frontend.Client.Forms.FormStack next = this.Forms.First; while (next != null) { formStack = next; next = next.Next; // remember the next item before it get's lost while ( !formStack.IsEmpty() && ( (exclude == null) || (formStack.GetTopmostForm().HostNode != exclude) ) ) { if (!formStack.GetTopmostForm().Close(behavior)) { return(false); } } } return(true); }
public bool Close(CloseBehavior behavior) { if (_form != null) { _form.Close(behavior); } return(_form == null); // will be null of close succussfully completed (this should never be true for a windows form because closing will not happen until the next message loop iteration) }
public virtual bool Closed(CloseBehavior behavior) { var session = (Silverlight.Session)HostNode.Session; try { bool endOfStack = true; try { endOfStack = session.Forms.Remove(this); } finally { try { if (behavior == CloseBehavior.AcceptOrClose) { FormAccepted(); } else { FormRejected(); } } finally { try { Session.DispatcherInvoke((System.Action)(() => { if (Form != null) { session.Close(Form); } })); if (OnClosed != null) { OnClosed(this, EventArgs.Empty); } } finally { EndChildModal(); session.DisposeFormHost(HostNode, endOfStack); } } } return(true); } catch (Exception AException) { this.HandleException(AException); return(false); } }
/// <summary> Closes the session's forms and returns true if it is okay to close the session. </summary> /// <remarks> Closes all of the forms opened in this session (except for the root form). </remarks> public bool PrepareToClose(CloseBehavior behavior) { while (_formsByID.Count > 1) { foreach (IFormInterface form in Forms) { if (((_rootFormHost == null) || (_rootFormHost.Children.Count == 0) || (form != _rootFormHost.Children[0])) && !form.Close(behavior)) { return(false); } } } return(true); }
public virtual bool Closing(CloseBehavior behavior) { try { if (behavior == CloseBehavior.AcceptOrClose) { PostChanges(); return(true); } else { CancelChanges(); return(true); } } catch (Exception AException) { this.HandleException(AException); return(false); } }
public virtual void Close(CloseBehavior behavior) { if (_isAcceptReject) { if (behavior == CloseBehavior.AcceptOrClose) { DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.Cancel; } } else // Close { DialogResult = DialogResult.Abort; } if (!Modal) // Not truly modal { UnsafeNativeMethods.PostMessage(Handle, NativeMethods.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); //Close(); Don't call close directly here so that callers can safely complete their message loop before the form goes away. } }
// Close public bool Close(CloseBehavior behavior) { CancelEventArgs args = new CancelEventArgs(false); Closing(args); if (args.Cancel) { return(false); } if (IsAcceptReject) { if (behavior == CloseBehavior.AcceptOrClose) { PostChanges(); } else { CancelChanges(); } } HostNode.Session.Forms.Remove(this); try { if (IsAcceptReject) { if (behavior == CloseBehavior.AcceptOrClose) { AcceptForm(); } else { RejectForm(); } } } finally { if (behavior == CloseBehavior.AcceptOrClose) { if (_onAcceptForm != null) { _onAcceptForm(this); } } else { if (_onRejectForm != null) { _onRejectForm(this); } } EndModal(); } Closed(EventArgs.Empty); if ((HostNode != null) && (HostNode.NextRequest == null)) { HostNode.Dispose(); } return(true); }
/// <summary> Callback event from the main thread that the user is attempting to close the form. </summary> private void FormCloseRequested(object sender, CloseBehavior behavior) { Session.Invoke((System.Action)(() => { Close(behavior); })); }