Esempio n. 1
0
        /// <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);
         }
     }
 }
Esempio n. 3
0
        async Task OnClosing(DocumentCloseEventArgs e)
        {
            if (Closing != null)
            {
                foreach (var handler in Closing.GetInvocationList().Cast <DocumentCloseAsyncEventHandler> ())
                {
                    await handler(this, e);

                    if (e.Cancel)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        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);
                    }
                }
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
 public bool ClosingIsHooked()
 {
     return(Closing != null && Closing.GetInvocationList().Length > 0);
 }