Пример #1
0
        private IVsWindowFrame CreateChildEditorFrame(Guid guidEditorFactory, SplitterPanel panel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsUIShellOpenDocument vsUISHOD = GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            IVsWindowFrame      childFrame = null;
            IVsUIHierarchy      vsUIHier;
            uint                itemid;
            int                 fOpen;
            Guid                guidLogEditorView = Guid.Empty;
            IOleServiceProvider oleServiceProvider;

            int hr = vsUISHOD.IsSpecificDocumentViewOpen((IVsUIHierarchy)this.vsHierarchy, this.itemid, this.fileName, ref guidEditorFactory, null, 0, out vsUIHier, out itemid, out childFrame, out fOpen);

            if (ErrorHandler.Succeeded(hr) && fOpen != 0)
            {
                // if already open, create a copy
                hr = vsUISHOD.OpenCopyOfStandardEditor(childFrame, ref guidLogEditorView, out childFrame);
            }
            else
            {
                hr = vsUISHOD.OpenDocumentViaProjectWithSpecific(fileName,
                                                                 (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor | (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen,
                                                                 ref guidEditorFactory, null, ref guidLogEditorView, out oleServiceProvider, out vsUIHier, out itemid, out childFrame);
            }

            if (ErrorHandler.Failed(hr))
            {
                Debug.Fail("Failed to create/open editor!!!");
                Marshal.ThrowExceptionForHR(hr);
            }

            IVsWindowFrame parentFrame = GetService(typeof(SVsWindowFrame)) as IVsWindowFrame;

            if (parentFrame == null)
            {
                throw new System.InvalidOperationException("could not retrieve the parent Window Frame");
            }

            childFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentFrame, parentFrame);
            childFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this);
            childFrame.SetProperty((int)__VSFPROPID3.VSFPROPID_NotifyOnActivate, true);
            childFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_DontAutoOpen, true);
            childFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentHwnd, panel.Handle);

            Guid cmdUITextEditorGuid = VSConstants.GUID_TextEditorFactory;

            childFrame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref cmdUITextEditorGuid);

            return(childFrame);
        }
Пример #2
0
        private void NewWindow()
        {
            int hr = VSConstants.S_OK;

            IVsUIShellOpenDocument uishellOpenDocument = (IVsUIShellOpenDocument)GetService(typeof(SVsUIShellOpenDocument));

            if (uishellOpenDocument != null)
            {
                IVsWindowFrame windowFrameOrig = (IVsWindowFrame)GetService(typeof(SVsWindowFrame));
                if (windowFrameOrig != null)
                {
                    Guid LOGVIEWID_Primary = Guid.Empty;
                    hr = uishellOpenDocument.OpenCopyOfStandardEditor(windowFrameOrig, ref LOGVIEWID_Primary, out IVsWindowFrame windowFrameNew);
                    if (windowFrameNew != null)
                    {
                        hr = windowFrameNew.Show();
                    }

                    ErrorHandler.ThrowOnFailure(hr);
                }
            }
        }