本文整理汇总了C#中IVsWindowFrame.Show方法的典型用法代码示例。如果您正苦于以下问题:C# IVsWindowFrame.Show方法的具体用法?C# IVsWindowFrame.Show怎么用?C# IVsWindowFrame.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsWindowFrame
的用法示例。
在下文中一共展示了IVsWindowFrame.Show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenWithSpecific
public override int OpenWithSpecific(uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) {
frame = null;
Debug.Assert(editorType == VSConstants.GUID_ProjectDesignerEditor, "Cannot open project designer with guid " + editorType.ToString());
if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) {
return VSConstants.E_FAIL;
}
IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
if (serviceProvider != null && uiShellOpenDocument != null) {
string fullPath = this.GetFullPathForDocument();
string caption = this.GetOwnerCaption();
IVsUIHierarchy parentHierarchy = this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchy) as IVsUIHierarchy;
IntPtr parentHierarchyItemId = (IntPtr)this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid);
ErrorHandler.ThrowOnFailure(uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, parentHierarchy, (uint)(parentHierarchyItemId.ToInt32()), docDataExisting, serviceProvider, out frame));
if (frame != null) {
if (windowFrameAction == WindowFrameShowAction.Show) {
ErrorHandler.ThrowOnFailure(frame.Show());
}
}
}
return VSConstants.S_OK;
}
示例2: NavigateToFrame
public static bool NavigateToFrame(IVsWindowFrame frame, int start, int length) {
int hr = frame.Show();
if (ErrorHandler.Succeeded(hr)) {
IVsTextView vsTextView = VsShellUtilities.GetTextView(frame);
if (vsTextView != null) {
return NavigateToTextView(vsTextView, start, length);
}
}
return false;
}
示例3: GetAlreadyOpenedDocument
public bool GetAlreadyOpenedDocument(string path, out IVsWindowFrame windowFrame)
{
Validate.IsNotNull(path, nameof(path));
IVsUIHierarchy hierarchy;
uint itemId;
// DevDiv 248655: Calling OpenFile on a previewed document will promote it.
// Do not promote unnecessarily. Simply activate the window if it exists.
if (!VsShellUtilities.IsDocumentOpen(this.singletons.ServiceProvider, path, VSConstants.LOGVIEWID.Code_guid, out hierarchy, out itemId, out windowFrame) || windowFrame == null)
{
return false;
}
return ErrorHandler.Succeeded(windowFrame.Show());
}
示例4: OpenItem
private int OpenItem(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction)
{
frame = null;
if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
{
return VSConstants.E_FAIL;
}
int result = VSConstants.S_OK;
uint[] ppItemId = new uint[1];
ppItemId[0] = this.ID;
int open;
IVsUIHierarchy project;
string fullPath = GetMkDocument();
// check if the file exists
if (!System.IO.File.Exists(fullPath))
{
// TODO Inform clients that we have an invalid item (wrong icon)
//// Inform clients that we have an invalid item (wrong icon)
//this.Node.OnInvalidateItems(this.Node.Parent);
return VSConstants.S_FALSE;
}
IVsUIShellOpenDocument sod = (this.ProjectMgr as CogaenEditProject).Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
if (sod != null)
{
try
{
// try to get hold of the open file
sod.IsDocumentOpen(this.ProjectMgr
, this.ID
, GetMkDocument()
, ref logicalView /* LOGVIEWID_Code to show xml behind */
, (uint)__VSIDOFLAGS.IDO_ActivateIfOpen
, out project
, ppItemId
, out frame
, out open);
// file is not open
if (open == 0)
{
// TODO load doc data
Load(fullPath, 0, 0);
docDataExisting = Marshal.GetIUnknownForObject(ObjectBuilder);
if (openWith)
{
result = sod.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog//(uint)__VSOSEFLAGS.OSE_ChooseBestStdEditor
, GetMkDocument()
, ref logicalView /* VSConstants.LOGVIEWID.Code_guid for xml behind*/
, Caption
, this.ProjectMgr
, this.ID
// TODO pass docData!!!!
, docDataExisting
, this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider
, out frame);
}
else
{
__VSOSEFLAGS openFlags = 0;
if (newFile)
{
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);
}
}
//.........这里部分代码省略.........
示例5: OpenDocument
/// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.OpenDocument"]/*' />
/// <devdoc>
/// Open document using the appropriate project.
/// </devdoc>
/// <param name="provider">The service provider.</param>
/// <param name="fullPath">Full path to the document.</param>
/// <param name="logicalView">GUID identifying the logical view.</param>
/// <param name="hierarchy">Reference to the IVsUIHierarchy interface of the project that contains the Open document.</param>
/// <param name="itemID"> Reference to the hierarchy item identifier of the document in the project.</param>
/// <param name="windowFrame">A reference to the window frame that is mapped to the document.</param>
public static void OpenDocument(IServiceProvider provider, string fullPath, Guid logicalView, out IVsUIHierarchy hierarchy, out uint itemID, out IVsWindowFrame windowFrame)
{
windowFrame = null;
itemID = VSConstants.VSITEMID_NIL;
hierarchy = null;
if (provider == null)
{
throw new ArgumentException("provider");
}
if (String.IsNullOrEmpty(fullPath))
{
throw new ArgumentException("fullPath");
}
//open document
if (!IsDocumentOpen(provider, fullPath, logicalView, out hierarchy, out itemID, out windowFrame))
{
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
if (shellOpenDoc != null)
{
IOleServiceProvider psp;
uint itemid;
ErrorHandler.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProject(fullPath, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame));
}
}
if (windowFrame != null)
{
ErrorHandler.ThrowOnFailure(windowFrame.Show());
}
}
示例6: OpenDocumentWithSpecificEditor
/// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.OpenDocumentWithSpecificEditor"]/*' />
/// <devdoc>
/// Open a document using a specific editor.
/// </devdoc>
/// <param name="provider">The service provider.</param>
/// <param name="fullPath">Full path to the document.</param>
/// <param name="editorType">Unique identifier of the editor type.</param>
/// <param name="logicalView">In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class</param>
/// <param name="hierarchy">Reference to the IVsUIHierarchy interface of the project that can open the document.</param>
/// <param name="itemID"> Reference to the hierarchy item identifier of the document in the project.</param>
/// <param name="windowFrame">A reference to the window frame that is mapped to the document.</param>
public static void OpenDocumentWithSpecificEditor(IServiceProvider provider, string fullPath, Guid editorType, Guid logicalView, out IVsUIHierarchy hierarchy, out uint itemID, out IVsWindowFrame windowFrame)
{
windowFrame = null;
itemID = VSConstants.VSITEMID_NIL;
hierarchy = null;
if (provider == null)
{
throw new ArgumentException("provider");
}
if (String.IsNullOrEmpty(fullPath))
{
throw new ArgumentException("fullPath");
}
//open document
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
IVsRunningDocumentTable pRDT = provider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
string physicalView = null;
if (pRDT != null && shellOpenDoc != null)
{
ErrorHandler.ThrowOnFailure(shellOpenDoc.MapLogicalView(ref editorType, ref logicalView, out physicalView));
// See if the requested editor is already open with the requested view.
IntPtr punkDocData = IntPtr.Zero;
uint docCookie;
IVsHierarchy ppIVsHierarchy;
try
{
ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, fullPath, out ppIVsHierarchy, out itemID, out punkDocData, out docCookie));
int pfOpen;
uint flags = (uint)__VSIDOFLAGS.IDO_ActivateIfOpen;
int hr = shellOpenDoc.IsSpecificDocumentViewOpen((IVsUIHierarchy)ppIVsHierarchy, itemID, fullPath, ref editorType, physicalView, flags, out hierarchy, out itemID, out windowFrame, out pfOpen);
if (ErrorHandler.Succeeded(hr) && pfOpen == 1)
{
return;
}
}
finally
{
if (punkDocData != IntPtr.Zero)
{
Marshal.Release(punkDocData);
}
}
IOleServiceProvider psp;
uint editorFlags = (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor | (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen;
ErrorHandler.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProjectWithSpecific(fullPath, editorFlags, ref editorType, physicalView, ref logicalView, out psp, out hierarchy, out itemID, out windowFrame));
if (windowFrame != null)
ErrorHandler.ThrowOnFailure(windowFrame.Show());
psp = null;
}
}
示例7: OpenItem
//.........这里部分代码省略.........
//NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid
// of the node being opened, otherwise the debugger doesn't work.
IOleServiceProvider psp = site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
int retryCount = 1;
while (retryCount > 0)
{
try
{
if (editorType != Guid.Empty)
{
NativeMethods.ThrowOnFailure(doc.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, pRootHierarchy, hierarchyId, docData, psp, out windowFrame));
}
else
{
openFlags |= OSE_ChooseBestStdEditor;
NativeMethods.ThrowOnFailure(doc.OpenStandardEditor(openFlags, fullPath, ref logicalView, caption, pRootHierarchy, hierarchyId, docData, psp, out windowFrame));
}
break;
}
catch (Exception e)
{
if (e is COMException)
{
COMException ce = (COMException)e;
if (ce.ErrorCode == NativeMethods.OLE_E_PROMPTSAVECANCELLED)
{
break;
}
}
// perhaps the editor is not compatible with an existing one.
// try OpenStandardEditor.
if (editorType != Guid.Empty)
{
editorType = Guid.Empty;
}
else
{
throw e;
}
}
}
}
if (windowFrame != null)
{
if (newFile)
{
object var;
NativeMethods.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var));
IVsPersistDocData ppd = (IVsPersistDocData)var;
NativeMethods.ThrowOnFailure(ppd.SetUntitledDocPath(fullPath));
}
}
if (windowFrame != null)
NativeMethods.ThrowOnFailure(windowFrame.Show());
}
catch (Exception e)
{
error = e;
}
if (error != null)
{
string msg = error.Message;
if (logicalView != Guid.Empty)
{
if (editorType != Guid.Empty)
{
msg = String.Format(SR.GetString(SR.EditorViewError), logicalView.ToString(), editorType.ToString()) + "\r\n" + msg;
}
else
{
msg = String.Format(SR.GetString(SR.StandardEditorViewError), logicalView.ToString()) + "\r\n" + msg;
}
}
else if (editorType != Guid.Empty)
{
msg = String.Format(SR.GetString(SR.StandardEditorViewError), logicalView.ToString()) + "\r\n" + msg;
}
MessageBox.Show(msg, SR.GetString(SR.Error), MessageBoxButtons.OK, MessageBoxIcon.Error);
if (windowFrame != null)
{
try
{
NativeMethods.ThrowOnFailure(windowFrame.CloseFrame(0));
}
catch
{
}
windowFrame = null;
}
}
if (docData != punkDocDataExisting && docData != IntPtr.Zero)
{
Marshal.Release(docData);
}
}
示例8: OpenDocument
public static void OpenDocument(IServiceProvider provider, string fullPath, Guid logicalView, out IVsUIHierarchy hierarchy, uint[] itemID, out IVsWindowFrame windowFrame) {
windowFrame = null;
hierarchy = null;
//open document
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
IVsRunningDocumentTable pRDT = provider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
if (pRDT != null) {
IntPtr punkDocData;
uint docCookie;
uint pitemid;
IVsHierarchy ppIVsHierarchy;
pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, fullPath, out ppIVsHierarchy, out pitemid, out punkDocData, out docCookie);
if (punkDocData == IntPtr.Zero) {
IOleServiceProvider psp;
uint itemid;
shellOpenDoc.OpenDocumentViaProject(fullPath, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame);
if (windowFrame != null)
windowFrame.Show();
psp = null;
} else {
Marshal.Release(punkDocData);
int pfOpen;
shellOpenDoc.IsDocumentOpen((IVsUIHierarchy)ppIVsHierarchy, pitemid, fullPath, ref logicalView, (uint)__VSIDOFLAGS.IDO_IgnoreLogicalView, out hierarchy, itemID, out windowFrame, out pfOpen);
if (windowFrame != null)
windowFrame.Show();
}
}
}
示例9: OpenDocumentWithSpecificEditor
/// <include file='doc\Utilities.uex' path='docs/doc[@for="VsShell.OpenDocumentWithSpecificEditor1"]/*' />
public static void OpenDocumentWithSpecificEditor(IServiceProvider provider, string fullPath, Guid editorType, Guid logicalView, out IVsUIHierarchy hierarchy, out uint itemID, out IVsWindowFrame windowFrame) {
windowFrame = null;
itemID = NativeMethods.VSITEMID_NIL;
hierarchy = null;
//open document
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
RunningDocumentTable pRDT = new RunningDocumentTable(provider);
string physicalView = null;
if (shellOpenDoc != null) {
NativeMethods.ThrowOnFailure(shellOpenDoc.MapLogicalView(ref editorType, ref logicalView, out physicalView));
// See if the requested editor is already open with the requested view.
uint docCookie;
IVsHierarchy ppIVsHierarchy;
object docData = pRDT.FindDocument(fullPath, out ppIVsHierarchy, out itemID, out docCookie);
if (docData != null) {
int pfOpen;
uint flags = (uint)__VSIDOFLAGS.IDO_ActivateIfOpen;
int hr = shellOpenDoc.IsSpecificDocumentViewOpen((IVsUIHierarchy)ppIVsHierarchy, itemID, fullPath, ref editorType, physicalView, flags, out hierarchy, out itemID, out windowFrame, out pfOpen);
if (NativeMethods.Succeeded(hr) && pfOpen == 1) {
return;
}
}
IOleServiceProvider psp;
uint editorFlags = (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor | (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen;
NativeMethods.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProjectWithSpecific(fullPath, editorFlags, ref editorType, physicalView, ref logicalView, out psp, out hierarchy, out itemID, out windowFrame));
if (windowFrame != null)
NativeMethods.ThrowOnFailure(windowFrame.Show());
psp = null;
}
}
示例10: OpenDocument
/// <include file='doc\Utilities.uex' path='docs/doc[@for="VsShell.OpenDocument1"]/*' />
public static void OpenDocument(IServiceProvider provider, string fullPath, Guid logicalView, out IVsUIHierarchy hierarchy, out uint itemID, out IVsWindowFrame windowFrame) {
windowFrame = null;
itemID = NativeMethods.VSITEMID_NIL;
hierarchy = null;
//open document
if (!IsDocumentOpen(provider, fullPath, Guid.Empty, out hierarchy, out itemID, out windowFrame)) {
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
if (shellOpenDoc != null) {
IOleServiceProvider psp;
uint itemid;
NativeMethods.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProject(fullPath, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame));
if (windowFrame != null)
NativeMethods.ThrowOnFailure(windowFrame.Show());
psp = null;
}
} else if (windowFrame != null) {
NativeMethods.ThrowOnFailure(windowFrame.Show());
}
}
示例11: OpenItem
public int OpenItem(uint itemid, ref Guid rguidLogicalView, IntPtr punkDocDataExisting, out IVsWindowFrame ppWindowFrame) {
_logger.LogHierarchy("OpenItem({0})", (int)itemid);
ppWindowFrame = null;
NodeViewModel node;
uint flags = 536936448U;
int hresult = 0;
if (!_nodes.FindNode(itemid, out node))
return VSConstants.E_FAIL;
if (string.IsNullOrEmpty(node.FullPath))
return VSConstants.E_NOTIMPL;
IVsUIHierarchy hierarchy;
uint itemid1;
if (!VsShellUtilities.IsDocumentOpen(_serviceProvider, node.FullPath, rguidLogicalView, out hierarchy, out itemid1, out ppWindowFrame)) {
IVsHierarchy hierOpen;
int isDocInProj;
IsDocumentInAnotherProject(node.FullPath, out hierOpen, out itemid1, out isDocInProj);
if (hierOpen == null) {
hresult = OpenItemViaMiscellaneousProject(flags, node.FullPath, ref rguidLogicalView, out ppWindowFrame);
} else {
var vsProject3 = hierOpen as IVsProject3;
hresult = vsProject3 == null
? OpenItemViaMiscellaneousProject(flags, node.FullPath, ref rguidLogicalView, out ppWindowFrame)
: vsProject3.OpenItem(itemid1, ref rguidLogicalView, punkDocDataExisting, out ppWindowFrame);
}
}
if (ppWindowFrame != null)
hresult = ppWindowFrame.Show();
return hresult;
}
示例12: OpenItem
public static void OpenItem(ServiceProvider site, bool newFile, bool openWith, ref Guid logicalView,
IntPtr punkDocDataExisting, IVsHierarchy pHierarchy,
uint hierarchyId, out IVsWindowFrame windowFrame) {
windowFrame = null;
IntPtr docData = punkDocDataExisting;
try {
uint itemid = hierarchyId;
object pvar;
pHierarchy.GetProperty(hierarchyId, (int)__VSHPROPID.VSHPROPID_Caption, out pvar);
string caption = (string)pvar;
string fullPath = null;
if (punkDocDataExisting != IntPtr.Zero) {
try {
// if interface is not supported, return null
IPersistFileFormat pff = (IPersistFileFormat)Marshal.GetTypedObjectForIUnknown(punkDocDataExisting, typeof(IPersistFileFormat));
uint format;
pff.GetCurFile(out fullPath, out format);
}
catch {
};
}
if (fullPath == null) {
string dir;
pHierarchy.GetProperty((uint)VsConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectDir, out pvar);
dir = (string)pvar;
pHierarchy.GetProperty(hierarchyId, (int)__VSHPROPID.VSHPROPID_SaveName, out pvar);
fullPath = dir != null ? Path.Combine(dir,(string)pvar) : (string)pvar;
}
IVsUIHierarchy pRootHierarchy = null;
pHierarchy.GetProperty((uint)VsConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Root, out pvar);
IntPtr ptr;
if (pvar == null) {
pRootHierarchy = (IVsUIHierarchy)pHierarchy;
} else {
ptr = (IntPtr)pvar;
pRootHierarchy = (IVsUIHierarchy)Marshal.GetTypedObjectForIUnknown(ptr, typeof(IVsUIHierarchy));
Marshal.Release(ptr);
}
IVsUIHierarchy pVsUIHierarchy = pRootHierarchy;
IVsUIShellOpenDocument doc = (IVsUIShellOpenDocument)site.QueryService(VsConstants.SID_VsUIShellOpenDocument, typeof(IVsUIShellOpenDocument));
const uint OSE_ChooseBestStdEditor = 0x20000000;
const uint OSE_UseOpenWithDialog = 0x10000000;
const uint OSE_OpenAsNewFile = 0x40000000;
if (openWith) {
doc.OpenStandardEditor(OSE_UseOpenWithDialog, fullPath, ref logicalView, caption,
pVsUIHierarchy, itemid, docData, site.Unwrap(), out windowFrame);
} else {
// First we see if someone else has opened the requested view of the file and if so,
// simply activate that view.
IVsRunningDocumentTable pRDT = (IVsRunningDocumentTable)site.QueryService(VsConstants.SID_SVsRunningDocumentTable, typeof(IVsRunningDocumentTable));
if (pRDT != null) {
uint docCookie;
IVsHierarchy ppIVsHierarchy;
pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock,
fullPath, out ppIVsHierarchy, out itemid, out docData, out docCookie);
if (ppIVsHierarchy != null && docCookie != VsConstants.VSDOCCOOKIE_NIL &&
pHierarchy != ppIVsHierarchy && pVsUIHierarchy != ppIVsHierarchy) {
// not opened by us, so call IsDocumentOpen with the right IVsUIHierarchy so we avoid the
// annoying "This document is opened by another project" message prompt.
pVsUIHierarchy = (IVsUIHierarchy)ppIVsHierarchy;
itemid = (uint)VsConstants.VSITEMID_SELECTION;
}
ppIVsHierarchy = null;
}
IVsUIHierarchy ppHierOpen;
uint pitemidOpen;
int pfOpen;
doc.IsDocumentOpen(pVsUIHierarchy, itemid, fullPath,
ref logicalView, (uint)__VSIDOFLAGS.IDO_ActivateIfOpen,
out ppHierOpen, out pitemidOpen, out windowFrame, out pfOpen);
if (pfOpen != 1) {
uint openFlags = OSE_ChooseBestStdEditor;
if (newFile) openFlags |= OSE_OpenAsNewFile;
//NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid
// of the node being opened, otherwise the debugger doesn't work.
doc.OpenStandardEditor(openFlags, fullPath, ref logicalView, caption,
pRootHierarchy, hierarchyId, docData,
site.Unwrap(), out windowFrame);
if (windowFrame != null) {
if (newFile) {
object var;
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var);
IVsPersistDocData ppd = (IVsPersistDocData)var;
ppd.SetUntitledDocPath(fullPath);
}
}
}
}
if (windowFrame != null)
windowFrame.Show();
} catch (COMException e) {
if ((uint)e.ErrorCode != (uint)OleErrors.OLE_E_PROMPTSAVECANCELLED) {
//.........这里部分代码省略.........
示例13: OpenDocument
public static void OpenDocument( ServiceProvider provider, string fullPath, out IVsUIHierarchy hierarchy,
out uint itemID, out IVsWindowFrame windowFrame, out IVsTextView view) {
view = null;
windowFrame = null;
itemID = VsConstants.VSITEMID_NIL;
hierarchy = null;
//open document
IVsUIShellOpenDocument shellOpenDoc = (IVsUIShellOpenDocument)provider.QueryService(VsConstants.SID_SVsUIShellOpenDocument, typeof(IVsUIShellOpenDocument));
IVsRunningDocumentTable pRDT = (IVsRunningDocumentTable)provider.QueryService(VsConstants.SID_SVsRunningDocumentTable, typeof(IVsRunningDocumentTable));
if (pRDT != null) {
IntPtr punkDocData;
uint docCookie;
uint pitemid;
IVsHierarchy ppIVsHierarchy;
pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock,
fullPath, out ppIVsHierarchy, out pitemid, out punkDocData, out docCookie);
if (punkDocData == IntPtr.Zero) {
Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp;
uint itemid;
Guid logicalView = Guid.Empty;
shellOpenDoc.OpenDocumentViaProject(fullPath, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame);
if (windowFrame != null)
windowFrame.Show();
psp = null;
} else {
Marshal.Release(punkDocData);
Guid logicalView = Guid.Empty;
int pfOpen;
shellOpenDoc.IsDocumentOpen((IVsUIHierarchy)ppIVsHierarchy, pitemid, fullPath,
ref logicalView, (uint)__VSIDOFLAGS.IDO_IgnoreLogicalView,
out hierarchy, out itemID, out windowFrame, out pfOpen);
if (windowFrame != null)
windowFrame.Show();
}
}
//return objects
WindowFrameGetTextView( windowFrame, out view );
}
示例14: OpenDocumentWithSpecificEditor
public static void OpenDocumentWithSpecificEditor(IServiceProvider provider, string fullPath, Guid editorType, string physicalView, Guid logicalView, out IVsUIHierarchy hierarchy, uint[] itemID, out IVsWindowFrame windowFrame) {
windowFrame = null;
hierarchy = null;
//open document
IVsUIShellOpenDocument shellOpenDoc = provider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
IVsRunningDocumentTable pRDT = provider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
if (pRDT != null) {
IntPtr punkDocData;
uint docCookie;
uint pitemid;
IVsHierarchy ppIVsHierarchy;
pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, fullPath, out ppIVsHierarchy, out pitemid, out punkDocData, out docCookie);
if (punkDocData != IntPtr.Zero) {
Marshal.Release(punkDocData);
int pfOpen;
shellOpenDoc.IsDocumentOpen((IVsUIHierarchy)ppIVsHierarchy, pitemid, fullPath, ref logicalView, (uint)__VSIDOFLAGS.IDO_IgnoreLogicalView, out hierarchy, itemID, out windowFrame, out pfOpen);
hierarchy = null;
if (windowFrame != null) {
Guid currentEditor;
windowFrame.GetGuidProperty((int)__VSFPROPID.VSFPROPID_guidEditorType, out currentEditor);
object currentView;
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_pszPhysicalView, out currentView);
if (currentEditor == editorType && currentView != null && physicalView == currentView.ToString()) {
windowFrame.Show();
return;
}
}
//windowFrame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_PromptSave);
windowFrame = null;
}
IOleServiceProvider psp;
uint itemid;
uint editorFlags = (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor;
shellOpenDoc.OpenDocumentViaProjectWithSpecific(fullPath, editorFlags, ref editorType, physicalView, ref logicalView, out psp, out hierarchy, out itemid, out windowFrame);
if (windowFrame != null)
windowFrame.Show();
psp = null;
}
}
示例15: GetTextView
internal static IVsTextView GetTextView(IVsWindowFrame windowFrame)
{
if (windowFrame != null) {
object docView;
windowFrame.Show();
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out docView);
if (docView != null) {
IVsTextView textView = docView as IVsTextView;
if (textView == null) {
IVsCodeWindow codeWindow = docView as IVsCodeWindow;
if (codeWindow != null) {
codeWindow.GetPrimaryView(out textView);
}
}
return textView;
}
}
return null;
}