Exemplo n.º 1
0
        virtual public void CloseDocument()
        {
            if (OnCloseDocument != null)
            {
                DocumentCloseEventArgs args = new DocumentCloseEventArgs();
                args.FileName = string.Empty;

                OnCloseDocument(this, args);
            }
        }
Exemplo n.º 2
0
        Task DocumentManager_DocumentClosing(object sender, DocumentCloseEventArgs e)
        {
            NavigationPoint point = GetNavPointForDoc(e.Document, true) as DocumentNavigationPoint;

            if (point == null)
            {
                return(Task.CompletedTask);
            }

            closedHistory.Add(new Tuple <NavigationPoint, int> (point, documentManager.Documents.IndexOf(e.Document)));
            OnClosedHistoryChanged();
            return(Task.CompletedTask);
        }
Exemplo 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;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public async Task <bool> Close(bool force = false)
        {
            using (await asyncCriticalSection.EnterAsync()) {
                if (closed)
                {
                    return(true);
                }

                bool wasActive = documentManager.ActiveDocument == this;

                // Raise the closing event. Handlers have a chance to cancel the save operation

                var args = new DocumentCloseEventArgs(this, force, wasActive);
                args.Cancel = false;
                await OnClosing(args);

                if (!force && args.Cancel)
                {
                    return(false);
                }

                // Show the File not Saved UI

                if (!await ShowSaveUI(force))
                {
                    return(false);
                }

                closed = true;

                ClearTasks();

                Closed?.SafeInvoke(this, args);

                // Reset the root view before closing the view, otherwise shell.CloseView will destroy it.
                // We need the view to be functional until after the window is closed. The Dispose() method
                // already takes care of disposing the view, which will destroy the widget it contains
                window.SetRootView(null);

                shell.CloseView(window, true);

                Counters.OpenDocuments--;

                Dispose();

                return(true);
            }
        }
Exemplo n.º 5
0
        public async Task <bool> Close(bool force = false)
        {
            using (await asyncCriticalSection.EnterAsync()) {
                if (closed)
                {
                    return(true);
                }

                bool wasActive = documentManager.ActiveDocument == this;

                // Raise the closing event. Handlers have a chance to cancel the save operation

                var args = new DocumentCloseEventArgs(this, force, wasActive);
                args.Cancel = false;
                await OnClosing(args);

                if (!force && args.Cancel)
                {
                    return(false);
                }

                // Show the File not Saved UI

                if (!await ShowSaveUI(force))
                {
                    return(false);
                }

                closed = true;

                ClearTasks();

                try {
                    Closed?.Invoke(this, args);
                } catch (Exception ex) {
                    LoggingService.LogError("Exception while calling Closed event.", ex);
                }

                shell.CloseView(window, true);

                Counters.OpenDocuments--;

                Dispose();

                return(true);
            }
        }
Exemplo n.º 6
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);
                    }
                }
            }
        }