/// <summary> /// Closes the document /// </summary> public void Close() { if (IsClosed) { return; } IsClosed = true; Closing?.Invoke(this, null); EditorTree?.Dispose(); // this will also remove event handlers EditorTree = null; if (Closing != null) { foreach (var eh in Closing.GetInvocationList()) { var closingHandler = eh as EventHandler <EventArgs>; if (closingHandler != null) { Debug.Fail(Invariant($"There are still listeners in the EditorDocument.OnDocumentClosing event list: {eh.Target}")); Closing -= closingHandler; } } } EditorBuffer?.Services?.RemoveService(this); EditorBuffer = null; }
protected virtual async Task OnClosing(WorkbenchWindowEventArgs e) { if (Closing != null) { foreach (var handler in Closing.GetInvocationList().Cast <WorkbenchWindowAsyncEventHandler> ()) { await handler(this, e); } } }
async Task OnClosing(DocumentCloseEventArgs e) { if (Closing != null) { foreach (var handler in Closing.GetInvocationList().Cast <DocumentCloseAsyncEventHandler> ()) { await handler(this, e); if (e.Cancel) { break; } } } }
async Task OnClosing(DocumentCloseEventArgs e) { if (Closing != null) { foreach (var handler in Closing.GetInvocationList().Cast <DocumentCloseAsyncEventHandler> ()) { try { await handler(this, e); if (e.Cancel) { break; } } catch (Exception ex) { LoggingService.LogInternalError(ex); } } } }
public bool CloseWindowSync() { var e = new WorkbenchWindowEventArgs(true, true); if (Closing != null) { foreach (var handler in Closing.GetInvocationList().Cast <WorkbenchWindowAsyncEventHandler> ()) { handler(this, e).Wait(); if (e.Cancel) { break; } } } Closed?.Invoke(this, e);; return(true); }
private void RemoveAllHandledEvents() { if (Shown != null) { foreach (var @delegate in Shown.GetInvocationList()) { var h = (EventHandler)@delegate; Shown -= h; } } if (Closing != null) { foreach (var @delegate in Closing.GetInvocationList()) { var h = (CancelEventHandler)@delegate; Closing -= h; } } if (Closed != null) { foreach (var @delegate in Closed.GetInvocationList()) { var h = (EventHandler)@delegate; Closed -= h; } } var p = Parent as FrameworkElement; if (p != null) { p.DataContextChanged -= Parent_DataContextChanged; } }
public bool ClosingIsHooked() { return(Closing != null && Closing.GetInvocationList().Length > 0); }