Beispiel #1
0
 /// <summary>
 /// Remove the GnuPG CommandBar, if any.
 /// </summary>
 /// <param name="explorer"></param>
 internal void Remove()
 {
     Office.CommandBar bar = Find(_cmdBarName);
     if (bar == null)
     {
         return;
     }
     bar.Delete();
 }
Beispiel #2
0
        private void MyToolBar()
        {
            try
            {
                // Delete the existing instance, if applicable.
                Office.CommandBar _objTmpToolBar = (Office.CommandBar) this.Application.ActiveExplorer()
                                                   .CommandBars.FindControl(missing, missing,
                                                                            menuToolBarTag, true);
                if (_objTmpToolBar != null)
                {
                    _objTmpToolBar.Delete();
                }

                // Add a new toolbar to the CommandBars collection
                // of the Explorer window.
                _objToolBar = this.Application.ActiveExplorer()
                              .CommandBars.Add(menuToolBarTag,
                                               Office.MsoBarPosition.msoBarTop, false, true);
                if (_objToolBar != null)
                {
                    // Add a button to the new toolbar.
                    _objNewToolBarButton = (Office.CommandBarButton)_objToolBar
                                           .Controls.Add(Office.MsoControlType.msoControlButton,
                                                         missing, missing, 1, true);
                    _objNewToolBarButton.Style = Office.MsoButtonStyle
                                                 .msoButtonIconAndCaption;
                    _objNewToolBarButton.Caption = "My ToolBar Button";
                    _objNewToolBarButton.FaceId  = 65;
                    _objNewToolBarButton.Tag     = menuToolBarTag;
                    _objNewToolBarButton.Click  += new Office._CommandBarButtonEvents_ClickEventHandler(_objToolBarButton_Click);
                    _objNewToolBarButton.Visible = true;
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString()
                                                     , "Error Message");
            }
        }
Beispiel #3
0
        /// <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;
             }
        }
        /// <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;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Creates the tooblar, adds the buttons and enqueues click events handlers.
        /// </summary>
        private void BuildToolbar()
        {
            bool toolbarExists = FindXWordToolbar();

            if (toolbarExists)
            {
                xWordToolbar.Delete();
            }

            try
            {
                xWordToolbar = application.CommandBars.Add(
                    "XWord2003 ToolBar",
                    Office.MsoBarPosition.msoBarTop,
                    false,
                    true);
                xWordToolbar.Enabled    = true;
                xWordToolbar.Visible    = false;
                xWordToolbar.Protection = Office.MsoBarProtection.msoBarNoCustomize;
                xWordToolbar.Name       = "XWord2003 ToolBar";

                if (xWordToolbar != null)
                {
                    btnNew = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnNew.Caption = "New...";
                    btnNew.FaceId  = 1;
                    btnNew.Enabled = false;
                    btnNew.Visible = true;
                    btnNew.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnNew.Tag     = "XWord2003ToolbarBtnNew";
                    btnNew.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnNew_Click);

                    btnOpen = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnOpen.Caption = "Open XWiki page";
                    btnOpen.FaceId  = 1;
                    btnOpen.Enabled = false;
                    btnOpen.Visible = true;
                    btnOpen.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnOpen.Tag     = "XWord2003ToolbarBtnOpen";
                    btnOpen.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnOpen_Click);

                    btnPublish = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnPublish.Caption = "Publish XWiki page";
                    btnPublish.FaceId  = 1;
                    btnPublish.Enabled = false;
                    btnPublish.Visible = true;
                    btnPublish.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnPublish.Tag     = "XWord2003ToolbarBtnPublish";
                    btnPublish.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnPublish_Click);

                    btnViewInBrowser = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnViewInBrowser.Caption = "View in Browser";
                    btnViewInBrowser.FaceId  = 1;
                    btnViewInBrowser.Enabled = false;
                    btnViewInBrowser.Visible = true;
                    btnViewInBrowser.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnViewInBrowser.Tag     = "XWord2003ToolbarBtnViewInBrowser";
                    btnViewInBrowser.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnViewInBrowser_Click);

                    btnViewAttachments = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnViewAttachments.Caption    = "View Attachments";
                    btnViewAttachments.FaceId     = 1;
                    btnViewAttachments.Enabled    = false;
                    btnViewAttachments.Visible    = true;
                    btnViewAttachments.Style      = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnViewAttachments.Tag        = "XWord2003ToolbarBtnViewAttachments";
                    btnViewAttachments.BeginGroup = true;
                    btnViewAttachments.Click     += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnViewAttachments_Click);

                    btnAddAttachment = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnAddAttachment.Caption = "Add Attachment";
                    btnAddAttachment.FaceId  = 1;
                    btnAddAttachment.Enabled = false;
                    btnAddAttachment.Visible = true;
                    btnAddAttachment.Style   = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnAddAttachment.Tag     = "XWord2003ToolbarBtnAddAttachment";
                    btnAddAttachment.Click  += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnAddAttachment_Click);

                    btnXWordSettings = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnXWordSettings.Caption    = "XWord Settings";
                    btnXWordSettings.FaceId     = 1;
                    btnXWordSettings.Enabled    = true;
                    btnXWordSettings.Visible    = true;
                    btnXWordSettings.Style      = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnXWordSettings.Tag        = "XWord2003ToolbarBtnXWordSettings";
                    btnXWordSettings.BeginGroup = true;
                    btnXWordSettings.Click     += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnXWordSettings_Click);

                    btnAboutXWord = (Office.CommandBarButton)xWordToolbar.Controls.Add(
                        Office.MsoControlType.msoControlButton,
                        missing,
                        missing,
                        missing,
                        true);
                    btnAboutXWord.Caption    = "About XWord";
                    btnAboutXWord.FaceId     = 1;
                    btnAboutXWord.Enabled    = true;
                    btnAboutXWord.Visible    = true;
                    btnAboutXWord.Style      = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    btnAboutXWord.Tag        = "XWord2003ToolbarBtnAbout";
                    btnAboutXWord.BeginGroup = true;
                    btnAboutXWord.Click     += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnAboutXWord_Click);

                    xWordToolbar.Visible = true;
                }
            }
            catch { }
        }