コード例 #1
0
        // 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 = "PrintEco";

                // 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.
                    menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommand.Caption = "PrintEcotize";
                    menuCommand.Tag = "PrintEcotize";
                    menuCommand.FaceId = 65;

                    menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
コード例 #2
0
ファイル: ThisAddIn.cs プロジェクト: huankiat/excalibur
        public void AddContextMenu()
        {
            Office.CommandBar cellbar = this.Application.CommandBars["Cell"];

            //subscribe button
            subButton = (Office.CommandBarButton)cellbar.Controls.Add();
            subButton.Caption = "Subscribe";
            subButton.BeginGroup = true;
            subButton.Tag = "subButton";
            subButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(showSubForm);

            //publish button
            pubButton = (Office.CommandBarButton)cellbar.Controls.Add();
            pubButton.Caption = "Publish";
            pubButton.Tag = "pubButton";
            pubButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(showPubForm);

            //rePublish button
            rePubButton = (Office.CommandBarButton)cellbar.Controls.Add();
            rePubButton.Caption = "RePublish";
            rePubButton.Tag = "rePubButton";
            rePubButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(showRePubForm);

            //refresh button
            refreshButton = (Office.CommandBarButton)cellbar.Controls.Add();
            refreshButton.Caption = "Refresh";
            refreshButton.Tag = "refreshButton";
            refreshButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(refreshAll);
        }
コード例 #3
0
ファイル: ThisAddIn.cs プロジェクト: tstanley93/ASSP-Outlook
 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);
     }
 }
コード例 #4
0
ファイル: ThisAddIn.cs プロジェクト: andhikanugraha/sigamal
        private void AddToEmail(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            Outlook.MailItem _ObjMailItem = (Outlook.MailItem)Inspector.CurrentItem;
            System.Diagnostics.Debug.WriteLine("Add to Mail");
            if (Inspector.CurrentItem is Outlook.MailItem)
            {
                System.Diagnostics.Debug.WriteLine("Add to Mail 1");
                bool IsExists = false;

                foreach (Office.CommandBar _ObjCmd in Inspector.CommandBars)
                {
                    if (_ObjCmd.Name == toolBarTagEmail)
                    {
                        IsExists = true;
                        _ObjCmd.Delete();
                    }
                }

                Office.CommandBar _ObjCommandBar = Inspector.CommandBars.Add(toolBarTagEmail, Office.MsoBarPosition.msoBarTop, false, true);
                siGamalBarButton = (Office.CommandBarButton)_ObjCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, missing, missing, true);

                if (!IsExists)
                {
                    System.Diagnostics.Debug.WriteLine("Add to Mail - 2");
                    siGamalBarButton.Caption = "SiGamal";
                    siGamalBarButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow;
                    siGamalBarButton.FaceId = 500;
                    siGamalBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(siGamalBarButton_Click);
                    _ObjCommandBar.Visible = true;
                    siGamalBarButton.Visible = true;

                }
            }
        }
コード例 #5
0
ファイル: ThisAddIn.cs プロジェクト: ytyukhnin/Mail2JIRA
        /// <summary>
        /// Adds a button on email window.
        /// </summary>
        /// <param name="Inspector">Microsoft.Office.Interop.Outlook.Inspector</param>
        private void AddButtonToEmailWindow(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            Outlook.MailItem objMailItem = (Outlook.MailItem)Inspector.CurrentItem;

            if (Inspector.CurrentItem is Outlook.MailItem)
            {
                objMailItem = (Outlook.MailItem)Inspector.CurrentItem;
                // Delete the existing instance, if applicable.
                foreach (Office.CommandBar objCmd in Inspector.CommandBars)
                {
                    if (objCmd.Name == TOOL_BAR_TAG_EMAIL)
                    {
                        objCmd.Delete();
                    }
                }

                Office.CommandBar objCommandBar = Inspector.CommandBars.Add(TOOL_BAR_TAG_EMAIL, Office.MsoBarPosition.msoBarBottom, false, true);
                objEmailToolBarButton = (Office.CommandBarButton)objCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, missing, missing, true);

                objEmailToolBarButton.Caption = "Create a JIRA ticket";
                objEmailToolBarButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow;
                objEmailToolBarButton.FaceId = 349; // button faceid code http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/
                objEmailToolBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(objEmailToolBarButton_Click);
                objCommandBar.Visible = true;
            }
        }
コード例 #6
0
ファイル: ThisAddIn.cs プロジェクト: sunilrao91/AutoTask
 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);
     }
 }
コード例 #7
0
ファイル: Connect.cs プロジェクト: jimbrannon/tlap_p2jm
 /// <summary>
 ///      Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
 ///      Receives notification that the host application is being unloaded.
 /// </summary>
 /// <param term='custom'>
 ///      Array of parameters that are host application specific.
 /// </param>
 /// <seealso class='IDTExtensibility2' />
 public void OnBeginShutdown(ref System.Array custom)
 {
     object omissing = System.Reflection.Missing.Value;
     _hydro2Button.Delete(omissing);
     _hydro2Button = null;
     //MessageBox.Show("Hydro Add-In is unloading.");
     //_customButton.Delete(omissing);
     //_customButton = null;
 }
コード例 #8
0
ファイル: ThisAddIn.cs プロジェクト: minikie/test
        private void DefineShortcutMenu()
        {

            Office.MsoControlType menuItem = Office.MsoControlType.msoControlButton;

            writeToText = (Office.CommandBarButton)Application.CommandBars["Cell"].
                Controls.Add(menuItem, missing, missing, 1, true);

            writeToText.Style = Office.MsoButtonStyle.msoButtonCaption;
            writeToText.Caption = "Write to a Text File";
            writeToText.Tag = "0";
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        private void AddToolbar()
        {
            if (_newToolBar == null)
            {
                var cmdBars =
                    Application.ActiveExplorer().CommandBars;
                _newToolBar = cmdBars.Add("Create Contacts",
                    Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                var createCapContacts =
                    (Office.CommandBarButton)_newToolBar.Controls
                    .Add(1, missing, missing, missing, missing);
                createCapContacts.Style = Office
                    .MsoButtonStyle.msoButtonIconAndCaption;
                createCapContacts.Caption = "Create capSpire Contacts";

                Image logo = Image.FromFile(
                        @"C:\Users\Craig\documents\visual studio 2013\Projects\ExecutiveAlert\ExecutiveAlert\Images\CapLogo.png");

                createCapContacts.Picture = PictureConverter.ImageToPictureDisp(logo);

                createCapContacts.Width = 130;
                createCapContacts.Height = 130;
                createCapContacts.Tag = "createContacts";
                if (_firstButton == null)
                {
                    _firstButton = createCapContacts;
                    _firstButton.Click += ButtonClick;
                }
                //Todo: second button idea
                var button2 = (Office.CommandBarButton)_newToolBar.Controls.Add(1);
                button2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                button2.Caption = "Button 2";
                button2.Tag = "Button2";
                _newToolBar.Visible = true;
                if (_secondButton == null)
                {
                    _secondButton = button2;
                    _secondButton.Click += ButtonClick;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #11
0
        public void MenuItem_ItemContextMenuDisplay(Microsoft.Office.Core.CommandBar CommandBar, Microsoft.Office.Interop.Outlook.Selection Selection)
        {
            try
            {

                // Commadbarpopup control to context menu item
                Office.CommandBarPopup CustomItem = (Office.CommandBarPopup)CommandBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, "Custom Menu Item", CommandBar.Controls.Count + 1, Type.Missing);
                // Added to separate group in context menu
                CustomItem.BeginGroup = true;
                // Set the tag value for the menu
                CustomItem.Tag = "CustomMenuItem";
                // Caption for the context menu item
                CustomItem.Caption = "Custom SLX Integration";
                // Set it to visible
                CustomItem.Visible = true;

                //Website with all the faceid's http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/
                cmdGotoContact = (Office.CommandBarButton)CustomItem.Controls.Add(1, missing, missing, missing, true);
                cmdGotoContact.Caption = "Goto Contact";
                cmdGotoContact.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdGotoContact_Click);
                cmdGotoContact.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                cmdGotoContact.FaceId = 2103;

                //Website with all the faceid's http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/
                cmdButton = (Office.CommandBarButton)CustomItem.Controls.Add(1, missing, missing, missing, true);
                cmdButton.Caption = "Create Opportunity / Ticket / Activity";
                cmdButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdButton_Click);
                cmdButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                cmdButton.FaceId = 0577;

                //Website with all the faceid's http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/
                cmdOpportunities = (Office.CommandBarButton)CustomItem.Controls.Add(1, missing, missing, missing, true);
                cmdOpportunities.Caption = "Opportunity List";
                cmdOpportunities.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdOpportunities_Click);
                cmdOpportunities.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                cmdOpportunities.FaceId = 0008;

                cmdSettings = (Office.CommandBarButton)CustomItem.Controls.Add(1, missing, missing, missing, true);
                cmdSettings.Caption = "Settings";
                cmdSettings.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdSettings_Click);
                cmdSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                cmdSettings.FaceId = 0212;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #12
0
        private void AddToolbar()
        {
            if (newToolBar == null)
            {
                Office.CommandBars cmdBars =
                    this.Application.ActiveExplorer().CommandBars;
                newToolBar = cmdBars.Add("NewToolBar",
                    Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                Office.CommandBarButton btnBanckleContacts =
                    (Office.CommandBarButton)newToolBar.Controls
                    .Add(1, missing, missing, missing, missing);
                btnBanckleContacts.Style = Office
                    .MsoButtonStyle.msoButtonCaption;
                btnBanckleContacts.Caption = "Banckle Contacts";
                btnBanckleContacts.Tag = "BanckleContacts";
                if (this.firstButton == null)
                {
                    this.firstButton = btnBanckleContacts;
                    firstButton.Click += new Office.
                        _CommandBarButtonEvents_ClickEventHandler
                        (ButtonClick);
                }

                Office.CommandBarButton OutlookContacts = (Office
                    .CommandBarButton)newToolBar.Controls.Add
                    (1, missing, missing, missing, missing);
                OutlookContacts.Style = Office
                    .MsoButtonStyle.msoButtonCaption;
                OutlookContacts.Caption = "Button 2";
                OutlookContacts.Tag = "Button2";
                newToolBar.Visible = true;
                if (this.secondButton == null)
                {
                    this.secondButton = OutlookContacts;
                    secondButton.Click += new Office.
                        _CommandBarButtonEvents_ClickEventHandler
                        (ButtonClick);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #13
0
        private void AddToolbar()
        {
            const string btnEnumHierarchy = "Enumerate Hierarchy";
            if (_newToolBar == null)
            {
                Office.CommandBars cmdBars =
                    this.Application.ActiveExplorer().CommandBars;
                _newToolBar = cmdBars.Add("Test Bar",
                    Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                Office.CommandBarButton button_1 =
                    (Office.CommandBarButton)_newToolBar.Controls
                    .Add(1, missing, missing, missing, missing);
                button_1.Style = Office
                    .MsoButtonStyle.msoButtonCaption;
                button_1.Caption = btnEnumHierarchy;
                button_1.Tag = btnEnumHierarchy;
                if (this._enumerateHiearchyButton == null)
                {
                    this._enumerateHiearchyButton = button_1;
                    _enumerateHiearchyButton.Click += new Office.
                        _CommandBarButtonEvents_ClickEventHandler
                        (EnumerateHierarchyClick);
                }

                Office.CommandBarButton button_2 = (Office
                    .CommandBarButton)_newToolBar.Controls.Add
                    (1, missing, missing, missing, missing);
                button_2.Style = Office
                    .MsoButtonStyle.msoButtonCaption;
                button_2.Caption = "Move folder";
                button_2.Tag = "Move folder";
                _newToolBar.Visible = true;
                if (this._moveButton == null)
                {
                    this._moveButton = button_2;
                    _moveButton.Click += _moveButton_Click;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #14
0
        public void AddUnmapButtonMenuCommand()
        {
            Office._CommandBarButtonEvents_ClickEventHandler xButtonHandler =
                new Office._CommandBarButtonEvents_ClickEventHandler(unmapXMLClick);

            Office._CommandBarButtonEvents_ClickEventHandler cButtonHandler =
                new Office._CommandBarButtonEvents_ClickEventHandler(unmapHeaderClick);

            XMLUnmapButton = (Office.CommandBarButton)Application.CommandBars["XML Range Popup"].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            XMLUnmapButton.Click += xButtonHandler;
            XMLUnmapButton.Caption = "Unmap Values";
            XMLUnmapButton.Visible = true;

            CellUnmapButton = (Office.CommandBarButton)Application.CommandBars["Cell"].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            CellUnmapButton.Click += cButtonHandler;
            CellUnmapButton.Caption = "Clear Cell";
            CellUnmapButton.Visible = true;
        }
コード例 #15
0
ファイル: ThisAddIn.cs プロジェクト: dunckr/word-thesaurus
        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);
            }
        }
コード例 #16
0
ファイル: ThisAddIn.cs プロジェクト: NCIP/cadsr-cgmdr
        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;
        }
コード例 #17
0
ファイル: ThisAddIn.cs プロジェクト: vnisor/email-notes
        void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
        {
            if (Selection.Count > 0)
            {
                mail = Selection[1] as Outlook.MailItem;
                if (mail != null)
                {
                    btnID = CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing) as Office.CommandBarButton;
                    btnID.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption;
                    btnID.Caption = "Copy Email ID";
                    btnID.FaceId = 224;
                    btnID.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btn_CopyEmailID);

                    btnNotes = CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing) as Office.CommandBarButton;
                    btnNotes.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption;
                    btnNotes.Caption = "Email Notes...";
                    btnNotes.FaceId = 1996;
                    btnNotes.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btn_EmailNotes);
                }
            }
        }
コード例 #18
0
        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);

        }
コード例 #19
0
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            ExcelProperties.Instance.Worksheet = new WorksheetInteropWrapper((Excel.Worksheet)Globals.ThisAddIn.Application.ActiveSheet);
              ExcelProperties.Instance.Selection = new Selection { ColumnCount = 1, RowCount = 1, StartColumn = 1, StartRow = 1 };

              _cellbar = Application.CommandBars["Cell"];
              _button = (Office.CommandBarButton)_cellbar.FindControl(Office.MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU", Missing.Value, Missing.Value);
              if (_button == null)
              {
            // add the button
            _button = (Office.CommandBarButton)_cellbar.Controls.Add(Office.MsoControlType.msoControlButton, Missing.Value, Missing.Value, _cellbar.Controls.Count, true);
            _button.Caption = "Quick Convert";
            _button.BeginGroup = true;
            _button.DescriptionText = "Uses the actual ExcelTableConverter settings to convert the excel table";
            _button.Picture = ConvertImage.GetIPictureDispImage(Properties.Resources.convert_icon_white_small);
            _button.Click += QuickConvertButton_Click;
              }

              //BaseTableConverter.CurrentConverter = BaseTableConverter.Converters.First().Value;

              Globals.ThisAddIn.Application.SheetSelectionChange += ApplicationOnSheetSelectionChange;
              Globals.ThisAddIn.Application.WorkbookActivate += ApplicationOnWorkbookActivate;
              Globals.ThisAddIn.Application.SheetActivate += ApplicationOnSheetActivate;
        }
コード例 #20
0
 private void AboutButton_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
 {
   Globals.OutlookGnuPG.About();
 }
コード例 #21
0
 private void btnSyncClick(Office.CommandBarButton ctrl, ref bool cancel)
 {
     //System.Windows.Forms.MessageBox.Show("Syncing with Outlook plz wait","Banckle Contacts");
     SyncContacts();
 }
コード例 #22
0
        private void btnSettingsClick(Office.CommandBarButton ctrl, ref bool cancel)
        {
            Settings settings = new Settings();

            settings.Show();
        }
コード例 #23
0
 public void DrawAllGraphs2Columns(Office.CommandBarButton cmdBarbutton, ref bool cancel)
 {
     DrawAllGraphs(2);
 }
コード例 #24
0
        void btnRules_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            int    rulecount    = 1;
            int    ruleindex    = 1;
            string RuleName     = Ctrl.Caption.Substring(10);//Load selected Rule Name from button caption
            bool   AlreadyThere = false;

            Outlook.MailItem citem = Application.ActiveExplorer().Selection[1];  //Load selected mail item

            Outlook.Rules MyRules = Application.Session.DefaultStore.GetRules(); //Retrieve Rules

            Outlook.Folder Folder = Application.ActiveExplorer().CurrentFolder   //Retrieve Folder
                                    as Outlook.Folder;
            string Email = citem.SenderEmailAddress;                             //Extract Selected Mail Item Email Address

            foreach (Outlook.Rule RL in MyRules)
            {
                if (RuleName == RL.Name)
                {
                    ruleindex = rulecount;//Assign indext to selected Rule
                }
                rulecount++;
            }

            foreach (Outlook.RuleCondition RC in MyRules[ruleindex].Conditions)
            {
                if (RC.Enabled)               //Add selected item parts to respective conditions if condition enabled
                {
                    switch (RC.ConditionType) //When I put this in as switch condition vs automatically added all the case statements below!
                    {
                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionAccount:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionAnyCategory:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionBody:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionBodyOrSubject:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionCategory:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionCc:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionDateRange:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionFlaggedForAction:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionFormName:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionFrom:

                        foreach (Outlook.Recipient ite in MyRules[ruleindex].Conditions.From.Recipients)
                        {
                            string rec  = ite.Address;
                            string name = ite.Name;
                            if (rec == item.SenderEmailAddress || name == item.SenderName)
                            {
                                AlreadyThere = true;
                            }
                        }


                        if (!AlreadyThere)
                        {
                            MyRules[ruleindex].Conditions.From.Recipients.Add(item.SenderEmailAddress);
                            MyRules[ruleindex].Conditions.From.Recipients.Add(item.SenderName);
                            MyRules[ruleindex].Conditions.From.Recipients.GetEnumerator();    //This here thingy keeps the new address and rule condition from returning void and hince being added multiple times and not executing when rule is run. Otherwise even though the new condition recipient shows up in the wizard, but has no effect when wizard is run.
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show(item.SenderEmailAddress + @" already in sender list!",
                                                                 "Error Adding To Rule", System.Windows.Forms.MessageBoxButtons.OK);
                        }

                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionFromAnyRssFeed:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionFromRssFeed:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionHasAttachment:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionImportance:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionLocalMachineOnly:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionMeetingInviteOrUpdate:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionMessageHeader:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionNotTo:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionOOF:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionOnlyToMe:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionOtherMachine:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionProperty:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionRecipientAddress:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSenderAddress:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSenderInAddressBook:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSensitivity:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSentTo:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSizeRange:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionSubject:
                        //Next to do#########################################
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionTo:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionToOrCc:
                        break;

                    case Microsoft.Office.Interop.Outlook.OlRuleConditionType.olConditionUnknown:
                        break;

                    default:
                        break;
                    }
                }
            }


            MyRules.Save(false);


            MyRules[ruleindex].Execute(true, Folder, Type.Missing, Type.Missing);
        }
コード例 #25
0
ファイル: ThisAddIn.cs プロジェクト: NCIP/cadsr-cgmdr
        public void AddUnmapButtonMenuCommand()
        {
            Office._CommandBarButtonEvents_ClickEventHandler xButtonHandler =
                new Office._CommandBarButtonEvents_ClickEventHandler(unmapXMLClick);

            Office._CommandBarButtonEvents_ClickEventHandler cButtonHandler =
                new Office._CommandBarButtonEvents_ClickEventHandler(unmapHeaderClick);

            Office._CommandBarButtonEvents_ClickEventHandler lButtonHandler =
                new Office._CommandBarButtonEvents_ClickEventHandler(unmapListClick);

            //Uncomment and Loop to find correct command dropdown menu.
            /*
            Office.CommandBars commandBars;

            commandBars = (Office.CommandBars)Application.CommandBars;

            foreach (Office.CommandBar commandBar in commandBars)
            {
                string name = commandBar.Name;
                string iName = commandBar.Name;
                try
                {
                    Office.CommandBarButton testButton = (Office.CommandBarButton)Application.CommandBars[commandBar.Name].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
                    testButton.Caption = commandBar.Name;
                    testButton.Visible = true;
                    //Uncomment when you want to clear the junk you just added.
                    Application.CommandBars[commandBar.Name].Reset();
                }
                catch (Exception e)
                { }
            }
            */

            ClearInListButton = (Office.CommandBarButton)Application.CommandBars["List Range Popup"].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            ClearInListButton.Click += lButtonHandler;
            ClearInListButton.Caption = "Remove Mapping";
            ClearInListButton.Visible = true;

            XMLUnmapButton = (Office.CommandBarButton)Application.CommandBars["XML Range Popup"].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            XMLUnmapButton.Click += xButtonHandler;
            XMLUnmapButton.Caption = "Unmap Values";
            XMLUnmapButton.Visible = true;

            CellUnmapButton = (Office.CommandBarButton)Application.CommandBars["Cell"].Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            CellUnmapButton.Click += cButtonHandler;
            CellUnmapButton.Caption = "Clear Cell";
            CellUnmapButton.Visible = true;
        }
コード例 #26
0
        private void btnAboutClick(Office.CommandBarButton ctrl, ref bool cancel)
        {
            About about = new About();

            about.Show();
        }
コード例 #27
0
 private void _myCommandBarPopup2Button_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
 {
     MessageBox.Show("Clicked " + Ctrl.Caption);
 }
コード例 #28
0
ファイル: CreateTask.cs プロジェクト: GianiWVL/VUYLSTEKE
        private void CreateTask_Startup(object sender, System.EventArgs e)
        {
            try
            {
                if (tisToolBar == null)
                {
                    tisToolBar = Application.ActiveExplorer().CommandBars.Add("TIS", Office.MsoBarPosition.msoBarTop, false, true);
                    // Add Button to Toolbar
                    tisCreateTaskToolBarButton = (Office.CommandBarButton)tisToolBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing,1, true);
                    tisCreateTaskToolBarButton.Caption = "Create Task";

                    tisCreateTaskToolBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(tisCreateTaskToolBarButton_Click);
                    tisToolBar.Visible = true;
                }

            }
            catch (System.Exception exception1)
            {
                System.Exception thisException = exception1;
                Management.ShowException(thisException);
            }
        }
コード例 #29
0
 private void buttonOne_Click(Office.CommandBarButton ctrl, ref bool cancel)
 {
     ProcessMessages();
 }
コード例 #30
0
 private void _myToolBarButton_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
 {
     //MessageBox.Show("Clicked " + Ctrl.Caption);
     LoadDVBFile(@"C:\Users\Aaron\Source\Repos\VBATesting\VBASourceControl.dvb", "SelectFormToConvert");
 }
コード例 #31
0
 private void MyButton_Click(Office.CommandBarButton ctrl, ref bool canceldefault)
 {
     Excel.Range selection = Globals.ThisAddIn.Application.Selection as Excel.Range;
     MessageBox.Show(GetWorksheet().Name + "!" + selection.AddressLocal);
 }
コード例 #32
0
 private void cbtnArchive_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
 {
     ShowArchiveForm();
 }
コード例 #33
0
 private void QuickConvertButton_Click(Office.CommandBarButton cmdBarbutton, ref bool cancel)
 {
     Clipboard.SetText(ConverterProvider.Instance.GetContent());
 }
コード例 #34
0
 private void SettingsButton_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
 {
   Globals.OutlookGnuPG.Settings();
 }
コード例 #35
0
 void addBtn_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
 {
     CommonFunction.DeleteQuotation(Globals.ThisAddIn.Application);
 }
コード例 #36
0
ファイル: ThisAddIn.cs プロジェクト: risavkarna/Sally
        /*
         * Adds the buttons and the Sally sub menu to the context menu
         */
        private void DefineShortcutMenu()
        {
            Office.MsoControlType menuItem = Office.MsoControlType.msoControlButton;

            cellbar = Application.CommandBars["Cell"];

            lookupButton = (Office.CommandBarButton)cellbar.FindControl(menuItem, 0, "AlexRightClickMenu", missing, missing);
            if (lookupButton == null)
            {
                // first time so add the button
                lookupButton = (Office.CommandBarButton)cellbar.Controls.Add(menuItem, missing, missing, 1, true);
                lookupButton.Caption = "Sally Frame";
                lookupButton.BeginGroup = true;
                lookupButton.Tag = "1";
                lookupButton.Visible = false;

            }

            //Office.MsoControlType sub = Office.MsoControlType.msoControlPopup;
            //subMenu = (Office.CommandBarPopup)cellbar.Controls.Add(sub, missing, missing, 2, true);
            //subMenu.Caption = "Sally Options";
            //subMenu.Tag = "2";
            //subMenu.Visible = false;

            //projectMode = (Office.CommandBarButton)subMenu.Controls.Add(menuItem, missing, missing, 1, true);
            //projectMode.Style = Office.MsoButtonStyle.msoButtonCaption;
            //projectMode.Caption = "Project Mode";
            //projectMode.Tag = "1";

            //saveMap = (Office.CommandBarButton)subMenu.Controls.Add(menuItem, missing, missing, 2, true);
            //saveMap.Style = Office.MsoButtonStyle.msoButtonCaption;
            //saveMap.Caption = "Save semantic map";
            //saveMap.Tag = "2";
        }
コード例 #37
0
ファイル: ThisAddIn.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>CreateParentMenu</c> member function
        /// Method to create Parent Menu ie At the Top 
        /// </summary>
        /// <param name="strParentMenuTag"></param>
        /// <param name="strCaption"></param>
        /// <returns></returns>
        private bool CreateParentMenu(string strParentMenuTag, string strCaption)
        {
            try
            {
                //Define the existent Menu Bar

                menuBarItopia = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;

                //Add new ITopia menu bar to active menubar
                menuBarSharePoint = (Office.CommandBarButton)menuBarItopia.Controls.Add(
                Office.MsoControlType.msoControlButton, missing, missing, missing, false);

                //If I dont find the newMenuBar, I add it
                if (menuBarSharePoint != null)
                {
                    //Add caption and tag
                    menuBarSharePoint.Caption = strCaption;
                    menuBarSharePoint.Tag = strParentMenuTag;

                    //Create SharePoint menu under ItopiaToola Menu
                    //menuBarConnectionProperties = (Office.CommandBarPopup)menuBarSharePoint.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, true);
                    //menuBarConnectionProperties.Caption = "Sharepoint";
                    //menuBarConnectionProperties.Tag = "SharePoint";

                    //Add button control to SharePoint popup menu
                    btnOptions = (Office.CommandBarButton)menuBarItopia.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    btnOptions.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnOptions.Caption = "Options";
                    btnOptions.FaceId = 630;
                    btnOptions.Tag = "Options";
                    btnOptions.Visible = true;
                    btnOptions.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnOptions_Click);

                    //Add button control to SharePoint popup menu
                    btnNewConnection = (Office.CommandBarButton)menuBarItopia.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    btnNewConnection.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnNewConnection.Caption = "New Connection";
                    btnNewConnection.FaceId = 611;

                    btnNewConnection.Tag = "New Connection";
                    btnNewConnection.Visible = true;
                    btnNewConnection.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnNewConnection_Click);

                    //Add button control to SharePoint popup menu
                    btnConnectionProperties = (Office.CommandBarButton)menuBarItopia.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    btnConnectionProperties.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnConnectionProperties.Caption = "Connection Properties";
                    btnConnectionProperties.FaceId = 610;
                    btnConnectionProperties.Tag = "Connection Properties";
                    btnConnectionProperties.Visible = true;
                    btnConnectionProperties.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnConnectionProperties_Click);

                    return true;

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

            return false;
        }
コード例 #38
0
        /// <summary>
        /// Adds commandBars to PowerPoint Application
        /// </summary>
        private void AddToolbar()
        {
            // VSTO API uses object-wrapped booleans
            object falseValue = false;
            object trueValue  = true;

            // Try to get a handle to an existing COMMANDBAR_NAME CommandBar
            try
            {
                m_CommandBar = Application.CommandBars[COMMANDBAR_NAME];

                // If we found the CommandBar, then it's a permanent one we need to delete
                // Note: if the user has manually created a toolbar called COMMANDBAR_NAME it will get torched here
                if (m_CommandBar != null)
                {
                    m_CommandBar.Delete();
                }
            }
            catch
            {
                // Benign - the CommandBar didn't exist
            }

            // Create a temporary CommandBar named COMMANDBAR_NAME
            m_CommandBar = Application.CommandBars.Add(COMMANDBAR_NAME, Office.MsoBarPosition.msoBarTop, falseValue, trueValue);

            if (m_CommandBar != null)
            {
                // Load any saved toolbar position
                LoadToolbarPosition();

                // Add our button to the command bar (as a temporary control) and an event handler.
                m_AlfrescoButton = (Office.CommandBarButton)m_CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, trueValue);
                if (m_AlfrescoButton != null)
                {
                    m_AlfrescoButton.Style           = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    m_AlfrescoButton.Caption         = COMMANDBAR_BUTTON_CAPTION;
                    m_AlfrescoButton.DescriptionText = COMMANDBAR_BUTTON_DESCRIPTION;
                    m_AlfrescoButton.TooltipText     = COMMANDBAR_BUTTON_DESCRIPTION;
                    Bitmap bmpButton = new Bitmap(GetType(), "toolbar.ico");
                    m_AlfrescoButton.Picture = new ToolbarPicture(bmpButton);
                    Bitmap bmpMask = new Bitmap(GetType(), "toolbar_mask.ico");
                    m_AlfrescoButton.Mask = new ToolbarPicture(bmpMask);
                    m_AlfrescoButton.Tag  = "AlfrescoButton";

                    // Finally add the event handler and make sure the button is visible
                    m_AlfrescoButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(m_AlfrescoButton_Click);
                }

                // Add the help button to the command bar (as a temporary control) and an event handler.
                m_HelpButton = (Office.CommandBarButton)m_CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, trueValue);
                if (m_HelpButton != null)
                {
                    m_HelpButton.Style           = Office.MsoButtonStyle.msoButtonIcon;
                    m_HelpButton.DescriptionText = COMMANDBAR_HELP_DESCRIPTION;
                    m_HelpButton.TooltipText     = COMMANDBAR_HELP_DESCRIPTION;
                    m_HelpButton.FaceId          = 984;
                    m_HelpButton.Tag             = "AlfrescoHelpButton";

                    // Finally add the event handler and make sure the button is visible
                    m_HelpButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(m_HelpButton_Click);
                }

                // We need to find this toolbar later, so protect it from user changes
                m_CommandBar.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize;
                m_CommandBar.Visible    = true;
            }
        }
コード例 #39
0
ファイル: Connect.cs プロジェクト: htom78/Xero
        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);
            }
        }
コード例 #40
0
        private void BuildMenu(Office.CommandBarPopup menuBar, IEnumerable <menu> buttons)
        {
            int customButtonPosition = 1;

            foreach (menu customButton in buttons)
            {
                Office.CommandBarPopup addInButton = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, this.missing, this.missing, customButtonPosition++, true);
                addInButton.Caption = customButton.label;
                for (int i = 0; i < customButton.Items.Length; i++)
                {
                    if (customButton.Items[i] is menu)
                    {
                        menu categoryMenu = (menu)customButton.Items[i];
                        Office.CommandBarPopup categoryButton = (Office.CommandBarPopup)addInButton.Controls.Add(Office.MsoControlType.msoControlPopup, this.missing, this.missing, i + 1, true);
                        categoryButton.Caption = categoryMenu.label;
                        categoryButton.Tag     = categoryMenu.id;

                        // the name of the menu is the name of the file
                        if (categoryMenu.Items.Length > 0)
                        {
                            for (int j = 0; j < categoryMenu.Items.Length; j++)
                            {
                                button actionMenu = (button)categoryMenu.Items[j];
                                Office.CommandBarButton actionButton = (Office.CommandBarButton)categoryButton.Controls.Add(Office.MsoControlType.msoControlButton, this.missing, this.missing, j + 1, true);
                                actionButton.Caption = actionMenu.label;
                                switch (actionMenu.onAction)
                                {
                                case "SendNormal":
                                    actionButton.Click += this.HandleMenuClickNormal;
                                    break;

                                case "SendHigh":
                                    actionButton.Click += this.HandleMenuClickHigh;
                                    break;

                                case "SendLow":
                                    actionButton.Click += this.HandleMenuClickLow;
                                    break;

                                case "Guidance":
                                    actionButton.Click += this.HandleMenuClickGuidance;
                                    break;
                                }

                                actionButton.Tag             = actionMenu.tag;
                                actionButton.DescriptionText = actionMenu.id;
                            }
                        }
                    }
                    else if (customButton.Items[i] is button)
                    {
                        button actionMenu = (button)customButton.Items[i];
                        Office.CommandBarButton actionButton = (Office.CommandBarButton)addInButton.Controls.Add(Office.MsoControlType.msoControlButton, this.missing, this.missing, i + 1, true);
                        actionButton.Caption = actionMenu.label;
                        switch (actionMenu.onAction)
                        {
                        case "SendNormal":
                            actionButton.Click += this.HandleMenuClickNormal;
                            break;

                        case "SendHigh":
                            actionButton.Click += this.HandleMenuClickHigh;
                            break;

                        case "SendLow":
                            actionButton.Click += this.HandleMenuClickLow;
                            break;

                        case "Guidance":
                            actionButton.Click += this.HandleMenuClickGuidance;
                            break;
                        }

                        actionButton.Tag             = actionMenu.tag;
                        actionButton.DescriptionText = actionMenu.id;
                    }
                    else if (customButton.Items[i] is menuSeparator)
                    {
                        menuSeparator           sep          = (menuSeparator)customButton.Items[i];
                        Office.CommandBarButton actionButton = (Office.CommandBarButton)addInButton.Controls.Add(Office.MsoControlType.msoControlButton, this.missing, this.missing, i + 1, true);
                        actionButton.BeginGroup = true;
                        actionButton.Caption    = sep.title;
                        if (string.IsNullOrEmpty(sep.title))
                        {
                            actionButton.Visible = false;
                        }

                        actionButton.Enabled = false;
                    }
                }
            }
        }
コード例 #41
0
ファイル: ThisAddIn.cs プロジェクト: s0lt4r/spamgrabber
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            _ReportSpam = ReportSpam;
            _ReportHam = ReportHam;
            _ReportSelected = ReportSelected;
            _SafeView = SafeView;
            _CopyToClipboard = CopyToClipboard;
            _Settings = Settings;

            Explorer _objExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
            //_cbSpamGrabber = _objExplorer.CommandBars.Add("SpamGrabber", Office.MsoBarPosition.msoBarTop, false, true);
            _cbSpamGrabber = _objExplorer.CommandBars["Standard"];

            _cbbDefaultSpam = CreateCommandBarButton(_cbSpamGrabber,
                "Report Spam", "Report to Default Spam profile", "Report to Default Spam profile",
                Office.MsoButtonStyle.msoButtonIcon, Properties.Resources.spamgrab_red,
                true, true, _cbSpamGrabber.Controls.Count, _ReportSpam);

            _cbbDefaultHam = CreateCommandBarButton(_cbSpamGrabber,
                "Report Ham", "Report to Default Ham profile", "Report to Default Ham profile",
                Office.MsoButtonStyle.msoButtonIcon, Properties.Resources.spamgrab_green,
                false, GlobalSettings.ShowHamButton, _cbSpamGrabber.Controls.Count, _ReportHam);

            _cbcbProfile = AddComboBox(_cbSpamGrabber);
            _cbcbProfile.Visible = GlobalSettings.ShowSelectButton;

            _cbbReportSelected = CreateCommandBarButton(_cbSpamGrabber,
                "Report", "Report to Selected Profile", "Report to Selected Profile",
                Office.MsoButtonStyle.msoButtonCaption, null,
                false, GlobalSettings.ShowSelectButton, _cbSpamGrabber.Controls.Count, _ReportSelected);

            _cbbPreview = CreateCommandBarButton(_cbSpamGrabber,
                "Safe View", "Safe Preview", "Safe Preview",
                Office.MsoButtonStyle.msoButtonIcon, Properties.Resources.search4doc,
                true, GlobalSettings.ShowPreviewButton, _cbSpamGrabber.Controls.Count, _SafeView);

            _cbbCopyToClipboard = CreateCommandBarButton(_cbSpamGrabber,
                "Copy Source", "Copy Source to Clipboard", "Copy Source to Clipboard",
                Office.MsoButtonStyle.msoButtonIcon, Properties.Resources.spamgrab_copy,
                false, GlobalSettings.ShowCopyButton, _cbSpamGrabber.Controls.Count, _CopyToClipboard);

            _cbbOptions = CreateCommandBarButton(_cbSpamGrabber,
                "Options", "SpamGrabber Options", "SpamGrabber Options",
                Office.MsoButtonStyle.msoButtonIcon, Properties.Resources.spamgrab_settings,
                false, GlobalSettings.ShowSettingsButton, _cbSpamGrabber.Controls.Count, _Settings);

            Reporting.Application = Globals.ThisAddIn.Application;
        }
コード例 #42
0
        private void AddCommandBarButtons_recursive(XmlNodeList nodes, Dictionary <string, Core.CommandBarButton> buttons, Core.CommandBarPopup cmdbar, bool beginGroup)
        {
            if (nodes == null)
            {
                return;
            }
            foreach (XmlNode node in nodes)
            {
                var    nodeName  = node.Name;
                string nodeLabel = string.Empty;
                var    labelAtt  = node.Attributes["label"];
                if (labelAtt != null)
                {
                    nodeLabel = labelAtt.Value;
                }
                else
                {
                    var getlabelAtt = node.Attributes["getLabel"];
                    if (getlabelAtt != null)
                    {
                        nodeLabel = (string)typeof(Connect11).GetMethod(getlabelAtt.Value).Invoke(this, null);
                    }
                }
                switch (nodeName)
                {
                case "tab":
                    var oCommandBars = (Core.CommandBars)_excelapp.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, _excelapp, null);
                    _btTab         = (Core.CommandBarPopup)oCommandBars["Worksheet Menu Bar"].Controls.Add(Core.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true);
                    _btTab.Caption = nodeLabel;
                    AddCommandBarButtons_recursive(node.ChildNodes, buttons, _btTab, false);
                    break;

                case "group":
                    AddCommandBarButtons_recursive(node.ChildNodes, buttons, cmdbar, true);
                    break;

                case "menu":
                    var btMenu = (Core.CommandBarPopup)cmdbar.Controls.Add(Core.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true);
                    btMenu.Caption = nodeLabel;
                    if (beginGroup)
                    {
                        btMenu.BeginGroup = true;
                        beginGroup        = false;
                    }
                    AddCommandBarButtons_recursive(node.ChildNodes, buttons, btMenu, false);
                    break;

                case "button":
                    var nodeId = node.Attributes["id"].Value;
                    Core.CommandBarButton bt = (Core.CommandBarButton)cmdbar.Controls.Add(Core.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
                    buttons.Add(nodeId, bt);
                    bt.Caption = nodeLabel;
                    string imgName  = null;
                    var    imageAtt = node.Attributes["image"];
                    if (imageAtt != null)
                    {
                        imgName = imageAtt.Value;
                    }
                    else
                    {
                        var getimageAtt = node.Attributes["getImage"];
                        if (getimageAtt != null)
                        {
                            imgName = (string)typeof(Connect11).GetMethod(getimageAtt.Value).Invoke(this, null);
                        }
                    }
                    if (imgName != null)
                    {
                        var image = GetPicture(imgName);
                        if (image != null)
                        {
                            bt.Picture = image;
                        }
                        var imagemsk = GetPicture(imgName + "_msk");
                        if (imagemsk != null)
                        {
                            bt.Mask = imagemsk;
                        }
                    }

                    var enabledAtt = node.Attributes["enabled"];
                    if (enabledAtt != null)
                    {
                        bt.Enabled = bool.Parse(enabledAtt.Value);
                    }
                    else
                    {
                        var getenabledAtt = node.Attributes["getEnabled"];
                        if (getenabledAtt != null)
                        {
                            bt.Enabled = (bool)typeof(Connect11).GetMethod(getenabledAtt.Value).Invoke(this, null);
                        }
                    }
                    //_commands.SetControlEnabled(nodeId, bool.Parse(enabledAttribute.Value));
                    var screentip = node.Attributes["screentip"];
                    if (screentip != null)
                    {
                        bt.TooltipText = node.Attributes["screentip"].Value;
                    }
                    if (beginGroup)
                    {
                        bt.BeginGroup = true;
                        beginGroup    = false;
                    }
                    bt.Click += delegate { _commands.OnActionInvoked(nodeId); };
                    break;
                }
            }
        }
コード例 #43
0
 private void btnBanckleClick(Office.CommandBarButton ctrl, ref bool cancel)
 {
     System.Diagnostics.Process.Start("https://crm.banckle.com/");
 }
コード例 #44
0
        private void cbtnSettings_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            frmSettings objacbbSettings = new frmSettings();

            objacbbSettings.ShowDialog();
        }
コード例 #45
0
        /// <summary>
        ///     Generates quotation sheets by user selection using templates
        /// </summary>
        /// <param name="ctrl"></param>
        /// <param name="canceldefault"></param>
        private void _generateSheetsButton_Click(Office.CommandBarButton ctrl, ref bool canceldefault)
        {
            // find all group label by finding where column B is blank but column C is not
            var labels = ((Range)_target.Columns["B"].Cells).Cast <Range>().Select(cell => cell.Value2 as string)
                         .Distinct().Where(value => value != null);
            // create a diction to store the starting address of each label
            var sectionRowLookup = ((Range)_target.Columns["B"].Cells).Cast <Range>()
                                   .ToLookup(c => c.Value2 as string, c => c.Row - _target[1, 1].Row as int?);

            // add a new workbook
            var customTemplatePath = ConfigurationManager.AppSettings["TemplatePath"];
            var templatePath       = string.IsNullOrWhiteSpace(customTemplatePath)
                ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\自定义 Office 模板\涂装项目报价表模板.xltx"
                : customTemplatePath;
            var wb = _target.Application.Workbooks.Add(templatePath);

            // paste to new workbook
            foreach (Worksheet sheet in wb.Sheets)
            {
                // format summary style
                sheet.Outline.SummaryRow = XlSummaryRow.xlSummaryAbove;

                // continue if it's a constant sheet
                // todo: separate into app config
                if (sheet.Name == "材料及加工费综合单价")
                {
                    continue;
                }

                // apply auto fill
                var startCell = sheet.UsedRange.End[XlDirection.xlDown].Offset[1, 0];
                var endCell   = sheet.Cells[sheet.UsedRange.Rows.Count, sheet.UsedRange.Columns.Count]
                                .Offset[_target.Rows.Count - 1, 0] as Range;
                var source      = startCell.Resize[ColumnSize : sheet.UsedRange.Columns.Count];
                var destination = sheet.Range[startCell.Address, endCell.Address];
                source.AutoFill(destination);

                // modify section sum
                foreach (var sectionRowGroup in sectionRowLookup)
                {
                    // convert to absolute row number of section
                    var absoluteRowGroup = sectionRowGroup.Select(i => i + startCell.Row);

                    if (string.IsNullOrEmpty(sectionRowGroup.Key))
                    {
                        // highlight section header
                        absoluteRowGroup.ToList().ForEach(row =>
                        {
                            var rng = (Range)sheet.Cells[row, 1].Resize[1, sheet.UsedRange.Columns.Count];
                            rng.Interior.ThemeColor   = XlThemeColor.xlThemeColorAccent5;
                            rng.Interior.TintAndShade = 0.5;
                        });
                        continue;
                    }

                    // write summary
                    var sumFormulaSource = (Range)sheet.Cells[absoluteRowGroup.Min() - 1, 1];
                    sumFormulaSource.Formula = $"=SUM(A{absoluteRowGroup.Min()}:A{absoluteRowGroup.Max()})";

                    var sumDestination = sheet.Range[sumFormulaSource.Address,
                                                     sheet.Cells[sumFormulaSource.Row, sheet.UsedRange.Columns.Count]];

                    sumFormulaSource.AutoFill(sheet.Range[sumFormulaSource.Address, sumDestination.Address],
                                              XlAutoFillType.xlFillValues);

                    ((Range)sheet.Rows[$"{absoluteRowGroup.Min()}:{absoluteRowGroup.Max()}"]).Group();
                }

                // paste content
                // todo: separate into app config
                if (sheet.Name == "加工单价表")
                {
                    _target.Resize[ColumnSize : 4].Copy();
                }
                else
                {
                    _target.Resize[ColumnSize : 3].Copy();
                }
                sheet.Activate();
                startCell.PasteSpecial(XlPasteType.xlPasteValues);

                // modify coefficient if it's summary sheet
                if (sheet.Name == "报价表")
                {
                    _target.Columns[5].Copy();
                    endCell.Offset[-(_target.Rows.Count - 1), -2].Resize[_target.Rows.Count, 2]
                    .PasteSpecial(XlPasteType.xlPasteValues);
                }

                // adjust row height and column width
                sheet.UsedRange.Columns.AutoFit();
                sheet.UsedRange.Rows.AutoFit();
            }
        }
コード例 #46
0
ファイル: ThisAddIn.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>CreateEventToRenameOnFolderContextMenu</c> Event Handler
        /// Method to  create rename event of folder context menu
        /// </summary>
        /// <param name="CommandBar"></param>
        /// <param name="Folder"></param>
        private void CreateEventToRenameOnFolderContextMenu(Microsoft.Office.Core.CommandBar CommandBar, Microsoft.Office.Interop.Outlook.MAPIFolder Folder)
        {
            for (int i = 1; i <= CommandBar.Controls.Count; i++)
            {
                if (CommandBar.Controls[i].Caption.StartsWith("&Rename"))
                {
                    try
                    {
                        renameButton.Click -= new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(renameButton_Click);
                    }
                    catch { }
                    renameButton = null;
                    renameButton = (Office.CommandBarButton)CommandBar.Controls[i];
                    renameButton.Tag = Folder.Name;

                    renameButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(renameButton_Click);
                    break;
                }
            }
        }
コード例 #47
0
ファイル: MenuManager.cs プロジェクト: dilipkumarj/sandbox
        /// <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;
            }
        }
コード例 #48
0
ファイル: ThisAddIn.cs プロジェクト: imysecy/SPLINK
        /// <summary>
        /// <c>Application_FolderContextMenuDisplay</c> Event Handler
        /// Folder context menu display event
        /// it is executed when user right clicks on outlook folder to display context menu 
        /// </summary>
        /// <param name="CommandBar"></param>
        /// <param name="Folder"></param>
        void Application_FolderContextMenuDisplay(Microsoft.Office.Core.CommandBar CommandBar, Microsoft.Office.Interop.Outlook.MAPIFolder Folder)
        {
            try
            {
                currentFolderSelected = Folder.Name;

                currentFolderSelectedGuid = Folder.EntryID;
                AddfFolderinSessionMapi();
                MAPIFolderWrapper folderWrapper = myFolders.Find(delegate(MAPIFolderWrapper p) { return p.FolderName == Folder.Name; });

                if (folderWrapper != null && !string.IsNullOrEmpty(Folder.WebViewURL))
                {

                    oContextMenuFolder = Folder;
                    try
                    {
                        CreateEventToRenameOnFolderContextMenu(CommandBar, Folder);
                        //Remove the click event on the button
                        oFolderMenuButtonEditConnectionProperties.Click -= new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(oFolderMenuButtonEditConnectionProperties_Click);

                    }
                    catch { }

                    //System.Diagnostics.Debugger.Launch();

                    //Add Edit Connection properties button
                    oFolderMenuButtonEditConnectionProperties = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    oFolderMenuButtonEditConnectionProperties.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    oFolderMenuButtonEditConnectionProperties.Caption = "Edit Connection (ITOPIA)";
                    oFolderMenuButtonEditConnectionProperties.FaceId = 222;
                    oFolderMenuButtonEditConnectionProperties.Tag = Folder.Name;
                    oFolderMenuButtonEditConnectionProperties.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(oFolderMenuButtonEditConnectionProperties_Click);

                    //Add SharePoint View Context Menu button
                    oFolderMenuButtonSharePointView = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    oFolderMenuButtonSharePointView.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    oFolderMenuButtonSharePointView.Caption = "SharePoint View (ITOPIA)";
                    oFolderMenuButtonSharePointView.FaceId = 223;
                    oFolderMenuButtonSharePointView.Tag = Folder.Name + "A";
                    oFolderMenuButtonSharePointView.Click += new Office._CommandBarButtonEvents_ClickEventHandler(oFolderMenuButtonSharePointView_Click);

                    //Add Outlook View Context Menu button
                    oFolderMenuButtonOutlookView = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    oFolderMenuButtonOutlookView.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    oFolderMenuButtonOutlookView.Caption = "Outlook View (ITOPIA)";
                    oFolderMenuButtonOutlookView.FaceId = 224;
                    oFolderMenuButtonOutlookView.Tag = Folder.Name + "B";
                    oFolderMenuButtonOutlookView.Click += new Office._CommandBarButtonEvents_ClickEventHandler(oFolderMenuButtonOutlookView_Click);

                    ////Add view Connection properties button
                    //oFolderMenuButtonViewProperties = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    //oFolderMenuButtonViewProperties.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    //oFolderMenuButtonViewProperties.Caption = "ITOPIA Edit Connection Properties";
                    //oFolderMenuButtonViewProperties.FaceId = 222;
                    //oFolderMenuButtonViewProperties.Tag = Folder.Name;
                    //oFolderMenuButtonViewProperties.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(oFolderMenuButtonEditConnectionProperties_Click);
                    ////

                    Outlook.MAPIFolder myfolder = (Outlook.MAPIFolder)Folder.Parent;
                    try
                    {
                        myfolder.Folders.FolderChange -= new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);
                    }
                    catch (Exception)
                    {

                    }

                    myfolder.Folders.FolderChange += new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                }
            }
            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("Application_FolderContextMenuDisplay", ex.Message, MessageBoxIcon.Error);
            }
        }
コード例 #49
0
ファイル: ThisAddIn.cs プロジェクト: wallenius71/Wind-Dev
        // 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  = "Define &UFL";

                // 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: Import Data
                    menuCommandImportData = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandImportData.Caption = "&Add UFL Areas";
                    menuCommandImportData.Tag     = menuTags.ImportData.ToString();
                    menuCommandImportData.FaceId  = 4388;

                    menuCommandImportData.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);


                    // Add the menu command: Insert Column Header
                    menuCommandInsertColumnHeader = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandInsertColumnHeader.BeginGroup = true;
                    menuCommandInsertColumnHeader.Caption    = "&Insert PI Tag Header";
                    menuCommandInsertColumnHeader.Tag        = menuTags.InsertColumnHeader.ToString();

                    menuCommandInsertColumnHeader.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);

                    // Add the menu command: Load Details
                    menuCommandLoadDetails = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandLoadDetails.BeginGroup = true;

                    menuCommandLoadDetails.Caption = "&Load Details From Database";
                    menuCommandLoadDetails.Tag     = menuTags.LoadDetails.ToString();
                    menuCommandLoadDetails.FaceId  = 23;


                    menuCommandLoadDetails.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);


                    // Add the menu command: Save Details
                    menuCommandSaveDetails = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandSaveDetails.Caption = "&Save Details To Database";
                    menuCommandSaveDetails.Tag     = menuTags.SaveDetails.ToString();
                    menuCommandSaveDetails.FaceId  = 3;

                    menuCommandSaveDetails.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);

                    // Add the menu command: Save As New Format
                    menuCommandSaveAsDetails = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandSaveAsDetails.Caption = "Save As New &Format";
                    menuCommandSaveAsDetails.Tag     = menuTags.SaveAsDetails.ToString();
                    menuCommandSaveAsDetails.FaceId  = 0;

                    menuCommandSaveAsDetails.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);

                    // Add the menu command: GenerateUFL
                    menuCommandGenerateUFL = (Office.CommandBarButton)cmdBarControl.Controls.Add(
                        Office.MsoControlType.msoControlButton, missing, missing, missing, true);

                    menuCommandGenerateUFL.BeginGroup = true;
                    menuCommandGenerateUFL.Caption    = "&Generate UFL";
                    menuCommandGenerateUFL.Tag        = menuTags.GenerateUFL.ToString();
                    menuCommandGenerateUFL.FaceId     = 65;

                    menuCommandGenerateUFL.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 Define UFL";
                    menuCommandAbout.Tag        = menuTags.About.ToString();

                    menuCommandAbout.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                        menuCommand_Click);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
コード例 #50
0
        private void AddToolbar()
        {
            if (newToolBar == null)
            {
                Office.CommandBars cmdBars =
                    this.Application.ActiveExplorer().CommandBars;
                newToolBar = cmdBars.Add("NewToolBar",
                    Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                Office.CommandBarButton button_1 =
                    (Office.CommandBarButton)newToolBar.Controls
                    .Add(1, missing, missing, missing, missing);
                button_1.Style = Office
                    .MsoButtonStyle.msoButtonIconAndCaption;
                button_1.Caption = "Close SalesLogix Task Pane";
                button_1.Tag = "show";
                button_1.FaceId = 0005;
                if (this.firstButton == null)
                {
                    this.firstButton = button_1;
                    firstButton.Click += new Office.
                        _CommandBarButtonEvents_ClickEventHandler
                        (ButtonClick);
                }

                newToolBar.Visible = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #51
0
        public void OnStartupComplete(ref System.Array custom)
        {
            /*
             *
             * When outlook is opened it loads a Menu if Outlook plugin is installed.
             * PengERP - > 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();
                PengERPOutlookPlugin openerp_outlook = Cache.PengERPOutlookPlugin;
                PengERPConnect       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 + " '.", "PengERP Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                newMenuBar = (office.CommandBarPopup)menuBar.Controls.Add(office.MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
                if (newMenuBar != null)
                {
                    newMenuBar.Caption = "PengERP";
                    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);
            }
        }
コード例 #52
0
ファイル: ThisAddIn.cs プロジェクト: javacx/alfresco
        /// <summary>
        /// Adds commandBars to Word Application
        /// </summary>
        private void AddToolbar()
        {
            // VSTO API uses object-wrapped booleans
             object falseValue = false;
             object trueValue = true;

             // Try to get a handle to an existing COMMANDBAR_NAME CommandBar
             try
             {
            m_CommandBar = Application.CommandBars[COMMANDBAR_NAME];

            // If we found the CommandBar, then it's a permanent one we need to delete
            // Note: if the user has manually created a toolbar called COMMANDBAR_NAME it will get torched here
            if (m_CommandBar != null)
            {
               m_CommandBar.Delete();
            }
             }
             catch
             {
            // Benign - the CommandBar didn't exist
             }

             // Create a temporary CommandBar named COMMANDBAR_NAME
             m_CommandBar = Application.CommandBars.Add(COMMANDBAR_NAME, Office.MsoBarPosition.msoBarTop, falseValue, trueValue);

             if (m_CommandBar != null)
             {
            // Load any saved toolbar position
            LoadToolbarPosition();

            // Add our button to the command bar (as a temporary control) and an event handler.
            m_AlfrescoButton = (Office.CommandBarButton)m_CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, trueValue);
            if (m_AlfrescoButton != null)
            {
               m_AlfrescoButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
               m_AlfrescoButton.Caption = COMMANDBAR_BUTTON_CAPTION;
               m_AlfrescoButton.DescriptionText = COMMANDBAR_BUTTON_DESCRIPTION;
               m_AlfrescoButton.TooltipText = COMMANDBAR_BUTTON_DESCRIPTION;
               Bitmap bmpButton = new Bitmap(GetType(), "toolbar.ico");
               m_AlfrescoButton.Picture = new ToolbarPicture(bmpButton);
               Bitmap bmpMask = new Bitmap(GetType(), "toolbar_mask.ico");
               m_AlfrescoButton.Mask = new ToolbarPicture(bmpMask);
               m_AlfrescoButton.Tag = "AlfrescoButton";

               // Finally add the event handler and make sure the button is visible
               m_AlfrescoButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(m_AlfrescoButton_Click);
            }

            // Add the help button to the command bar (as a temporary control) and an event handler.
            m_HelpButton = (Office.CommandBarButton)m_CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, trueValue);
            if (m_HelpButton != null)
            {
               m_HelpButton.Style = Office.MsoButtonStyle.msoButtonIcon;
               m_HelpButton.DescriptionText = COMMANDBAR_HELP_DESCRIPTION;
               m_HelpButton.TooltipText = COMMANDBAR_HELP_DESCRIPTION;
               m_HelpButton.FaceId = 984;
               m_HelpButton.Tag = "AlfrescoHelpButton";

               // Finally add the event handler and make sure the button is visible
               m_HelpButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(m_HelpButton_Click);
            }

            // We need to find this toolbar later, so protect it from user changes
            m_CommandBar.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize;
            m_CommandBar.Visible = true;
             }
        }
コード例 #53
0
        void btn_open_configuration_form_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            frm_openerp_configuration frm_config = new frm_openerp_configuration();

            frm_config.Show();
        }
コード例 #54
0
 void _FindRepalceWordBtn_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
 {
     OpenMyFloatingPanel();
 }
コード例 #55
0
 private void btnAddContactClick(Office.CommandBarButton ctrl, ref bool cancel)
 {
 }
コード例 #56
0
ファイル: ThisAddIn.cs プロジェクト: MiguelRa/OfficeGengo
        // addin startup event handler. Here we initialize and show the task pane.
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // create and show myCustomTaskPane
            ucTranslationPanel = new UCTranslationPanel();
            tpTranslationPanel = this.CustomTaskPanes.Add(ucTranslationPanel, _taskPaneTitle);
            tpTranslationPanel.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            tpTranslationPanel.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;
            tpTranslationPanel.Width = widthTaskPaneDocked;
            tpTranslationPanel.Visible = true;
            tpTranslationPanel.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged);
            tpTranslationPanel.DockPositionChanged += new EventHandler(myCustomTaskPane_DockPositionChanged);

            // add menu item to View menu
            // * get View Menu
            string viewMenuID = "30004";
            Office.CommandBarPopup viewMenu = (Office.CommandBarPopup)this.Application.ActiveExplorer().
                                                CommandBars.ActiveMenuBar.FindControl(Office.MsoControlType.msoControlPopup,
                                                                viewMenuID, Type.Missing, true, true);

            // * add menu item
            miToogleTranslationPanel = (Office.CommandBarButton)viewMenu.Controls.Add(Office.MsoControlType.msoControlButton, missing,
                                                                            missing, 1, true);
            //miToogleTranslationPanel.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
            miToogleTranslationPanel.Caption = _viewMenuItemText;
            miToogleTranslationPanel.FaceId = 65;
            miToogleTranslationPanel.Tag = "c123";
            miToogleTranslationPanel.State = Office.MsoButtonState.msoButtonDown;
            miToogleTranslationPanel.Click += new Office._CommandBarButtonEvents_ClickEventHandler(viewTaskPane_Click);
        }
コード例 #57
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try
            {
                var outlookApp = this.Application;
                OutlookVersion = (OutlookMajorVersion)Convert.ToInt32(outlookApp.Version.Split('.')[0]);

                this.settings = new clsSettings();
                StartLogging(settings);

                _syncContext        = new SyncContext(outlookApp, settings);
                _contactSyncing     = new ContactSyncing(_syncContext);
                _taskSyncing        = new TaskSyncing(_syncContext);
                _appointmentSyncing = new AppointmentSyncing(_syncContext);

                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);

                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)
                    {
                        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);
                }

                while (!this.VerifyLicenceKey())
                {
                    /* if licence key does not validate, show the settings form to allow the user to enter
                     * a (new) key, and retry. */
                    this.ShowSettingsForm();
                }

                SuiteCRMAuthenticate();
                new Thread(() => SyncAndAutoArchive()).Start();
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.ThisAddIn_Startup", ex);
            }
        }