private Office.CommandBarButton CreateCommandBarButton( Office.CommandBar commandBar, string captionText, string tagText, string tipText, Office.MsoButtonStyle buttonStyle, System.Drawing.Bitmap picture, bool beginGroup, bool isVisible, object objBefore, Office._CommandBarButtonEvents_ClickEventHandler handler) { // Determine if button exists Office.CommandBarButton aButton = (Office.CommandBarButton) commandBar.FindControl(buttonStyle, null, tagText, null, null); if (aButton == null) { // Add new button aButton = (Office.CommandBarButton) commandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, tagText, objBefore, true); aButton.Caption = captionText; aButton.Tag = tagText; if (buttonStyle != Office.MsoButtonStyle.msoButtonCaption) { aButton.Picture = (IPictureDisp)AxHost2.GetIPictureDispFromPicture(picture); } aButton.Style = buttonStyle; aButton.TooltipText = tipText; aButton.BeginGroup = beginGroup; aButton.Click += handler; } aButton.Visible = isVisible; return aButton; }
/// <summary> /// MakeSubMenu /// </summary> /// <param name="o">The parent menu object</param> /// <param name="sm">The submenu caption</param> /// <param name="tag">The tag of the submenu created</param> /// <param name="e"></param> /// <returns>The newly created submenu</returns> private Office.CommandBarButton MkSMenu(Office.CommandBar o, string sm, string tag, Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler e) { Office.CommandBarButton f = (Office.CommandBarButton)(o.FindControl(Office.MsoControlType.msoControlButton, missing, tag, System.Type.Missing)); if (f != null) { f.Click -= e; f.Delete(); f = null; } f = (Office.CommandBarButton)(o.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true)); f.Tag = tag; f.accName = f.Caption = sm; #if test RemoveClickEvent(f); #endif f.Click += e; return f; }
private bool SubMenuExists(Office.CommandBar o, string tag) { Office.CommandBarButton f = (Office.CommandBarButton)o.FindControl(Office.MsoControlType.msoControlButton, missing, tag, System.Type.Missing); return (f != null); }
/// <summary> /// another Make menu overload made for convinience /// </summary> /// <param name="o"></param> /// <param name="s"></param> /// <param name="tag"></param> /// <returns></returns> private Office.CommandBarPopup MkMenu(Office.CommandBar o, string s, string tag) { Office.CommandBarPopup f = (Office.CommandBarPopup)o.FindControl(Office.MsoControlType.msoControlPopup, missing, tag, System.Type.Missing); if (f != null) DelPopup(f); f = (Office.CommandBarPopup)o.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, true); f.Tag = tag; f.accName = f.Caption = s; return f; }
private Office.CommandBarPopup MenuExists(Office.CommandBar o, string tag) { Office.CommandBarPopup f = (Office.CommandBarPopup)o.FindControl(Office.MsoControlType.msoControlPopup, System.Type.Missing, tag, System.Type.Missing); return f; }
private void DisplayMenuOption(Office.CommandBar commandBar, Outlook.MAPIFolder folder) { try { var READOUT_BUTTON_ID = "READOUT_BUTTON_ID"; if (commandBar.FindControl(Tag: READOUT_BUTTON_ID) != null) { #if DEBUG Util.AppLogger.WriteLine("Already exists"); #endif return; } //var btnInitReadOut = (Office.CommandBarButton)commandBar.Controls.Add(Type: Office.MsoControlType.msoControlButton); //btnInitReadOut.Tag = READOUT_BUTTON_ID; // btnInitReadOut.Caption = "Reinitiali&ze ReadOut Key Hook"; //btnInitReadOut.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnInitReadOut_Click); var btnReadOut = (Office.CommandBarButton)commandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing); btnReadOut.Tag = READOUT_BUTTON_ID; btnReadOut.Caption = "Read&Out"; btnReadOut.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnReadOut_Click); CurrentFolder = folder; if (folder.Items.Count <= 0) btnReadOut.Enabled = false; #if DEBUG var btnDump = (Office.CommandBarButton)commandBar.Controls.Add(Type: Office.MsoControlType.msoControlButton); btnDump.Caption = "Dump Key Hook"; btnDump.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler( (Office.CommandBarButton Ctrl, ref bool CancelDefault) => _panelManager.WriteState() ); #endif } catch (Exception ex) { ExceptionHandler.Catch(ex); } }