博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
代码片段
阅读量:6841 次
发布时间:2019-06-26

本文共 4360 字,大约阅读时间需要 14 分钟。

  hot3.png

private EventHandler(DTE2 app, AddIn addin)        {            this._applicationObject = app;            this._addInInstance = addin;            e = (TaskListEventsClass)app.Events.get_TaskListEvents(null);            e.TaskNavigated += new _dispTaskListEvents_TaskNavigatedEventHandler(e_TaskNavigated);            Window winPre = app.ActiveWindow;            Window win = app.Windows.Item(Constants.vsWindowKindTaskList);            win.Activate();            winPre.Activate();            frm = null;        }                if (this.win == null)                {                    string guid = "{87907470-2841-11de-8c30-0800200c9a66}";                    object obj = new object();                    Windows2 windows = (Windows2)this._applicationObject.Windows;                    string asm = Assembly.GetCallingAssembly().Location;                    this.win = (Window2)windows.CreateToolWindow2(this._addInInstance,                        asm, "EasyAddin.StackTree", "调用关系树", guid, ref obj);                    this.st = (StackTree)obj;                }                TextSelection ts = (TextSelection)this._applicationObject.ActiveWindow.Selection;                EditPoint ep = ts.ActivePoint.CreateEditPoint();                            CodeElement ce = GetCodeElement(ts);                    int startLine = 0;                    if (null != ce)                    {                        strFuncName = ce.FullName;                        strShortName = ce.Name;                        startLine = ce.StartPoint.Line;                    }                    this.st.AddNode(strFuncName, strTxt, _applicationObject.ActiveDocument.FullName, ts.TopPoint.Line, strShortName);                    strFuncName = string.Format("{0}[{1}] [{2}]", subCat, strFuncName, strTxt);CodeElement GetCodeElement(object tsORpoint)        {            CodeElement ce = null;            TextSelection ts = tsORpoint as TextSelection;            EditPoint ep ;            if (null != ts)            {                ep = ts.ActivePoint.CreateEditPoint();            }            else            {                ep = tsORpoint as EditPoint;            }            ep.EndOfLine();            int[] eleKind = new int[] { (int)vsCMElement.vsCMElementFunction, (int)vsCMElement.vsCMElementClass };            foreach (int a in eleKind)            {                vsCMElement eTmp = (vsCMElement)a;                ce = ep.get_CodeElement(eTmp);                if (null != ce)                {                    break;                }            }            if (null == ce)            {                for (int i = (int)vsCMElement.vsCMElementOther;                    i <= (int)vsCMElement.vsCMElementModule;                    i++)                {                    vsCMElement eTmp = (vsCMElement)i;                    ce = ep.get_CodeElement(eTmp);                    if (null != ce)                    {                        break;                    }                }            }            ep.StartOfLine();            return ce;        }        public void Navigate2File(string path, int line, string txt)        {            _applicationObject.ItemOperations.OpenFile(path, Constants.vsViewKindTextView);            TextSelection ts = (TextSelection)_applicationObject.ActiveDocument.Selection;            ts.MoveTo(line, 1, false);            ts.SelectLine();            string strTxt = ts.Text.Trim();            if (!string.IsNullOrEmpty(strTxt) && txt.IndexOf(strTxt) >= 0)            {                return;            }            string[] lst = SplitTaskText(txt);            if (lst == null)            {                return;            }            string filetype = "*" + path.Substring(path.LastIndexOf("."));            strTxt = lst[1];            TextDocument objTD = (TextDocument)_applicationObject.ActiveDocument.Object("TextDocument");            EditPoint objEditPt = objTD.StartPoint.CreateEditPoint();            int opt = (int)(vsFindOptions.vsFindOptionsFromStart | vsFindOptions.vsFindOptionsKeepModifiedDocumentsOpen);            EditPoint EndPoint = null;            bool a = objEditPt.FindPattern(strTxt, opt, ref EndPoint);            if (EndPoint != null)            {                ts.MoveTo(EndPoint.Line, 1, false);                ts.SelectLine();            }        }

 

转载于:https://my.oschina.net/fdayok/blog/884926

你可能感兴趣的文章
十进制转化为2/8/16
查看>>
iOS开发经验
查看>>
作业(十)
查看>>
内存拷贝
查看>>
matlab练习程序(二维直方图)
查看>>
解决Visual Studio调试突然变慢卡死的问题
查看>>
关于tableView中的细节
查看>>
[转载] FFMpeg的码率控制
查看>>
js创建函数的方式
查看>>
C++ 获取时间
查看>>
hdu 2795 - Billboard
查看>>
viewpage广告条的制作
查看>>
leetcode 1 两数之和
查看>>
RAM、ROM的概念与区别,Cache
查看>>
学点经济学知识(一)
查看>>
linux下安装软件
查看>>
关于SQL优化方面的一些总结
查看>>
JavaScript-字符串的使用
查看>>
网络通信框架Volley使用详细说明
查看>>
centos 安装 rtmp nginx 视频流服务器
查看>>