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


C# DTE2.OpenFile方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:zelon,项目名称:ZAssist,代码行数:47,代码来源:ZAssistManager.cs

示例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();
            }
        }
开发者ID:martinknafve,项目名称:incrementalfileopener,代码行数:36,代码来源:AddinApplication.cs

示例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);
     }
 }
开发者ID:JamesTryand,项目名称:AutoTest.Net,代码行数:14,代码来源:MethodFinder_Slow.cs

示例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;
        }
开发者ID:JamesTryand,项目名称:AutoTest.Net,代码行数:10,代码来源:MethodFinder_Slow.cs


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