Exemple #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);
            //}


            CancelEventArgs e = new CancelEventArgs(false);

            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)
            {
                oldManager.FireDocumentClosedEvent();
            }


            Debug.Assert(Parent == null, "Parent MUST bu null after Doc is closed");
            return(true);
        }