public void EnumerateMenuControls(DTE_Output InOutput) { CommandBarControls controls = mBar.Controls; foreach (CommandBarControl control in controls) { Microsoft.VisualStudio.CommandBars.MsoControlType msoType = control.Type; InOutput.WriteLine( "Control Caption: " + control.Caption + " type: " + msoType.ToString() + " Enabled: " + control.Enabled.ToString()); InOutput.WriteLine(" DescriptionText: " + control.DescriptionText); InOutput.WriteLine(" TooltipText: " + control.TooltipText); InOutput.WriteLine( " Index: " + control.Index.ToString() + " Id: " + control.Id.ToString()); Command cmd = mMain.Commandsx.Item(control.Id, -1); string cmdName = cmd.Name; if (control.Type == MsoControlType.msoControlButton) { CommandBarButton but = (CommandBarButton)control; DTE_Button dbut = new DTE_Button(mMain, control); InOutput.WriteLine(" " + dbut.Command.Name + " guid: " + dbut.CommandGuid + " LocalizedName:" + dbut.Command.command.LocalizedName); DTE_Addin addin = mMain.FindAddinByGuid(dbut.CommandGuid); if (addin != null) { InOutput.WriteLine(" addin progid:" + addin.ProgId); } } } }
public DTE_Command AddCommand( EnvDTE.AddIn InInstance, DTE_Addin InAddin, DTE_Command.ConstructProperties InProps) { object[] contextGuids = InProps.ContextGuids; //Add a command to the Commands collection: EnvDTE.Command command = mCmds.AddNamedCommand( InAddin.addin, InProps.Name, InProps.ButtonText, InProps.TooltipText, InProps.IsMsoButton, InProps.BitmapIx, ref contextGuids, InProps.Useable); InProps.ContextGuids = contextGuids; DTE_Command cmd = new DTE_Command(mMain, command); return(cmd); }