Example #1
0
        /// <summary>
        /// Close an open document window
        /// </summary>
        /// <param name="closeFlag">Decides how to close the document</param>
        /// <returns>S_OK if successful, otherwise an error is returned</returns>
        public virtual int Close(__FRAMECLOSE closeFlag)
        {
            if (this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed)
            {
                return(VSConstants.E_FAIL);
            }

            // Get info about the document
            bool isDirty, isOpen, isOpenedByUs;
            uint docCookie;
            IVsPersistDocData ppIVsPersistDocData;

            this.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData);

            if (isOpenedByUs)
            {
                IVsUIShellOpenDocument shell = this.Node.ProjectMgr.Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                Guid           logicalView   = Guid.Empty;
                uint           grfIDO        = 0;
                IVsUIHierarchy pHierOpen;
                uint[]         itemIdOpen = new uint[1];
                IVsWindowFrame windowFrame;
                int            fOpen;
                ErrorHandler.ThrowOnFailure(shell.IsDocumentOpen(this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, this.Node.Url, ref logicalView, grfIDO, out pHierOpen, itemIdOpen, out windowFrame, out fOpen));

                if (windowFrame != null)
                {
                    docCookie = 0;
                    return(windowFrame.CloseFrame((uint)closeFlag));
                }
            }

            return(VSConstants.S_OK);
        }
Example #2
0
        /// <summary>
        /// Close an open document window
        /// </summary>
        /// <param name="closeFlag">Decides how to close the document</param>
        /// <returns>S_OK if successful, otherwise an error is returned</returns>
        public virtual int Close(__FRAMECLOSE closeFlag)
        {
            if (this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.IsClosing)
            {
                return(VSConstants.E_FAIL);
            }

            if (this.IsOpenedByUs)
            {
                var            shell       = this.Node.ProjectMgr.Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                var            logicalView = Guid.Empty;
                uint           grfIDO      = 0;
                IVsUIHierarchy pHierOpen;
                var            itemIdOpen = new uint[1];
                IVsWindowFrame windowFrame;
                int            fOpen;
                ErrorHandler.ThrowOnFailure(shell.IsDocumentOpen(this.Node.ProjectMgr, this.Node.ID, this.Node.Url, ref logicalView, grfIDO, out pHierOpen, itemIdOpen, out windowFrame, out fOpen));

                if (windowFrame != null)
                {
                    return(windowFrame.CloseFrame((uint)closeFlag));
                }
            }

            return(VSConstants.S_OK);
        }
        /// <summary>
        /// Close an open document window
        /// </summary>
        /// <param name="closeFlag">Decides how to close the document</param>
        /// <returns>S_OK if successful, otherwise an error is returned</returns>
        public virtual int Close(__FRAMECLOSE closeFlag)
        {
            if (this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed)
            {
                return VSConstants.E_FAIL;
            }

            // Get info about the document
            bool isDirty, isOpen, isOpenedByUs;
            uint docCookie;
            IVsPersistDocData ppIVsPersistDocData;
            this.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData);

            if (isOpenedByUs)
            {
                IVsUIShellOpenDocument shell = this.Node.ProjectMgr.Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                Guid logicalView = Guid.Empty;
                uint grfIDO = 0;
                IVsUIHierarchy pHierOpen;
                uint[] itemIdOpen = new uint[1];
                IVsWindowFrame windowFrame;
                int fOpen;
                ErrorHandler.ThrowOnFailure(shell.IsDocumentOpen(this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, this.Node.Url, ref logicalView, grfIDO, out pHierOpen, itemIdOpen, out windowFrame, out fOpen));

                if (windowFrame != null)
                {
                    docCookie = 0;
                    return windowFrame.CloseFrame((uint)closeFlag);
                }
            }

            return VSConstants.S_OK;
        }
Example #4
0
        /// <summary>
        /// Close an open document window
        /// </summary>
        /// <param name="closeFlag">Decides how to close the document</param>
        /// <returns>S_OK if successful, otherwise an error is returned</returns>
        public virtual int Close(__FRAMECLOSE closeFlag) {
            if (this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.IsClosing) {
                return VSConstants.E_FAIL;
            }

            if (IsOpenedByUs) {
                IVsUIShellOpenDocument shell = this.Node.ProjectMgr.Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                Guid logicalView = Guid.Empty;
                uint grfIDO = 0;
                IVsUIHierarchy pHierOpen;
                uint[] itemIdOpen = new uint[1];
                IVsWindowFrame windowFrame;
                int fOpen;
                ErrorHandler.ThrowOnFailure(shell.IsDocumentOpen(this.Node.ProjectMgr, this.Node.ID, this.Node.Url, ref logicalView, grfIDO, out pHierOpen, itemIdOpen, out windowFrame, out fOpen));

                if (windowFrame != null) {
                    return windowFrame.CloseFrame((uint)closeFlag);
                }
            }

            return VSConstants.S_OK;
        }
 protected override void CloseFrameInternal(IVsWindowFrame WindowFrame, __FRAMECLOSE flags)
 {
     //NOOP
 }