示例#1
0
        public virtual void LoadMenu()
        {
            Office.CommandBars oCommandBars = null;

            try
            {
                oCommandBars = (Office.CommandBars)m_app.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, m_app, null);
            }
            catch (Exception)
            {
            }

            try
            {
                NewMenuBar = oCommandBars[cstrMenuTitle];
            }
            catch (Exception)
            {
                // doesn't exist yet, so create it
                NewMenuBar         = oCommandBars.Add(cstrMenuTitle, 1, missing, true);
                NewMenuBar.Visible = true;
            }

            ReleaseComObject(oCommandBars);
        }
示例#2
0
        /**
         * AddToolbar
         * Adds the toolbar and button to Excel
         **/
        private void AddToolbar()
        {
            if (this.toolbar == null)
            {
                Office.CommandBars cmdBar = this.Application.CommandBars;
                this.toolbar         = cmdBar.Add("MedPC Import Utility", Office.MsoBarPosition.msoBarTop, false, true);
                this.toolbar.Visible = true;
            }

            try
            {
                importButton         = (Office.CommandBarButton)toolbar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                importButton.Caption = "Quick-import data";
                importButton.Tag     = "MPC_Import";
                importButton.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(quickImportButton_click);
                importButton.Picture = getImage();

                importButton         = (Office.CommandBarButton)toolbar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                importButton.Caption = "Import data";
                importButton.Tag     = "MPC_Import";
                importButton.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(importButton_click);
                importButton.Picture = getImage();

                dataFilePath = "c:\\MED-PC IV\\Data";
                xmlFilePath  = "c:\\MED-PC IV\\MPC";
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Add a new CommandBar
        /// </summary>
        internal void Add()
        {
            if (_explorer == null)
            {
                return;
            }

            _commandBar = Find(_cmdBarName);
            if (_commandBar == null)
            {
                Office.CommandBars bars = _explorer.CommandBars;
                _commandBar = bars.Add(_cmdBarName, Office.MsoBarPosition.msoBarTop, false, true);
            }
            _commandBar.Visible = true;

            foreach (string btn in new string[] { "About", "Settings", "Decrypt", "Verify" })
            {
                _buttons.Add(btn, (Office.CommandBarButton)_commandBar.Controls.Add(Office.MsoControlType.msoControlButton,
                                                                                    Type.Missing, Type.Missing, 1, true));
                _buttons[btn].Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                _buttons[btn].Caption = btn;
                _buttons[btn].Tag     = "GnuPG" + btn;
            }

            // http://www.kebabshopblues.co.uk/2007/01/04/visual-studio-2005-tools-for-office-commandbarbutton-faceid-property/
            _buttons["Decrypt"].FaceId  = 718;
            _buttons["Verify"].FaceId   = 719;
            _buttons["About"].FaceId    = 700;
            _buttons["Settings"].FaceId = 2144;

            _buttons["Decrypt"].Picture  = ImageConverter.Convert(Properties.Resources.lock_edit);
            _buttons["Verify"].Picture   = ImageConverter.Convert(Properties.Resources.link_edit);
            _buttons["About"].Picture    = ImageConverter.Convert(Properties.Resources.Logo);
            _buttons["Settings"].Picture = ImageConverter.Convert(Properties.Resources.database_gear);
        }
示例#4
0
        private void InitializeToolbar()
        {
            if (cbNieuwsbrief == null)
            {
                // Adding the commandbar to Active explorer
                Office.CommandBars commandBars = this.Application.ActiveExplorer().CommandBars;

                // Adding Nieuwsbrief Toolbar to the commandBars
                cbNieuwsbrief = commandBars.Add(COMMANDBAR_TITLE, Office.MsoBarPosition.msoBarTop, false, true);
            }
        }
示例#5
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Define the Old Menu Bar
            PacktOldMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
            // Define the new Menu Bar into the existing menu bar
            PacktNewMenuBar = (Office.CommandBarPopup)PacktOldMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false);
            //If PacktNewMenuBar not found then the code will add it
            if (PacktNewMenuBar != null)
            {
                // Set caption for the Menu
                PacktNewMenuBar.Caption = "Analyze PKCS#7 structure";
                // Tag string value passing
                PacktNewMenuBar.Tag = strMenuString;
                // Assigning button type
                PacktButton1 = (Office.CommandBarButton)PacktNewMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                // Setting up the button style
                PacktButton1.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow;
                // Set button caption
                PacktButton1.Caption = "Analyze PKCS#7 structure";
                // Set the menu visible
                PacktNewMenuBar.Visible = true;
            }



            // Verify the PacktCustomToolBar exist and add to the application
            if (PacktCustomToolBar == null)
            {
                // Adding the commandbar to Active explorer
                Office.CommandBars PacktBars = this.Application.ActiveExplorer().CommandBars;
                // Adding PacktCustomToolBar to the commandbars
                PacktCustomToolBar = PacktBars.Add("NewPacktToolBar", Office.MsoBarPosition.msoBarTop, false, true);
            }
            // Adding button to the custom tool bar
            Office.CommandBarButton MyButton1 = (Office.CommandBarButton)PacktCustomToolBar.Controls.Add(1, missing, missing, missing, missing);
            // Set the button style
            MyButton1.Style = Office.MsoButtonStyle.msoButtonCaption;
            // Set the caption and tag string
            MyButton1.Caption = "Analyze PKCS#7 structure";
            MyButton1.Tag     = "Analyze PKCS#7 structure";
            if (this.PacktButtonA == null)
            {
                // Adding the event handler for the button in the toolbar
                this.PacktButtonA   = MyButton1;
                PacktButtonA.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick);
            }
            olApp = new Outlook.ApplicationClass();
            Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");

            olExplorer = olApp.ActiveExplorer();
            //  olExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
        }
示例#6
0
        private void AddToolbar()
        {
            if (newToolBar == null)
            {
                Office.CommandBars cmdBars = this.Application.ActiveExplorer().CommandBars;
                //cmdBars.
                newToolBar = cmdBars.Add("Banckle CRM", Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                //Office.

                btnBanckle         = (Office.CommandBarButton)newToolBar.Controls.Add(1, missing, missing, missing, missing);
                btnBanckle.Style   = Office.MsoButtonStyle.msoButtonIcon;
                btnBanckle.Caption = "Banckle CRM";
                btnBanckle.Tag     = "Banckle CRM";
                btnBanckle.Picture = getImage(Properties.Resources.crm_16x16);
                btnBanckle.Click  += new Office._CommandBarButtonEvents_ClickEventHandler(btnBanckleClick);


                btnSync            = (Office.CommandBarButton)newToolBar.Controls.Add(1, missing, missing, missing, missing);
                btnSync.Style      = Office.MsoButtonStyle.msoButtonIconAndCaption;
                btnSync.Caption    = "Sync";
                btnSync.Tag        = "Sync";
                btnSync.Picture    = getImage(Properties.Resources.sync_16x16);
                btnSync.BeginGroup = true;
                btnSync.Click     += new Office._CommandBarButtonEvents_ClickEventHandler(btnSyncClick);


                btnSettings         = (Office.CommandBarButton)newToolBar.Controls.Add(1, missing, missing, missing, missing);
                btnSettings.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                btnSettings.Caption = "Settings";
                btnSettings.Picture = getImage(Properties.Resources.settings_16x16);
                btnSettings.Tag     = "Settings";
                newToolBar.Visible  = true;
                btnSettings.Click  += new Office._CommandBarButtonEvents_ClickEventHandler(btnSettingsClick);

                btnAbout            = (Office.CommandBarButton)newToolBar.Controls.Add(1, missing, missing, missing, missing);
                btnAbout.Style      = Office.MsoButtonStyle.msoButtonIconAndCaption;
                btnAbout.Caption    = "About";
                btnAbout.Picture    = getImage(Properties.Resources.banckle_16x16);
                btnAbout.BeginGroup = true;
                btnAbout.Tag        = "About";
                btnAbout.Visible    = true;
                btnAbout.Click     += new Office._CommandBarButtonEvents_ClickEventHandler(btnAboutClick);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error:" + ex.Message, "Error");
            }
        }
        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);
            }
        }
示例#8
0
        AddToolBar(
            Office.CommandBars cbars,
            string toolBarName)
        {
            Office.CommandBar cbar;

            // Check to see if the toolbar already exists.  Delete it if found.
            // Need to do this in a loop as some apps allow multiple bars with
            // same name.

            foreach (Office.CommandBar cb in cbars)
            {
                if (cb.Name == toolBarName)
                {
                    cb.Delete();
                }
            }

            cbar         = cbars.Add(toolBarName, Office.MsoBarPosition.msoBarTop, false, true);
            cbar.Visible = true;
            return(cbar);
        }