private void CreateCommand(CommandBar commandBar, string name, string text, string tooltip)
{
var commands = (Commands2)_application.Commands;
Command command;
try
{
var contextGUIDS = new object[] { };
command = commands.AddNamedCommand2(
_addIn, name, text, tooltip, true, null, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
}
catch (ArgumentException)
{
command = commands.Item(_addIn.ProgID + "." + name, 0);
}
if (command != null)
{
command.AddControl(commandBar, commandBar.Controls.Count + 1);
}
}