Пример #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);
        }
        /// <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;
        }
 internal void FireDocumentClosingEvent(DocumentClosingCancelEventArgs e)
 {
     OnDocumentClosing(e);
 }
        /// <summary>
        /// Ovveride this method to handle <see cref="DocumentClosing"/> event.
        /// </summary>
        protected virtual void OnDocumentClosing(DocumentClosingCancelEventArgs e)
        {
            if (DocumentClosing != null && !e.Cancel)
            {
                DocumentContent docContent = e.Document as DocumentContent;

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

                DocumentClosing(this, e);
            }
        }