我创建了一个 Visual Studio 插件,但是当我一次又一次地打开 Visual Studio 时它会自行添加。现在我的视觉工作室中有 20 个菜单 :)
我如何检查它是否已经添加?
我在 Connect.cs [OnStartupComplete 方法] 上使用以下代码
我观看了有关添加 rigth 菜单的视频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());
}