当前位置: 首页>>代码示例>>C#>>正文


C# IVsWindowFrame.Hide方法代码示例

本文整理汇总了C#中IVsWindowFrame.Hide方法的典型用法代码示例。如果您正苦于以下问题:C# IVsWindowFrame.Hide方法的具体用法?C# IVsWindowFrame.Hide怎么用?C# IVsWindowFrame.Hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVsWindowFrame的用法示例。


在下文中一共展示了IVsWindowFrame.Hide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Open

        private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction)
        {
            windowFrame = null;
            if(this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed)
            {
                return VSConstants.E_FAIL;
            }

            Debug.Assert(this.Node != null, "No node has been initialized for the document manager");
            Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager");
            Debug.Assert(this.Node is FileNode, "Node is not FileNode object");

            int returnValue = VSConstants.S_OK;
            string caption = this.GetOwnerCaption();
            string fullPath = this.GetFullPathForDocument();

            // Make sure that the file is on disk before we open the editor and display message if not found
            if(!((FileNode)this.Node).IsFileOnDisk(true))
            {
                // Inform clients that we have an invalid item (wrong icon)
                this.Node.OnInvalidateItems(this.Node.Parent);

                // Bail since we are not able to open the item
                // Do not return an error code otherwise an internal error message is shown. The scenario for this operation
                // normally is already a reaction to a dialog box telling that the item has been removed.
                return VSConstants.S_FALSE;
            }

            IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
            IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;

            try
            {
                this.Node.ProjectMgr.OnOpenItem(fullPath);
                int result = VSConstants.E_FAIL;

                if(openWith)
                {
                    result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame);
                }
                else
                {
                    __VSOSEFLAGS openFlags = 0;
                    if(newFile)
                    {
                        openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile;
                    }

                    //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid
                    // of the node being opened, otherwise the debugger doesn't work.
                    if(editorType != Guid.Empty)
                    {
                        result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame);
                    }
                    else
                    {
                        openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor;
                        result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame);
                    }
                }

                if(result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED)
                {
                    ErrorHandler.ThrowOnFailure(result);
                }

                if(windowFrame != null)
                {
                    object var;

                    if(newFile)
                    {
                        ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var));
                        IVsPersistDocData persistDocData = (IVsPersistDocData)var;
                        ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath));
                    }

                    var = null;
                    ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var));
                    this.Node.DocCookie = (uint)(int)var;

                    if(windowFrameAction == WindowFrameShowAction.Show)
                    {
                        ErrorHandler.ThrowOnFailure(windowFrame.Show());
                    }
                    else if(windowFrameAction == WindowFrameShowAction.ShowNoActivate)
                    {
                        ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate());
                    }
                    else if(windowFrameAction == WindowFrameShowAction.Hide)
                    {
                        ErrorHandler.ThrowOnFailure(windowFrame.Hide());
                    }
                }
            }
            catch(COMException e)
            {
                Trace.WriteLine("Exception e:" + e.Message);
                returnValue = e.ErrorCode;
                CloseWindowFrame(ref windowFrame);
//.........这里部分代码省略.........
开发者ID:vestild,项目名称:nemerle,代码行数:101,代码来源:FileDocumentManager.cs

示例2: OpenItem


//.........这里部分代码省略.........
                            {
                                openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile;
                            }

                            openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor;

                            if (editorType != Guid.Empty)
                            {
                                result = sod.OpenSpecificEditor(editorFlags
                                    , fullPath
                                    , ref editorType
                                    , physicalView
                                    , ref logicalView
                                    , Caption
                                    , this.ProjectMgr
                                    , this.ID
                                    , docDataExisting
                                    , this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider
                                    , out frame);
                            }
                            else
                            {

                                result = sod.OpenStandardEditor((uint)openFlags
                                , GetMkDocument()
                                , ref logicalView /* VSConstants.LOGVIEWID.Code_guid for xml behind*/
                                , Caption
                                , this.ProjectMgr
                                , this.ID
                                , docDataExisting
                                , this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider
                                , out frame);
                            }
                        }
                        if (result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED)
                        {
                            ErrorHandler.ThrowOnFailure(result);
                        }
                        // eventually show window
                        if (frame != null)
                        {
                            object var;

                            if (newFile)
                            {
                                ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var));
                                IVsPersistDocData persistDocData = (IVsPersistDocData)var;
                                ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath));
                            }

                            var = null;
                            ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var));
                            this.DocCookie = (uint)(int)var;

                            if (windowFrameAction == WindowFrameShowAction.Show)
                            {
                                ErrorHandler.ThrowOnFailure(frame.Show());
                            }
                            else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate)
                            {
                                ErrorHandler.ThrowOnFailure(frame.ShowNoActivate());
                            }
                            else if (windowFrameAction == WindowFrameShowAction.Hide)
                            {
                                ErrorHandler.ThrowOnFailure(frame.Hide());
                            }
                        }
                    }
                    // file is already open
                    else
                    {
                        ObjectBuilder = Marshal.GetObjectForIUnknown(docDataExisting) as ObjectBuilder;
                        Marshal.Release(docDataExisting);

                        if (frame != null)
                        {
                            if (windowFrameAction == WindowFrameShowAction.Show)
                            {
                                ErrorHandler.ThrowOnFailure(frame.Show());
                            }
                            else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate)
                            {
                                ErrorHandler.ThrowOnFailure(frame.ShowNoActivate());
                            }
                            else if (windowFrameAction == WindowFrameShowAction.Hide)
                            {
                                ErrorHandler.ThrowOnFailure(frame.Hide());
                            }
                        }
                    }
                }
                catch (COMException e)
                {
                    Trace.WriteLine("Exception e:" + e.Message);
                    result = e.ErrorCode;
                    CloseWindowFrame(ref frame);
                }
            }
            return result;
        }
开发者ID:DelBero,项目名称:XnaScrapEdit,代码行数:101,代码来源:CogaenEditFile.cs


注:本文中的IVsWindowFrame.Hide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。