/// <summary> /// /// </summary> /// <param name="commandBar">Which bar to add method to</param> /// <param name="buttonStyle">The type of button to put on the bar</param> /// <remarks></remarks> public AddInInfo(ref CommandBar commandBar, ref MsoButtonStyle buttonStyle) { base.Name = _NAME; base.CommandBar = commandBar; base.EventHandler = Action; base.ButtonStyle = buttonStyle; base.BitMapName = _BITMAP_NAME; base.Asmbly = Assembly.GetExecutingAssembly(); base.Caption = _CAPTION; base.ToolTipText = _TOOL_TIP_TEXT; base.Description = _DESCRIPTION; base.Initialize(); }
/// <summary> /// Adds an command button to Visual Studio for the give command. /// </summary> /// <param name="command"></param> /// <param name="cmdBar"></param> /// <param name="buttonStyle"></param> /// <returns></returns> private CommandBarButton AddCommandToCmdBar(Command command, CommandBar cmdBar, MsoButtonStyle buttonStyle) { CommandBarButton tempCmdBarButton; tempCmdBarButton = (CommandBarButton)command.AddControl(cmdBar, cmdBar.Controls.Count + 1); tempCmdBarButton.BeginGroup = true; tempCmdBarButton.Style = buttonStyle; return tempCmdBarButton; }
private void AddToolBarButton(ref CommandBarButton CommandBarButton, MsoButtonStyle Style, string Caption, string ToolTip, string ImagePath, string MaskImagePath) { try { Assembly ThisAssembly = Assembly.GetExecutingAssembly(); CommandBarButton = (CommandBarButton)omToolbar.Controls.Add(MsoControlType.msoControlButton, 1, "", Type.Missing, true); CommandBarButton.Caption = Caption; CommandBarButton.TooltipText = ToolTip; CommandBarButton.Style = Style; CommandBarButton.Visible = true; Helper.SetPicture(ThisAssembly, CommandBarButton, ImagePath, MaskImagePath); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
public void AddCommandToCommandBar(CommandBar commandBar, string commandName, int insertIndex = 1, bool beginGroup = false, MsoButtonStyle style = MsoButtonStyle.msoButtonIconAndCaption) { ICommand command = GetCommand(commandName); if (null == command) { return; } CommandBarControl existingControl = FindCommandBarControlByCaption(commandBar, command.Caption); CommandBarButton commandBarButton; if (null != existingControl) { commandBarButton = (CommandBarButton)existingControl; } else { commandBarButton = (CommandBarButton)command.VSCommand.AddControl(commandBar, insertIndex); } commandBarButton.BeginGroup = beginGroup; commandBarButton.Style = style; }