protected void AddMenu(ref Office.CommandBarButton btn, Office.CommandBarPopup popup, string strCaption, string strTooltip, Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler handler) { btn = (Office.CommandBarButton)popup.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); AddMenu(btn, strCaption, strTooltip, handler); }
private void AddMenuBar() { try { menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, missing, false); if (newMenuBar != null) { newMenuBar.Caption = "AutoTask"; newMenuBar.Tag = menuTag; buttonOne = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, true); buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonOne.Caption = "AutoTask"; buttonOne.FaceId = 65; buttonOne.Tag = "AutoTask"; buttonOne.Picture = getImage(); newMenuBar.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AddMenuBar() { try { menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (newMenuBar != null) { buttonOne = (Office.CommandBarButton) newMenuBar.Controls. Add(Office.MsoControlType.msoControlButton, System. Type.Missing, System.Type.Missing, 1, true); newMenuBar.Caption = "Highlight"; buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonOne.Caption = "Highlight elad"; buttonOne.FaceId = 100; buttonOne.Tag = "c123"; buttonOne.Picture = getImage(); buttonOne.Click += ButtonOne_Click; newMenuBar.Visible = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public void cellmenu() { try { Globals.ThisAddIn.Application.CommandBars["Cell"].Controls["转成大小写"].Delete(); } catch {} finally { cell_meau = (Office.CommandBarPopup)Globals.ThisAddIn.Application.CommandBars["Cell"].Controls.Add(Type: Office.MsoControlType.msoControlPopup, Before: 1); cell_meau.Caption = "转成大小写"; cell_meau_btn_upper = (Office.CommandBarButton)cell_meau.Controls.Add(Type: Office.MsoControlType.msoControlButton); cell_meau_btn_upper.Caption = "转成大写"; cell_meau_btn_upper.FaceId = 80; //cell_meau_btn_upper.Click += cell_meau_btn_upper_Click; cell_meau_btn_upper.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cell_meau_btn_upper_Click); cell_meau_btn_lower = (Office.CommandBarButton)cell_meau.Controls.Add(Type: Office.MsoControlType.msoControlButton); cell_meau_btn_lower.Caption = "转成小写"; cell_meau_btn_lower.FaceId = 81; cell_meau_btn_lower.Click += Cell_meau_btn_lower_Click; cell_meau_btn_trim = (Office.CommandBarButton)cell_meau.Controls.Add(Type: Office.MsoControlType.msoControlButton); cell_meau_btn_trim.Caption = "去除空格"; cell_meau_btn_trim.FaceId = 82; cell_meau_btn_trim.Click += Cell_meau_btn_trim_Click; } }
private void AddMenuBar() { try { menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (newMenuBar != null) { newMenuBar.Caption = "New Menu"; buttonOne = (Office.CommandBarButton)newMenuBar.Controls. Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); buttonOne.Style = Office.MsoButtonStyle. msoButtonIconAndCaption; buttonOne.Caption = "Button One"; buttonOne.FaceId = 65; buttonOne.Tag = "c123"; //buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(buttonOne_Click); newMenuBar.Visible = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
// Create the menu, if it does not exist. private void AddMenuBar() { try { Office.CommandBarPopup cmdBarControl = null; Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar; int controlCount = menubar.Controls.Count; string menuCaption = "&New Menu"; // Add the menu. cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add( Office.MsoControlType.msoControlPopup, controlCount, true); if (cmdBarControl != null) { cmdBarControl.Caption = menuCaption; cmdBarControl.Tag = menuTag; // Add the menu command. menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add( Office.MsoControlType.msoControlButton, true); menuCommand.Caption = "&New Menu Command"; menuCommand.Tag = "NewMenuCommand"; menuCommand.FaceId = 65; menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler( menuCommand_Click); } } catch (Exception e) { MessageBox.Show(e.Message); } }
// Create the menu, if it does not exist. private void AddMenuBar(Application appli) { Office.CommandBarPopup cmdBarControl = null; Office.CommandBar menubar = (Office.CommandBar)appli.CommandBars.ActiveMenuBar; int controlCount = menubar.Controls.Count; string menuCaption = MENU_CAPTION; // Add the menu. cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, controlCount, missing); if (cmdBarControl != null) { cmdBarControl.Caption = menuCaption; cmdBarControl.Tag = MENU_ID; // Add the menu's commands. AddMenuCommand(cmdBarControl, ref menuCommand00, MENU_ITEM0_ID, MENU_ITEM0_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand0_Click), MENU_ITEM0_FACEID); AddMenuCommand(cmdBarControl, ref menuCommand03, MENU_ITEM3_ID, MENU_ITEM3_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand3_Click), MENU_ITEM3_FACEID); AddMenuCommand(cmdBarControl, ref menuCommand04, MENU_ITEM4_ID, MENU_ITEM4_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand4_Click), MENU_ITEM4_FACEID); //AddMenuCommand(cmdBarControl, ref menuCommand05, MENU_ITEM5_ID, MENU_ITEM5_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand5_Click), MENU_ITEM5_FACEID); //AddMenuCommand(cmdBarControl, ref menuCommand06, MENU_ITEM6_ID, MENU_ITEM6_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand6_Click), MENU_ITEM6_FACEID); //AddMenuCommand(cmdBarControl, ref menuCommand07, MENU_ITEM7_ID, MENU_ITEM7_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand7_Click), MENU_ITEM7_FACEID); //AddMenuCommand(cmdBarControl, ref menuCommand08, MENU_ITEM8_ID, MENU_ITEM8_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand8_Click), MENU_ITEM8_FACEID); AddMenuCommand(cmdBarControl, ref menuCommand20, MENU_ITEM20_ID, MENU_ITEM20_CAPTION, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menuCommand20_Click), MENU_ITEM20_FACEID); } }
// 如果菜单不存在则创建它. private void AddMenuBar() { try { Office.CommandBarPopup cmdBarControl = null; Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar; int controlCount = menubar.Controls.Count; string menuCaption = "案例处理(&P)"; // Add the menu. cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, controlCount, true); cmdBarControl.Tag = menuTag; if (cmdBarControl != null) { cmdBarControl.Caption = menuCaption; clearCaseAddressCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); clearCaseAddressCommand.Caption = "自动清理地址->楼盘(&S)"; clearCaseAddressCommand.Tag = "importCaseCommand"; clearCaseAddressCommand.FaceId = 0162; clearCaseAddressCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(clearCaseAddressCommand_Click); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public void AddMenu(string[] words) { bool addmenu = true; // If no synonyms don't show the menu addmenu &= words.Length >= 1; // A search that returns nothing will have one empty result addmenu &= !(words.Length == 1 && string.IsNullOrWhiteSpace(words[0])); foreach (var commandBar in textBars) { //RemovePopup(); popup = (Office.CommandBarPopup)commandBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, false); // the 1 here is where in context menu the popup will appear, apparently 1 is min value popup.accName = "Theasurus"; popup.Tag = "Theasurus"; popup.Visible = addmenu; foreach (string word in words) { if (string.IsNullOrWhiteSpace(word)) { continue; } string w = word.Trim(); var button = (Office.CommandBarButton)popup.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, popup.Controls.Count + 1, false); button.Caption = w; button.Tag = w; button.Visible = true; button.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_Click); menus.Add(button); } } }
public override void LoadMenu() { dao.Database aDb = (dao.Database)Application.CurrentDb(); if (aDb == null) { // Application.NewCurrentDatabase } else { base.LoadMenu(); try { SILConvertersPopup = (Office.CommandBarPopup)NewMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); SILConvertersPopup.Caption = "&SIL Converters"; AddMenu(ref ConvertFieldMenu, this.SILConvertersPopup, "&Convert a field in a table", "Click this item to convert a field in a table with a converter from the system repository", new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableFieldDialog_Click)); } catch (Exception ex) { DisplayException(ex); } } ReleaseComObject(aDb); }
private void AddMenuBar() { try { newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); if (newMenuBar != null) { newMenuBar.Caption = "Nuxeo"; newMenuBar.Tag = menuTag; buttonConfig = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, 1, true); buttonConfig.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonConfig.Caption = "Configuration"; buttonConfig.FaceId = 65; buttonConfig.Tag = "c123"; // buttonConfig.Picture = getImage(); newMenuBar.Visible = true; } } catch (Exception ex) { FormError bob = new FormError(ex.ToString(), "Erreur lors de l'ajout de la barre de menu." + System.Environment.NewLine + "Veuillez redémarrez le programme, réessayez ou contactez l'administrateur si le problème persiste."); bob.ShowDialog(); System.Diagnostics.Trace.TraceError("Problème Initialisation NuxeoDocList :" + ex); using (System.IO.StreamWriter file = new System.IO.StreamWriter(appDataFolterPath + "\\" + folderConfigName + @"\tmp\error.log", true)) { file.WriteLine(ex + "\n\t\n\t"); file.Close(); } } }
private void addMenuBar() { try { Office.CommandBarPopup cmdBarControl = null; Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar; int controlCount = menubar.Controls.Count; string menuCaption = "PI D&ata Edit"; // Add the menu. cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, controlCount, true); if (cmdBarControl != null) { cmdBarControl.Caption = menuCaption; // Add the menu command: Retrieve Data menuCommandGetPIData = (Office.CommandBarButton)cmdBarControl.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuCommandGetPIData.Caption = "&Retrieve PI Data"; menuCommandGetPIData.Tag = menuTags.GetPIData.ToString(); menuCommandGetPIData.FaceId = 23; menuCommandGetPIData.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler( menuCommand_Click); // Add the menu command: Update Data menuCommandUpdateData = (Office.CommandBarButton)cmdBarControl.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuCommandUpdateData.Caption = "&Update Data"; menuCommandUpdateData.Tag = menuTags.UpdateData.ToString(); menuCommandUpdateData.FaceId = 3; menuCommandUpdateData.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler( menuCommand_Click); // Add the menu command: About menuCommandAbout = (Office.CommandBarButton)cmdBarControl.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuCommandAbout.BeginGroup = true; menuCommandAbout.Caption = "&About PI Data Edit"; menuCommandAbout.Tag = menuTags.AboutPIDataEdit.ToString(); menuCommandAbout.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler( menuCommand_Click); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public static Office.CommandBarPopup AddSubMenu(Office.CommandBarPopup Menu, string Name) { Office.CommandBarPopup menu = null; //TODO: INSTANT C# TODO TASK: Instant C# could not resolve the named parameters in the following line: menu = (Office.CommandBarPopup)Menu.Controls.Add(Office.MsoControlType.msoControlPopup, Missing.Value, Missing.Value, Missing.Value, Missing.Value); menu.Caption = Name; return(menu); }
// If the menu already exists, remove it. private void CheckIfMenuBarExistsAndDelete(Application appli, string menuId) { Office.CommandBarPopup foundMenu = (Office.CommandBarPopup) appli.CommandBars.ActiveMenuBar.FindControl( Office.MsoControlType.msoControlPopup, System.Type.Missing, menuId, true, true); if (foundMenu != null) { foundMenu.Delete(true); } }
private void AddMenuCommand(Office.CommandBarPopup cmdBarControl, ref Office.CommandBarButton menuCommand, string cmdID, string cmdCAPTION, Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler clickHandler, int faceID) { menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, missing); //menuCommand = cmdBarControl.Controls.Add( // Office.MsoControlType.msoControlButton, missing, missing, missing, missing); menuCommand.Caption = cmdCAPTION; menuCommand.Tag = cmdID; menuCommand.FaceId = faceID; menuCommand.Click += clickHandler; }
private MOC.CommandBarButton add_menu_item(MOC.CommandBarPopup cmdbarpopup, string tag, string caption, System.Action handler) { tag = tagprefixmenuitem + tag; var btn = cmdbarpopup.AddNewMenuItem(tag, caption, (MOC.CommandBarButton Ctrl2, ref bool CancelDefault2) => wrap_handler(handler)); buttons.Add(btn); return(btn); }
public CustomMenu(Application appli) { // Suppression du menu personnalisé s'il existe CheckIfMenuBarExistsAndDelete(appli, MENU_ID); // Création du menu personnalisé AddMenuBar(appli); // Mémorisation de l'appli et du menu _appli = appli; _menu = (Office.CommandBarPopup) appli.CommandBars.ActiveMenuBar.FindControl( Office.MsoControlType.msoControlPopup, System.Type.Missing, MENU_ID, true, true); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { // Define the Old Menu Bar PacktOldMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; // Define the new Menu Bar into the existing menu bar PacktNewMenuBar = (Office.CommandBarPopup)PacktOldMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); //If PacktNewMenuBar not found then the code will add it if (PacktNewMenuBar != null) { // Set caption for the Menu PacktNewMenuBar.Caption = "Analyze PKCS#7 structure"; // Tag string value passing PacktNewMenuBar.Tag = strMenuString; // Assigning button type PacktButton1 = (Office.CommandBarButton)PacktNewMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); // Setting up the button style PacktButton1.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow; // Set button caption PacktButton1.Caption = "Analyze PKCS#7 structure"; // Set the menu visible PacktNewMenuBar.Visible = true; } // Verify the PacktCustomToolBar exist and add to the application if (PacktCustomToolBar == null) { // Adding the commandbar to Active explorer Office.CommandBars PacktBars = this.Application.ActiveExplorer().CommandBars; // Adding PacktCustomToolBar to the commandbars PacktCustomToolBar = PacktBars.Add("NewPacktToolBar", Office.MsoBarPosition.msoBarTop, false, true); } // Adding button to the custom tool bar Office.CommandBarButton MyButton1 = (Office.CommandBarButton)PacktCustomToolBar.Controls.Add(1, missing, missing, missing, missing); // Set the button style MyButton1.Style = Office.MsoButtonStyle.msoButtonCaption; // Set the caption and tag string MyButton1.Caption = "Analyze PKCS#7 structure"; MyButton1.Tag = "Analyze PKCS#7 structure"; if (this.PacktButtonA == null) { // Adding the event handler for the button in the toolbar this.PacktButtonA = MyButton1; PacktButtonA.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick); } olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); olExplorer = olApp.ActiveExplorer(); // olExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event); }
public override void LoadMenu() { dao.Database aDb = (dao.Database)Application.CurrentDb(); if (aDb == null) { // Application.NewCurrentDatabase } else { base.LoadMenu(); try { SILConvertersPopup = (Office.CommandBarPopup)NewMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); SILConvertersPopup.Caption = "&SIL Converters"; #if !UseDialogBoxToGetTableField foreach (dao.TableDef aTable in aDb.TableDefs) { if (aTable.Attributes == 0) // don't want system tables { Office.CommandBarPopup aPopup = (Office.CommandBarPopup)SILConvertersPopup.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); aPopup.Caption = aTable.Name; List<Office.CommandBarButton> aListOfCommandButtons = new List<Microsoft.Office.Core.CommandBarButton>(); foreach (dao.Field aField in aTable.Fields) { Office.CommandBarButton aFieldButton = null; AddMenu(ref aFieldButton, aPopup, aField.Name, aTable.Name, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableField_Click)); aListOfCommandButtons.Add(aFieldButton); } m_listTablePopups.Add(aPopup, aListOfCommandButtons); } } #else AddMenu(ref ConvertFieldMenu, this.SILConvertersPopup, "&Convert a field in a table", "Click this item to convert a field in a table with a converter from the system repository", new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableFieldDialog_Click)); #endif } catch (Exception ex) { DisplayException(ex); } } ReleaseComObject(aDb); }
private void BuildMenu() { _menuBar = this.ActiveExplorer().CommandBars.ActiveMenuBar; _helpMenuIndex = _menuBar.Controls.Count; _topMenu = (Office.CommandBarPopup)(_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, _helpMenuIndex, true)); _topMenu.Caption = "Add-in Tasks"; _topMenu.Visible = true; _settingsMenu = (Office.CommandBarButton)(_topMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true)); _settingsMenu.Caption = "Growl Notification Settings..."; _settingsMenu.Visible = true; _settingsMenu.Enabled = true; _settingsMenu.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_settingsMenu_Click); }
public override void LoadMenu() { dao.Database aDb = (dao.Database)Application.CurrentDb(); if (aDb == null) { // Application.NewCurrentDatabase } else { base.LoadMenu(); try { SILConvertersPopup = (Office.CommandBarPopup)NewMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); SILConvertersPopup.Caption = "&SIL Converters"; #if !UseDialogBoxToGetTableField foreach (dao.TableDef aTable in aDb.TableDefs) { if (aTable.Attributes == 0) // don't want system tables { Office.CommandBarPopup aPopup = (Office.CommandBarPopup)SILConvertersPopup.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); aPopup.Caption = aTable.Name; List <Office.CommandBarButton> aListOfCommandButtons = new List <Microsoft.Office.Core.CommandBarButton>(); foreach (dao.Field aField in aTable.Fields) { Office.CommandBarButton aFieldButton = null; AddMenu(ref aFieldButton, aPopup, aField.Name, aTable.Name, new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableField_Click)); aListOfCommandButtons.Add(aFieldButton); } m_listTablePopups.Add(aPopup, aListOfCommandButtons); } } #else AddMenu(ref ConvertFieldMenu, this.SILConvertersPopup, "&Convert a field in a table", "Click this item to convert a field in a table with a converter from the system repository", new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableFieldDialog_Click)); #endif } catch (Exception ex) { DisplayException(ex); } } ReleaseComObject(aDb); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { CurrentVersion = Convert.ToInt32(Globals.ThisAddIn.Application.Version.Split('.')[0]); this.objExplorer = Globals.ThisAddIn.Application.ActiveExplorer(); SuiteCRMClient.clsSuiteCRMHelper.InstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SuiteCRMOutlookAddIn"; this.settings = new clsSettings(); if (this.settings.AutoArchive) { this.objExplorer.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail); this.objExplorer.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend); } if (CurrentVersion < 14) { this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay); var menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (objSuiteCRMMenuBar2007 != null) { objSuiteCRMMenuBar2007.Caption = "SuiteCRM"; this.btnArvive = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true); this.btnArvive.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; this.btnArvive.Caption = "Archive"; this.btnArvive.Picture = RibbonImageHelper.Convert(Resources.SuiteCRM1); this.btnArvive.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click); this.btnArvive.Visible = true; this.btnArvive.BeginGroup = true; this.btnArvive.TooltipText = "Archive selected emails to SuiteCRM"; this.btnArvive.Enabled = true; this.btnSettings = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true); this.btnSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; this.btnSettings.Caption = "Settings"; this.btnSettings.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click); this.btnSettings.Visible = true; this.btnSettings.BeginGroup = true; this.btnSettings.TooltipText = "SuiteCRM Settings"; this.btnSettings.Enabled = true; this.btnSettings.Picture = RibbonImageHelper.Convert(Resources.Settings); objSuiteCRMMenuBar2007.Visible = true; } } else { //For Outlook version 2010 and greater //var app = this.Application; //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay); } SuiteCRMAuthenticate(); }
/// <summary> /// Add menu bar plugin /// </summary> private void AddMenuBar() { try { //Define the existent Menu Bar menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; //Define the new Menu Bar into the old menu bar newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, missing, false); //If I dont find the newMenuBar, I add it if (newMenuBar != null) { newMenuBar.Caption = "AntySpam"; newMenuBar.Tag = menuTag; //about buttonOneAbout = (Office.CommandBarButton)newMenuBar.Controls. Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); buttonOneAbout.Style = Office.MsoButtonStyle.msoButtonCaption; buttonOneAbout.Caption = "About plugin"; buttonOneAbout.FaceId = 611; buttonOneAbout.Tag = "c124"; buttonOneAbout.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(buttonOneAbout_Click); //setting buttonOne = (Office.CommandBarButton)newMenuBar.Controls. Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); buttonOne.Style = Office.MsoButtonStyle. msoButtonIconAndCaption; buttonOne.Caption = "AntySpam Settings"; //This is the Icon near the Text buttonOne.FaceId = 610; buttonOne.Tag = "c123"; //Insert Here the Button1.Click event buttonOne.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(buttonOne_Click); newMenuBar.Visible = true; } } catch (Exception ex) { SaveToLog("Error adding menu plugin bar:\n\r" + ex.Message, pathToErrorLog); } }
private void AddMenuItem(Office.CommandBar imenu) { try { Application.ScreenUpdating = true; //Application.rev if (imenu == null) { _oCommand = Application.CommandBars.Add("TVC-QD", Office.MsoBarPosition.msoBarTop, Type.Missing, Type.Missing); //_oCommand.Name = "TVC-QD"; _oCommand.Visible = true; } else { _oCommand = imenu; } _oPop = (Office.CommandBarPopup)_oCommand.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); _oPop.Caption = "TVC-QD"; _oPop.Enabled = true; _oBtn = (Office.CommandBarButton)_oPop.CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, true); _oBtn.DescriptionText = _oBtn.Caption = "Balance"; _oBtn.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_oBtn_Click); _oBtn.Picture = PictureDispConverter.ToIPictureDisp(Properties.Resources.blance); _oBtnComment = (Office.CommandBarButton)_oPop.CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, true); _oBtnComment.Caption = "Comment"; _oBtnComment.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_oBtnComment_Click); _oBtnComment.Picture = PictureDispConverter.ToIPictureDisp(Properties.Resources.comment); _oBtnAnalysis = (Office.CommandBarButton)_oPop.CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, true); _oBtnAnalysis.Caption = "Analysis"; _oBtnAnalysis.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_oBtnAnalysis_Click); _oBtnAnalysis.Picture = PictureDispConverter.ToIPictureDisp(Properties.Resources.analysis); _oBtnConnect = (Office.CommandBarButton)_oPop.CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, true); _oBtnConnect.Caption = "Connection"; _oBtnConnect.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(_oBtnConnect_Click); _oBtnConnect.Picture = PictureDispConverter.ToIPictureDisp(Properties.Resources.connect); } catch (Exception ex) { BUS.CommonControl.AddLog("ErroLog", __documentDirectory + "\\Log", "Addin : " + ex.Message + "\n\t" + ex.Source + "\n\t" + ex.StackTrace); } }
/// <summary> /// Prepare me for running. /// </summary> private void Prepare() { var outlookApp = this.Application; this.MaybeUpgradeSettings(); OutlookVersion = (OutlookMajorVersion)Convert.ToInt32(outlookApp.Version.Split('.')[0]); StartLogging(); synchronisationContext = new SyncContext(outlookApp); contactSynchroniser = new ContactSyncing("CS", synchronisationContext); taskSynchroniser = new TaskSyncing("TS", synchronisationContext); appointmentSynchroniser = new AppointmentSyncing("AS", synchronisationContext); EmailArchiver = new EmailArchiving("EM", synchronisationContext.Log); var outlookExplorer = outlookApp.ActiveExplorer(); this.objExplorer = outlookExplorer; outlookExplorer.FolderSwitch -= objExplorer_FolderSwitch; outlookExplorer.FolderSwitch += objExplorer_FolderSwitch; // TODO: install/remove these event handlers when settings.AutoArchive changes: outlookApp.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail); outlookApp.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend); ((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler(ThisAddIn_Quit); if (OutlookVersion < OutlookMajorVersion.Outlook2010) { outlookApp.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay); var menuBar = outlookExplorer.CommandBars.ActiveMenuBar; objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (objSuiteCRMMenuBar2007 != null) { ConstructOutlook2007MenuBar(); } } else { //For Outlook version 2010 and greater //var app = this.Application; //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay); } }
public void AddMenu(string[] words) { popup = (Office.CommandBarPopup)commandBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, false); popup.accName = "Theasurus"; popup.Tag = "Theasurus"; popup.Visible = true; foreach (string word in words) { string w = word.Trim(); button = (Office.CommandBarButton)popup.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, popup.Controls.Count + 1, false); button.Caption = w; button.Tag = w; button.Visible = true; button.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_Click); menus.Add(button); } }
private void CheckIfMenuBarExists() { try { Office.CommandBarPopup foundMenu = (Office.CommandBarPopup) this.Application.CommandBars.ActiveMenuBar.FindControl( Office.MsoControlType.msoControlPopup, System.Type.Missing, menuTag, true, true); if (foundMenu != null) { foundMenu.Delete(true); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Searches for already created XWord menu. /// </summary> /// <returns>TRUE if XWord menu is found.</returns> private bool FindXWordMenus() { bool found = false; foreach (CommandBarControl control in officeMenuBar.Controls) { if (control.Type == MsoControlType.msoControlPopup) { CommandBarPopup popup = (CommandBarPopup)control; if (popup.Caption.ToUpper().IndexOf("XWORD") >= 0) { xwordMenu = popup; found = true; break; } } } return(found); }
private void RemoveMenubar() { // If the menu already exists, remove it. try { Office.CommandBarPopup foundMenu = (Office.CommandBarPopup) this.Application.ActiveExplorer().CommandBars.ActiveMenuBar. FindControl(Office.MsoControlType.msoControlPopup, missing, menuTag, true, true); if (foundMenu != null) { foundMenu.Delete(true); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public void InitializelMenu() { // Reset before initializing ResetMenu(); //================================= // Sample Popup Menu Office.CommandBarPopup popupMenu = (Office.CommandBarPopup)_contextMenu.Controls .Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true); popupMenu.Caption = "Sample Popup Menu"; Office.CommandBarButton printTextEffectsMenuItem = (Office.CommandBarButton)popupMenu.Controls .Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); printTextEffectsMenuItem.Caption = "Print All Text Effects"; printTextEffectsMenuItem.FaceId = 0609; printTextEffectsMenuItem.Click += PrintTextEffectsMenuItem_Click; Office.CommandBarButton clearTextEffectsMenuItem = (Office.CommandBarButton)popupMenu.Controls .Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); clearTextEffectsMenuItem.Caption = "Clear Printed Text Effects"; clearTextEffectsMenuItem.FaceId = 0330; clearTextEffectsMenuItem.Click += ClearTextEffectsMenuItem_Click; //================================= // Sample Long Processing popup menu Office.CommandBarPopup longProcessingMenu = (Office.CommandBarPopup)_contextMenu.Controls .Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true); longProcessingMenu.Caption = "Sample Long Processing"; Office.CommandBarButton showLoadingFormMenuItem = (Office.CommandBarButton)longProcessingMenu.Controls .Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); showLoadingFormMenuItem.Caption = "With Loading Form"; showLoadingFormMenuItem.FaceId = 0302; showLoadingFormMenuItem.Click += ShowLoadingFormMenuItem_Click; Office.CommandBarButton showLoadingTextMenuItem = (Office.CommandBarButton)longProcessingMenu.Controls .Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); showLoadingTextMenuItem.Caption = "With Loading Text"; showLoadingTextMenuItem.FaceId = 0253; showLoadingTextMenuItem.Click += ShowLoadingTextMenuItem_Click;; }
/// <summary> /// Remove menu bar plugin /// </summary> private void RemoveMenubar() { // If the menu already exists, remove it. try { Office.CommandBarPopup foundMenu = (Office.CommandBarPopup) this.Application.ActiveExplorer().CommandBars.ActiveMenuBar. FindControl(Office.MsoControlType.msoControlPopup, missing, menuTag, true, true); if (foundMenu != null) { foundMenu.Delete(true); } } catch (Exception ex) { SaveToLog("Error remove menu bar plugin:\n\r" + ex.Message, pathToErrorLog); } }
public static Office.CommandBarPopup AddMenu(Office.CommandBar cbar, string menuName) { Office.CommandBarPopup menuItem = null; // Clear out any things we have previously added with the same name at this level. foreach (Office.CommandBarControl cbc in cbar.Controls) { if (cbc.Caption == menuName) { cbc.Delete(Missing.Value); } } // Now that things are tidy, create the new one. menuItem = (Office.CommandBarPopup)cbar.Controls.Add(Office.MsoControlType.msoControlPopup, Missing.Value, Missing.Value, Missing.Value, Missing.Value); menuItem.Caption = menuName; return(menuItem); }
public void AddMenu() { try { mainMenuBar = ((Office.CommandBars)this.Application.ActiveWindow.CommandBars).ActiveMenuBar; } catch (Exception e) { string message = e.Message; return; } if (vstoAddInMenu != null) { vstoAddInMenu.Visible = true; return; } try { helpMenuIndex = mainMenuBar.Controls["Help"].Index; } catch (Exception) { helpMenuIndex = mainMenuBar.Controls.Count; } vstoAddInMenu = (Office.CommandBarPopup)mainMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, helpMenuIndex, true); vstoAddInMenu.Caption = "CancerGrid"; vstoAddInMenu.Visible = true; queryFormMenuItem = (Office.CommandBarButton)vstoAddInMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, 1); queryFormMenuItem.Style = Office.MsoButtonStyle.msoButtonCaption; queryFormMenuItem.Caption = "Query Service Control"; queryFormMenuItem.Click += new Office._CommandBarButtonEvents_ClickEventHandler(queryFormMenuItem_Click); cdeFormMenuItem = (Office.CommandBarButton)vstoAddInMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, 1, 1); cdeFormMenuItem.Style = Office.MsoButtonStyle.msoButtonCaption; cdeFormMenuItem.Caption = "Create new Data Element"; cdeFormMenuItem.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cdeFormMenuItem_Click); //menuAdded = true; }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { vis_cmd_bars = this.Application.CommandBars as Office.CommandBars; vis_file_menu = vis_cmd_bars["Menu Bar"].Controls["&File"] as Office.CommandBarPopup; new_button = (Office.CommandBarButton) vis_file_menu.Controls.Add( Office.MsoControlType.msoControlButton, // Type this.missing, // Object this.missing, // Id 2, // Before true // Temporary ) ; new_button.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption; new_button.Caption = "My New Menu Item"; //new_button.Tag = "My New Menu Item"; new_button.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnOpen_Click); }
private void AddMenu() { // Define the existing Menu Bar Office.CommandBar menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; // Add the top level new Menu StaticHelper.LogMessage(MessageType.Info, "Adding Controlled Vocab menu"); Office.CommandBarPopup newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true); newMenuBar.Caption = "Controlled Vocab"; // get the buttons StaticHelper.LogMessage(MessageType.Info, "Getting buttons"); menu[] buttons = StaticHelper.GetControlledVocabularyMenus(); // build the buttons StaticHelper.LogMessage(MessageType.Info, "Building menu"); this.BuildMenu(newMenuBar, buttons); StaticHelper.LogMessage(MessageType.Info, "Making menu visible"); newMenuBar.Visible = true; }
public override void LoadMenu() { base.LoadMenu(); try { SILConvertersPopup = (Office.CommandBarPopup)NewMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); SILConvertersPopup.Caption = "&SIL Converters"; AddMenu(ref ConvertFieldMenu, this.SILConvertersPopup, "&Convert selection", "Click this item to convert the text in the selected cells with a converter from the system repository", new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(ConvertTableField_Click)); AddMenu(ref ProcessTableResetMenu, SILConvertersPopup, "&Reset", "Reset the list of found items and the unfinished conversion process", new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(Reset_Click)); } catch (Exception ex) { DisplayException(ex); } }
private void MyMenuBar() { this.ErsMyMenuBar(); try { //Define the existent Menu Bar _objMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; //Define the new Menu Bar into the old menu bar _objNewMenuBar = (Office.CommandBarPopup) _objMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup , missing , missing , missing , false); if (_objNewMenuBar != null) { _objNewMenuBar.Caption = "My Menu"; _objNewMenuBar.Tag = menuTag; _objButton = (Office.CommandBarButton)_objNewMenuBar.Controls. Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); _objButton.Style = Office.MsoButtonStyle. msoButtonIconAndCaption; _objButton.Caption = "My menu item."; //Icon _objButton.FaceId = 500; _objButton.Tag = "ItemTag"; //EventHandler _objButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(_objButton_Click); _objNewMenuBar.Visible = true; } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString(), "Error Message"); } }
void AddMenu() { string menuCaption = Properties.Resources.OrdersMenu; string weeklyCaption = Properties.Resources.WeeklyMenu; string unscheduledCaption = Properties.Resources.UnscheduledMenu; Office.CommandBar mainMenuBar = this.ThisApplication.CommandBars.ActiveMenuBar; Office.CommandBarPopup cmdBarControl = null; Office.CommandBarButton weeklyButton; Office.CommandBarButton unscheduledButton; // 命令栏由整个应用程序共享。 // 如果有两个工作簿运行此代码, // 第二个工作簿应先检查工具栏 // 是否已存在,这样,就不会将菜单 // 添加两次。 foreach (Office.CommandBarControl currentControl in mainMenuBar.Controls) { if (currentControl.Caption == menuCaption) { cmdBarControl = (Office.CommandBarPopup)currentControl; break; } } if (cmdBarControl == null) { cmdBarControl = (Office.CommandBarPopup)mainMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); cmdBarControl.Caption = menuCaption; cmdBarControl.Tag = menuCaption; } if (cmdBarControl.CommandBar.FindControl(missing, missing, weeklyCaption, missing, true) == null) { weeklyButton = (Office.CommandBarButton)cmdBarControl.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); weeklyButton.Caption = weeklyCaption; weeklyButton.Tag = weeklyCaption; } else { weeklyButton = (Office.CommandBarButton)cmdBarControl.Controls[weeklyCaption]; } if (cmdBarControl.CommandBar.FindControl(missing, missing, unscheduledCaption, missing, true) == null) { unscheduledButton = (Office.CommandBarButton)cmdBarControl.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); unscheduledButton.Caption = unscheduledCaption; unscheduledButton.Tag = unscheduledCaption; } else { unscheduledButton = (Office.CommandBarButton)cmdBarControl.Controls[unscheduledCaption]; } weeklyButton.Click += delegate { try { new OrderingSheet(false); } catch (Exception ex) { MessageBox.Show(ex.Message); } }; unscheduledButton.Click += delegate { try { new OrderingSheet(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } }; // 有必要将按钮赋给成员变量, // 这样,它们就不会被垃圾回收器“清除”。 this.weeklyMenuItem = (Office.CommandBarButton)weeklyButton; this.unscheduledMenuItem = (Office.CommandBarButton)unscheduledButton; this.menuBar = cmdBarControl; }
public void OnStartupComplete(ref System.Array custom) { /* * When outlook is opened it loads a Menu if Outlook plugin is installed. * OpenERP - > Push, Partner ,Documents, Configuration */ Microsoft.Office.Interop.Outlook.Application app = null; try { app = new Microsoft.Office.Interop.Outlook.Application(); object omissing = System.Reflection.Missing.Value; menuBar = app.ActiveExplorer().CommandBars.ActiveMenuBar; ConfigManager config = new ConfigManager(); config.LoadConfigurationSetting(); OpenERPOutlookPlugin openerp_outlook = Cache.OpenERPOutlookPlugin; OpenERPConnect openerp_connect = openerp_outlook.Connection; try { if (openerp_connect.URL != null && openerp_connect.DBName != null && openerp_connect.UserId != null && openerp_connect.pswrd != "") { string decodpwd = Tools.DecryptB64Pwd(openerp_connect.pswrd); openerp_connect.Login(openerp_connect.DBName, openerp_connect.UserId, decodpwd); } } catch(Exception ) { MessageBox.Show("Unable to connect remote Server ' " + openerp_connect.URL + " '.", "OpenERP Connection",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); } newMenuBar = (office.CommandBarPopup)menuBar.Controls.Add(office.MsoControlType.msoControlPopup, omissing, omissing, omissing, true); if (newMenuBar != null) { newMenuBar.Caption = "OpenERP"; newMenuBar.Tag = "My"; btn_open_partner = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 1, true); btn_open_partner.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_partner.Caption = "Contact"; //Face ID will use to show the ICON in the left side of the menu. btn_open_partner.FaceId = 3710; newMenuBar.Visible = true; btn_open_partner.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_partner_Click); btn_open_document = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 2, true); btn_open_document.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_document.Caption = "Documents"; //Face ID will use to show the ICON in the left side of the menu. btn_open_document.FaceId = 258; newMenuBar.Visible = true; btn_open_document.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_document_Click); btn_open_configuration_form = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 3, true); btn_open_configuration_form.Style = office.MsoButtonStyle.msoButtonIconAndCaption; btn_open_configuration_form.Caption = "Configuration"; //Face ID will use to show the ICON in the left side of the menu. btn_open_configuration_form.FaceId = 5644; newMenuBar.Visible = true; btn_open_configuration_form.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_configuration_form_Click); } } catch (Exception) { object oActiveExplorer; oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null); oCommandBars = (office.CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null); } }
public void OnConnection(object application, ext_ConnectMode ConnectMode, object AddInInst, ref System.Array custom) { vbe = ((VBIDE.VBE) application); // VBEのメニューにコマンドを登録 Office.CommandBar cmdBar = vbe.CommandBars[1]; cmdBarPopup = (Office.CommandBarPopup)cmdBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, Type.Missing); cmdBarPopup.Caption = "&Comment"; // コメントアウト コマンド Office.CommandBarButton cmdCommentOut; cmdCommentOut = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); cmdCommentOut.Caption = "&Comment Out"; cmdCommentOut.ShortcutText = "'"; cmdCommentOut.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdCommentOut_Click); cmdCommentOut.Visible = true; // Globalコメント コマンド Office.CommandBarButton cmdGlobalComment; cmdGlobalComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); cmdGlobalComment.Caption = "&Global Comment"; cmdGlobalComment.ShortcutText = "'***"; cmdGlobalComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdGlobalComment_Click); cmdGlobalComment.Visible = true; // Privateコメント コマンド Office.CommandBarButton cmdPrivateComment; cmdPrivateComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); cmdPrivateComment.Caption = "&Private Comment"; cmdPrivateComment.ShortcutText = "'---"; cmdPrivateComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdPrivateComment_Click); cmdPrivateComment.Visible = true; // 日付コメント コマンド Office.CommandBarButton cmdDateComment; cmdDateComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); cmdDateComment.Caption = "&Date Comment"; cmdDateComment.ShortcutText = "' yyyy/mm/dd"; cmdDateComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdDateComment_Click); cmdDateComment.Visible = true; }
private void AddMenu() { cb = Application.CommandBars["Cell"]; menu = (Office.CommandBarPopup)cb.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu.Caption = "Test Automation"; menu_alm = (Office.CommandBarPopup)menu.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu_alm.Caption = "Repository"; btnConnect = (Office.CommandBarButton)menu_alm.Controls.Add(1, missing, missing, missing, missing); btnConnect.TooltipText = "Connect"; btnConnect.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnConnect_Click); menu_process = (Office.CommandBarPopup)menu_alm.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu_process.Caption = "Process"; menu_chain = (Office.CommandBarPopup)menu_alm.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu_chain.Caption = "Chain"; menu_iban = (Office.CommandBarPopup)menu.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu_iban.Caption = "IBAN"; btnIban = (Office.CommandBarButton)menu_iban.Controls.Add(1, missing, missing, missing, missing); btnIban.TooltipText = "Convert ING"; btnIban.Caption = lblIban; btnIban.Click += btnIban_Click; btnNLBank = (Office.CommandBarButton)menu_iban.Controls.Add(1, missing, missing, missing, missing); btnNLBank.TooltipText = "Convert other NL Bank"; btnNLBank.Caption = lblBanks; btnNLBank.Click += btnNLBank_Click; if (Framework.Connected) { btnConnect.Caption = "Disconnect"; } else { btnConnect.Caption = "Connect to Repository"; } btnUploadProcess = (Office.CommandBarButton)menu_process.Controls.Add(1, missing, missing, missing, missing); btnUploadProcess.TooltipText = "Upload Workbook"; btnUploadProcess.Caption = "Upload Workbook"; btnUploadProcess.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnUploadProcess_Click); btnUpload = (Office.CommandBarButton)menu_process.Controls.Add(1, missing, missing, missing, missing); btnUpload.TooltipText = "Upload Testcases"; btnUpload.Caption = "Upload Testcase"; btnUpload.Click += btnUpload_Click; btnChainRead = (Office.CommandBarButton)menu_chain.Controls.Add(1, missing, missing, missing, missing); btnChainRead.Caption = "Read Basicflows / testcases"; btnChainRead.Click += btnChainRead_Click; btnChainUpload = (Office.CommandBarButton)menu_chain.Controls.Add(1, missing, missing, missing, missing); btnChainUpload.Caption = "Upload test set"; btnChainUpload.Click += btnChainUpload_Click; btnUploadConfig = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnUploadConfig.TooltipText = "Repository Manager"; btnUploadConfig.Caption = "Repository Manager"; btnUploadConfig.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnConfig_Click); /// btnCheck = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnCheck.TooltipText = "check a value of a screen object"; btnCheck.Caption = ACTION.CHECK.ToString().ToLower(); btnCheck.Click += button_Click; /// btnFill = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnFill.TooltipText = "fill a value in a screen object"; btnFill.Caption = ACTION.FILL.ToString().ToLower(); btnFill.Click += button_Click; /// btnText = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnText.TooltipText = "Check text on a screen"; btnText.Caption = ACTION.TEXT.ToString().ToLower(); btnText.Click += button_Click; /// btnClick = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnClick.TooltipText = "Click on a screen object"; btnClick.Caption = ACTION.CLICK.ToString().ToLower(); btnClick.Click += button_Click; }
/// <summary> /// Builds the <code>CommandBarPopup</code> and <code>CommandBarButton</code> elements /// from the XWord menu. /// </summary> private void BuildMenus() { bool menuExists = FindXWordMenus(); if (menuExists) { xwordMenu.Delete(false); } if (officeMenuBar != null) { xwordMenu = (Office.CommandBarPopup)officeMenuBar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, missing, true); xwordMenu.Caption = "&XWord"; xwordMenu.Tag = "XWord2003Menu"; xwordMenu.Enabled = true; menuItemNew = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemNew.Caption = "&New..."; menuItemNew.Tag = "MenuItemNewXWikiPage"; menuItemNew.Enabled = true; menuItemNew.FaceId = 18; menuItemOpenXWikiPage = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemOpenXWikiPage.Caption = "&Open XWiki Page"; menuItemOpenXWikiPage.Tag = "MenuItemOpenXWikiPage"; menuItemOpenXWikiPage.Enabled = false; menuItemOpenXWikiPage.FaceId = 23; menuItemPublishXWikiPage = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemPublishXWikiPage.Caption = "&Publish XWiki Page"; menuItemPublishXWikiPage.Tag = "MenuItemPublishXWikiPage"; menuItemPublishXWikiPage.Enabled = false; menuItemPublishXWikiPage.FaceId = 3823; menuItemViewInBrowser = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemViewInBrowser.Caption = "View in &Browser"; menuItemViewInBrowser.Tag = "MenuItemViewInBrowser"; menuItemViewInBrowser.Enabled = false; menuItemViewAttachments = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemViewAttachments.Caption = "&View Attachments"; menuItemViewAttachments.Tag = "MenuItemViewAttachments"; menuItemViewAttachments.Enabled = false; menuItemViewAttachments.BeginGroup = true; menuItemAddAttachments = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemAddAttachments.Caption = "Add A&ttachments"; menuItemAddAttachments.Tag = "MenuItemAddAttachments"; menuItemAddAttachments.Enabled = false; menuItemXWordSettings = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemXWordSettings.Caption = "XWord &Settings"; menuItemXWordSettings.Tag = "MenuItemXWordSettings"; menuItemXWordSettings.Enabled = true; menuItemXWordSettings.BeginGroup = true; menuItemAboutXWord = (Office.CommandBarButton)xwordMenu.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, true); menuItemAboutXWord.Caption = "&About XWord"; menuItemAboutXWord.Tag = "MenuItemAboutXWord"; menuItemAboutXWord.Enabled = true; menuItemAboutXWord.BeginGroup = true; } }
/// <summary> /// Searches for already created XWord menu. /// </summary> /// <returns>TRUE if XWord menu is found.</returns> private bool FindXWordMenus() { bool found = false; foreach (CommandBarControl control in officeMenuBar.Controls) { if (control.Type == MsoControlType.msoControlPopup) { CommandBarPopup popup = (CommandBarPopup)control; if (popup.Caption.ToUpper().IndexOf("XWORD") >= 0) { xwordMenu = popup; found = true; break; } } } return found; }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { CurrentVersion = Convert.ToInt32(Globals.ThisAddIn.Application.Version.Split('.')[0]); this.objExplorer = Globals.ThisAddIn.Application.ActiveExplorer(); SuiteCRMClient.clsSuiteCRMHelper.InstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SuiteCRMOutlookAddIn"; this.settings = new clsSettings(); if (this.settings.AutoArchive) { this.objExplorer.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail); this.objExplorer.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend); } if (CurrentVersion < 14) { this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay); var menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (objSuiteCRMMenuBar2007 != null) { objSuiteCRMMenuBar2007.Caption = "SuiteCRM"; this.btnArvive = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true); this.btnArvive.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; this.btnArvive.Caption = "Archive"; this.btnArvive.Picture = RibbonImageHelper.Convert(Resources.SuiteCRM1); this.btnArvive.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click); this.btnArvive.Visible = true; this.btnArvive.BeginGroup = true; this.btnArvive.TooltipText = "Archive selected emails to SuiteCRM"; this.btnArvive.Enabled = true; this.btnSettings = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true); this.btnSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; this.btnSettings.Caption = "Settings"; this.btnSettings.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click); this.btnSettings.Visible = true; this.btnSettings.BeginGroup = true; this.btnSettings.TooltipText = "SuiteCRM Settings"; this.btnSettings.Enabled = true; this.btnSettings.Picture = RibbonImageHelper.Convert(Resources.Settings); objSuiteCRMMenuBar2007.Visible = true; } } else { //For Outlook version 2010 and greater //var app = this.Application; //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay); } SuiteCRMAuthenticate(); }
/// <summary> /// 添加智真会议工具栏 /// </summary> private void AddMenuBar() { try { menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, 2, true); if (newMenuBar != null) { newMenuBar.Caption = GlobalResourceClass.getMsg("BTN_CREATE_TP_CONF"); newMenuBar.Tag = menuTag; btnSchedule = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); btnSchedule.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; btnSchedule.Caption = GlobalResourceClass.getMsg("BTN_CREATE_TP_CONF"); btnSchedule.FaceId = 65; btnSchedule.Picture = ConvertImage.getImage(Properties.Resources.favicon);//new stdole.IPictureDisp; btnSchedule.Tag = "TP001"; btnSchedule.Click += new _CommandBarButtonEvents_ClickEventHandler(TPEventHandlers.btnSchedule_Click); // btnConfSettings = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); btnConfSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; btnConfSettings.Caption = GlobalResourceClass.getMsg("BTN_CONF_SETTINGS"); btnConfSettings.FaceId = 66; btnConfSettings.Picture = ConvertImage.getImage(Properties.Resources.setting_meeting1); btnConfSettings.Tag = "TP002"; btnConfSettings.Click += new _CommandBarButtonEvents_ClickEventHandler(TPEventHandlers.btnConfSettings_Click); // btnSysSettings = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); btnSysSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; btnSysSettings.Caption = GlobalResourceClass.getMsg("BTN_SYSTEM_SETTINGS"); btnSysSettings.FaceId = 67; btnSysSettings.Picture = ConvertImage.getImage(Properties.Resources.setting_order1); btnSysSettings.Tag = "TP003"; btnSysSettings.Click += new _CommandBarButtonEvents_ClickEventHandler(TPEventHandlers.btnSysSettings_Click); // btnHelp = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); btnHelp.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; btnHelp.Caption = GlobalResourceClass.getMsg("BTN_HELP"); btnHelp.FaceId = 68; btnHelp.Picture = ConvertImage.getImage(Properties.Resources.QuestionMark1); btnHelp.Tag = "TP004"; btnHelp.Click += new _CommandBarButtonEvents_ClickEventHandler(TPEventHandlers.btnHelp_Click); // btnAbout = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); btnAbout.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; btnAbout.Caption = GlobalResourceClass.getMsg("BTN_ABOUT"); btnAbout.FaceId = 69; btnAbout.Picture = ConvertImage.getImage(Properties.Resources.about1); btnAbout.Tag = "TP005"; btnAbout.Click += new _CommandBarButtonEvents_ClickEventHandler(TPEventHandlers.btnAbout_Click); newMenuBar.Visible = true; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void AddMenu() { cb = Application.CommandBars["Cell"]; RemoveMenu(); menu = (Office.CommandBarPopup)cb.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu.Caption = "QTP Framework"; menu_alm = (Office.CommandBarPopup)menu.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); menu_alm.Caption = "HP ALM"; btnConnect = (Office.CommandBarButton)menu_alm.Controls.Add(1, missing, missing, missing, missing); btnConnect.TooltipText = "Connect to " + Framework.Connection.Repository.ToString() + " repository."; btnConnect.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnConnect_Click); if (Framework.Ready) { btnConnect.Caption = "Disconnect"; btnUploadProcess = (Office.CommandBarButton)menu_alm.Controls.Add(1, missing, missing, missing, missing); btnUploadProcess.TooltipText = "Upload Workbook"; btnUploadProcess.Caption = "Upload Workbook"; btnUploadProcess.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnUploadProcess_Click); btnUpload = (Office.CommandBarButton)menu_alm.Controls.Add(1, missing, missing, missing, missing); btnUpload.TooltipText = "Upload Testcases"; btnUpload.Caption = "Upload Testcase"; btnUpload.Click += btnUpload_Click; btnUploadConfig = (Office.CommandBarButton)menu_alm.Controls.Add(1, missing, missing, missing, missing); btnUploadConfig.TooltipText = "Repository Manager"; btnUploadConfig.Caption = "Repository Manager"; btnUploadConfig.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnConfig_Click); //menu_config = (Office.CommandBarPopup)menu.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); //menu_config.Caption = "Configuration"; //btnExport = (Office.CommandBarButton)menu_config.Controls.Add(1, missing, missing, missing, missing); //btnExport.TooltipText = "Export Objects to QTP Framework Configuration"; //btnExport.Caption = "Upload Objects"; //btnExport.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnExport_Click); //btnManage = (Office.CommandBarButton)menu_config.Controls.Add(1, missing, missing, missing, missing); //btnManage.TooltipText = "Manage QTP Framework Configuration"; //btnManage.Caption = "Manage configuration"; //btnManage.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnManage_Click); } else { btnConnect.Caption = "Connect"; } /// btnCheck = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnCheck.TooltipText = "check a value of a screen object"; btnCheck.Caption = ACTION.CHECK.ToString(); btnCheck.Click += button_Click; /// btnFill = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnFill.TooltipText = "fill a value in a screen object"; btnFill.Caption = ACTION.FILL.ToString(); btnFill.Click += button_Click; /// btnText = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnText.TooltipText = "Check text on a screen"; btnText.Caption = ACTION.TEXT.ToString(); ; btnText.Click += button_Click; /// btnClick = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnClick.TooltipText = "Click on a screen object"; btnClick.Caption = ACTION.CLICK.ToString(); ; btnClick.Click += button_Click; /// btnScreen = (Office.CommandBarButton)menu.Controls.Add(1, missing, missing, missing, missing); btnScreen.TooltipText = "Screen"; btnScreen.Caption = "Screen"; btnScreen.Click += button_Click; }
public void AddMenuBar() { _menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; _newMenubar = (Office.CommandBarPopup)_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (_newMenubar != null) { _newMenubar.Caption = "Send Email to selection"; // Initialize button one _buttonOne = (Office.CommandBarButton)_newMenubar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); _buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; _buttonOne.Caption = "Email from template"; _buttonOne.Click += _buttonOne_Click; // Initialize button two _buttonTwo = (Office.CommandBarButton)_newMenubar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 2, true); _buttonTwo.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; _buttonTwo.Caption = "New email"; _buttonTwo.Click += _buttonTwo_Click; // menubar visible _newMenubar.Visible = true; } }