Simply The Best.

.NET FrameWork C# VB.NET CodeDom

博客园 首页 新随笔 联系 订阅 管理

(1)在OnConnection中,判断connectMode时,一定要加上ext_cm_AfterStartup

   if(connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup
    || connectMode == Extensibility.ext_ConnectMode.ext_cm_Startup
    || connectMode == Extensibility.ext_ConnectMode.ext_cm_AfterStartup) // this line will work when u choose addin in addin manager
这样子,在vs的Addin Manager中选中插件时,插件才会重新显示出来,一般的范例中,只有前两个判断

(2)QueryState中,设置state时,要使用下面语句

    if( 是你加入的command )
    {
     if( 满足显示的条件 )
      status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported|vsCommandStatus.vsCommandStatusEnabled;
     else
      status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported;
    }
    else
     status = (vsCommandStatus)vsCommandStatus.vsCommandStatusUnsupported;
这样做,才能在条件不满足时,插件的菜单变灰

(3)判断代码窗口存在的方法是

(applicationObject.ActiveWindow != null) && (applicationObject.ActiveWindow.Type == vsWindowType.vsWindowTypeDocument)

就是说当前有活动窗口,而且其类型是文档类型

(4)在文档窗口插入字符的方法是

   TextSelection ts = (TextSelection)applicationObject.ActiveDocument.Selection;
   EditPoint ep = ts.ActivePoint.CreateEditPoint();
    
   ep.Insert(strCode);
当然,还可以调用EditPoint的其它方法,来实现删除,替换等等

posted on 2006-01-16 17:12  吹口琴的程序员  阅读(232)  评论(0编辑  收藏  举报