【发布时间】:2013-10-06 03:39:12
【问题描述】:
我创建了一个 Visual Studio 插件,但是当我一次又一次地打开 Visual Studio 时它会自行添加。现在我的视觉工作室中有 20 个菜单 :)
如何查看是否已添加?
我在 Connect.cs [OnStartupComplete 方法] 上使用以下代码
我看了这个关于添加右菜单http://msdn.microsoft.com/en-us/vstudio/bb614548.aspx的视频
Command command = null;
CommandBarControl commandBarControl;
CommandBar commandBarASPX, commandBarCS;
CommandBars commandBars;
try
{
try
{
command = _applicationObject.Commands.Item(_addInInstance.ProgID + "." + AddInName);
}
catch
{
}
if (command == null)
{
command = _applicationObject.Commands.AddNamedCommand(_addInInstance, AddInName, AddInButtonName, AddInButtonTooltip, true, 528, null, (int)vsCommandStatus.vsCommandStatusEnabled | (int)vsCommandStatus.vsCommandStatusSupported);
}
else
{
commandBars = _applicationObject.CommandBars as CommandBars;
commandBarASPX = commandBars["ASPX Context"];
commandBarControl = command.AddControl(commandBarASPX, commandBarASPX.Controls.Count + 1) as CommandBarControl;
commandBarCS = commandBars["Code Window"];
commandBarControl = command.AddControl(commandBarCS, commandBarCS.Controls.Count + 1) as CommandBarControl;
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message.ToString());
}
【问题讨论】:
标签: c# visual-studio-2010 visual-studio