Example #1
0
        /// <summary>
        /// Close this document removing it from its parent container
        /// </summary>
        /// <remarks>Use this function to close a document and remove it from its parent container. Please note
        /// that if you simply remove it from its parent <see cref="DocumentPane"/> without call this method, events like
        /// <see cref="OnClosing"/>/<see cref="OnClosed"/> are not called.
        /// </remarks>
        public override bool Close()
        {
            if (!IsCloseable)
            {
                return(false);
            }

            ////if documents are attached to an external source via DockingManager.DocumentsSource
            ////let application host handle the document closing by itself
            //if (Manager.DocumentsSource != null)
            //{
            //    //return Manager.FireRequestDocumentCloseEvent(this);
            //    Manager.HandleDocumentClose(this);
            //}


            DocumentClosingCancelEventArgs e = new DocumentClosingCancelEventArgs(false, this);

            OnClosing(e);

            if (e.Cancel)
            {
                return(false);
            }

            DockingManager oldManager = Manager;

            if (oldManager != null)
            {
                oldManager.FireDocumentClosingEvent(e);
            }

            if (e.Cancel)
            {
                return(false);
            }

            InternalClose();

            OnClosed();

            //if documents are attached to an external source via DockingManager.DocumentsSource
            //let application host handle the document closing by itself


            //if (oldManager != null &&
            //    oldManager.DocumentsSource != null)
            //{
            //    oldManager.HandleDocumentClose(this);
            //}

            if (oldManager != null)
            {
                DocumentClosedEventArgs documentClosedArgs = new DocumentClosedEventArgs(this);
                oldManager.FireDocumentClosedEvent(documentClosedArgs);
            }

            Debug.Assert(Parent == null, "Parent MUST bu null after Doc is closed");
            return(true);
        }
Example #2
0
 private void newDockableContent_Closed(object sender, DocumentClosedEventArgs e)
 {
     var dockableContent = e.Document;
     if (dockableContent != null)
     {
         if (this.Region.Views.Contains(dockableContent.Content))
         {
             _documents.Remove(dockableContent);
             this.Region.Remove(dockableContent.Content);
             //this.SynchronizeItems();
         }
     }
 }
        /// <summary>
        /// Close this document removing it from its parent container
        /// </summary>
        /// <remarks>Use this function to close a document and remove it from its parent container. Please note
        /// that if you simply remove it from its parent <see cref="DocumentPane"/> without call this method, events like
        /// <see cref="OnClosing"/>/<see cref="OnClosed"/> are not called.
        /// </remarks>
        public override bool Close()
        {
            if (!IsCloseable)
                return false;

            ////if documents are attached to an external source via DockingManager.DocumentsSource
            ////let application host handle the document closing by itself
            //if (Manager.DocumentsSource != null)
            //{
            //    //return Manager.FireRequestDocumentCloseEvent(this);
            //    Manager.HandleDocumentClose(this);
            //}


            DocumentClosingCancelEventArgs e = new DocumentClosingCancelEventArgs(false, this);
            OnClosing(e);
            
            if (e.Cancel)
                return false;

            DockingManager oldManager = Manager;

            if (oldManager != null)
                oldManager.FireDocumentClosingEvent(e);

            if (e.Cancel)
                return false;

            InternalClose();

            OnClosed();

            //if documents are attached to an external source via DockingManager.DocumentsSource
            //let application host handle the document closing by itself
            
            
            //if (oldManager != null &&
            //    oldManager.DocumentsSource != null)
            //{
            //    oldManager.HandleDocumentClose(this);
            //}

            if (oldManager != null)
            {
                DocumentClosedEventArgs documentClosedArgs = new DocumentClosedEventArgs(this);
                oldManager.FireDocumentClosedEvent(documentClosedArgs);
            }

            Debug.Assert(Parent == null, "Parent MUST bu null after Doc is closed");
            return true;
        }
Example #4
0
        internal void _ExecuteCloseCommand(LayoutDocument document)
        {
            if (DocumentClosing != null)
            {
                var evargs = new DocumentClosingEventArgs(document);
                DocumentClosing(this, evargs);
                if (evargs.Cancel)
                    return;
            }

            if (!document.TestCanClose())
                return;

            document.Close();

            if (DocumentClosed != null)
            {
                var evargs = new DocumentClosedEventArgs(document);
                DocumentClosed(this, evargs);
            }
        }
 internal void FireDocumentClosedEvent(DocumentClosedEventArgs e)
 {
     OnDocumentClosed(e);
 }
        /// <summary>
        /// Ovveride this method to handle <see cref="DocumentClosed"/> event.
        /// </summary>
        protected virtual void OnDocumentClosed(DocumentClosedEventArgs e)
        {
            if (DocumentClosed != null)
            {
                DocumentContent docContent = e.Document as DocumentContent;

                //if it was wrapped document remove it from the lookup, and set args to the content
                if (docContent != null && docContent.Content != null && m_wrapperDocumentCointainers.ContainsKey(docContent.Content))
                {
                    e.Document = docContent.Content;
                    m_wrapperDocumentCointainers.Remove(docContent.Content);
                }

                DocumentClosed(this, e);
            }
        }
Example #7
0
        private void DocumentClosed(object sender, DocumentClosedEventArgs e)
        {
            var template = e.Document.Content as RazorTemplateViewModel;

            if (template != null)
                ViewModel.Templates.Remove(template);
        }