本文整理汇总了C#中IVsWindowFrame.CloseFrame方法的典型用法代码示例。如果您正苦于以下问题:C# IVsWindowFrame.CloseFrame方法的具体用法?C# IVsWindowFrame.CloseFrame怎么用?C# IVsWindowFrame.CloseFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsWindowFrame
的用法示例。
在下文中一共展示了IVsWindowFrame.CloseFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseWindowFrame
protected static void CloseWindowFrame(ref IVsWindowFrame windowFrame)
{
if (windowFrame != null)
{
try
{
ErrorHandler.ThrowOnFailure(windowFrame.CloseFrame(0));
}
finally
{
windowFrame = null;
}
}
}
示例2: CloseWindowFrame
protected static void CloseWindowFrame(ref IVsWindowFrame windowFrame)
{
if (windowFrame != null)
{
try
{
windowFrame.CloseFrame(0);
}
finally
{
windowFrame = null;
}
}
}
示例3: 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);
}
}
示例4: OpenItem
public static void OpenItem(IServiceProvider site, bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, 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 && punkDocDataExisting.ToInt64() != -1L) {
fullPath = VsShell.GetFilePath(punkDocDataExisting);
}
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);
// todo: what if the path is a URL?
fullPath = dir != null ? Path.Combine(dir,(string)pvar) : (string)pvar;
}
HierarchyNode node = pHierarchy as HierarchyNode;
IVsUIHierarchy pRootHierarchy = node == null ? (IVsUIHierarchy) pHierarchy : node.projectMgr;
IVsUIHierarchy pVsUIHierarchy = pRootHierarchy;
IVsUIShellOpenDocument doc = site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
const uint OSE_ChooseBestStdEditor = 0x20000000;
const uint OSE_UseOpenWithDialog = 0x10000000;
const uint OSE_OpenAsNewFile = 0x40000000;
if (openWith) {
IOleServiceProvider psp = site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
doc.OpenStandardEditor(OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, pVsUIHierarchy, itemid, docData, psp, out windowFrame);
} else {
// First we see if someone else has opened the requested view of the file.
IVsRunningDocumentTable pRDT = site.GetService(typeof(SVsRunningDocumentTable)) as 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 = new uint[1];
int pfOpen;
doc.IsDocumentOpen(pVsUIHierarchy, itemid, fullPath, ref logicalView, (uint)__VSIDOFLAGS.IDO_ActivateIfOpen, out ppHierOpen, pitemidOpen, out windowFrame, out pfOpen);
if (pfOpen == 1 && editorType != Guid.Empty) {
if (windowFrame != null) {
Guid currentEditor;
windowFrame.GetGuidProperty((int)__VSFPROPID.VSFPROPID_guidEditorType, out currentEditor);
if (currentEditor == editorType) {
goto done;
}
}
windowFrame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_PromptSave);
windowFrame = null;
pfOpen = 0;
}
if (pfOpen != 1) {
uint openFlags = 0;
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.
IOleServiceProvider psp = site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
if (editorType != Guid.Empty) {
doc.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, pRootHierarchy, hierarchyId, docData, psp, out windowFrame);
} else {
openFlags |= OSE_ChooseBestStdEditor;
doc.OpenStandardEditor(openFlags, fullPath, ref logicalView, caption, pRootHierarchy, hierarchyId, docData, psp, out windowFrame);
}
if (windowFrame != null) {
if (newFile) {
object var;
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var);
IVsPersistDocData ppd = (IVsPersistDocData)var;
ppd.SetUntitledDocPath(fullPath);
}
}
}
}
done:
if (windowFrame != null)
windowFrame.Show();
} catch (COMException e) {
if ((uint)e.ErrorCode != (uint)OleErrors.OLE_E_PROMPTSAVECANCELLED) {
#if DEBUG
MessageBox.Show(e.Message);
#endif
}
//.........这里部分代码省略.........