本文整理汇总了C#中DTE2.OpenFile方法的典型用法代码示例。如果您正苦于以下问题:C# DTE2.OpenFile方法的具体用法?C# DTE2.OpenFile怎么用?C# DTE2.OpenFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DTE2
的用法示例。
在下文中一共展示了DTE2.OpenFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenCorrespondingFile
internal static void OpenCorrespondingFile(DTE2 _applicationObject)
{
if (_applicationObject.ActiveDocument != null)
{
string filename = System.IO.Path.GetFullPath(_applicationObject.ActiveDocument.FullName);
string[] extChain = new string[] { ".h", ".hpp", ".cpp", ".c" };
for ( int i=0; i<extChain.Length; ++i )
{
if (filename.ToLower().EndsWith(extChain[i]))
{
int nextIndex = i;
for (int j = 0; j < extChain.Length; ++j)
{
nextIndex = (nextIndex + 1) % extChain.Length;
string nextExt = extChain[nextIndex];
string newfilename = System.IO.Path.GetDirectoryName(filename) + "\\" + System.IO.Path.GetFileNameWithoutExtension(filename);
newfilename += nextExt;
if (File.Exists(newfilename))
{
Window w = _applicationObject.OpenFile(EnvDTE.Constants.vsViewKindPrimary, newfilename);
if (w != null)
{
w.Activate();
break;
}
}
else
{
System.Diagnostics.Debug.Print("There is no file : " + newfilename);
}
}
break;
}
}
}
else
{
System.Diagnostics.Debug.Print("ActiveDocument is null");
}
}
示例2: Run
public void Run(DTE2 _applicationObject)
{
List<FileDetails> fileDetails = new List<FileDetails>();
/*
* Create a list of all projects and files in the solution, so
* that we can display them later on to the user. This is done
* prior to showing the dialog.
*/
Projects projects = _applicationObject.Solution.Projects;
int projCount = _applicationObject.Solution.Projects.Count;
for (int i = 1; i <= projects.Count; i++ )
{
Project project = projects.Item(i);
CreateFileList(project.Name, project.ProjectItems, ref fileDetails);
}
/*
* formIncrementalOpen is the dialog in which the user filters
* the list of files.
*/
formIncrementalOpen openDlg = new formIncrementalOpen();
FileDetails resultFile = openDlg.Show(fileDetails);
if (resultFile != null)
{
string fullPath = Path.Combine(resultFile.Path, resultFile.FileName);
Window win = _applicationObject.OpenFile(EnvDTE.Constants.vsViewKindCode, fullPath);
win.Visible = true;
win.SetFocus();
}
}
示例3: GotoTypeByFullName
public static void GotoTypeByFullName(DTE2 dte, string name)
{
try
{
var ProjectItem = GetProjectItemFromFullName(dte, name);
var window = dte.OpenFile(vsViewKindCode, ProjectItem.FileNames[0]);
window.Activate();
}
catch(Exception ex)
{
Core.DebugLog.Debug.WriteDebug("error going to type " + name);
Core.DebugLog.Debug.WriteException(ex);
}
}
示例4: goTo
//hack for embedded constants.
private static void goTo(DTE2 dte, Position item)
{
var window = dte.OpenFile(vsViewKindCode, item.Filename);
window.Activate();
var selection = (TextSelection)dte.ActiveDocument.Selection;
selection.MoveToDisplayColumn(item.LineNumber, 0);
return;
}