为每一个软件行业的从业人员,无论是开发人员、项目经理、还是测试人员,也要不断适应这个趋势,我认为VS 2003插件只会使我们的工作更简单和更轻松。
虽然有许多人对VS 2003插件的安全性表示怀疑,但在年复一年的不断发展中,他的安全性也在不断提高。保障VS 2003插件的安全性是完全有可能的,但前提是要深入理解到底什么是VS 2003插件,及他是怎么运作的。 #t#
选择"新建"->"项目"->"其他项目"->"Visual Studio.Net外接程序"创建一个C#的外接项目。默认地,会生成一个Connet.cs文件,该文件就是当你的Visual Studio 启动时加载的东西:好了,那么具体应该怎么写代码呢,看几个代码片断吧:
- object[]contextGUIDS=newobject[]{};
- //获得VisualStudio的Commands
- Commandscommands=applicationObject.Commands;
- //获得VisualStudio的菜单
- _CommandBarscommandBars=applicationObject.CommandBars;
- try
- {
- //获得VisualStudio的"工具"菜单
- CommandBartoolsBar=(CommandBar)commandBars["Tools"];
- foreach(CommandBarControlcontrolintoolsBar.Controls)
- {
- //如果VSX菜单已经存在就直接返回
- if(control.Caption=="VSX")
- {
- return;
- }
- }
- //添加VSX菜单到工具栏下面
- CommandBarvsxBar=(CommandBar)commands.AddCommandBar("VSX",vsCommandBarType.vsCommandBarTypeMenu,toolsBar,1);
- //添加OutLook到VSX菜单下面
- Commandcommand=commands.AddNamedCommand(addInInstance,"OutLook","打开OutLook","在VS中嵌入OutLook",true,50,refcontextGUIDS,(int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled);
- command.AddControl(vsxBar,1);
- }
- catch(Exceptionex)
- {
- System.Windows.Forms.MessageBox.Show(ex.ToString());
- }
看看VS 2003插件注释就知道干了些什么。首先获取"工具"菜单,然后在"工具"上面加了个"VSX", ***在VSX上面加了个"OutLook". F5Debug一下,会弹出Visual Studio 2003,VS 2003插件看到工具下面的VSX没有?不过还没有任何功能。这里要注意的是:command.AddControl(VSxBar,1);就将command命令和vsxBar绑定在一起了。
转载请说明出处
知优网 » 对VS2003插件进行深度研究(vs2003使用方法)
知优网 » 对VS2003插件进行深度研究(vs2003使用方法)