Example #1
0
 /// <summary>
 ///		Implements the constructor for the Add-in object.
 ///		Place your initialization code within this method.
 /// </summary>
 public Connect()
 {
     _scs_button_handler           = new _CommandBarButtonEvents_ClickEventHandler(scsButton_Click);
     _call_contact_button_handler  = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
     _call_sender_button_handler   = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
     _start_meeting_button_handler = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
 }
Example #2
0
        /// <summary>
        /// Adds the command bar.
        /// </summary>
        /// <param name="cmdBr">The CMD br.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="index">The index.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="caption">The caption.</param>
        /// <returns></returns>
        private CommandBarButton AddCommandBar(CommandBar cmdBr, _CommandBarButtonEvents_ClickEventHandler handler, int index, string tag, string caption)
        {
            CommandBarButton cmdBtn = (CommandBarButton)cmdBr.FindControl(MsoControlType.msoControlButton, 0, tag, missing, missing);

            if ((cmdBtn != null))
            {
                cmdBtn.Delete(true);
            }

            cmdBtn         = (CommandBarButton)cmdBr.Controls.Add(MsoControlType.msoControlButton, missing, missing, index, true);
            cmdBtn.Style   = MsoButtonStyle.msoButtonCaption;
            cmdBtn.Caption = caption;
            cmdBtn.Tag     = tag;
            cmdBtn.Visible = true;

            cmdBtn.Click -= handler;
            cmdBtn.Click += handler;

            if (!commandBarsTags.Contains(tag))
            {
                commandBarsTags.Add(tag);
            }

            return(cmdBtn);
        }
Example #3
0
		/// <summary>
		///		Implements the constructor for the Add-in object.
		///		Place your initialization code within this method.
		/// </summary>
		public Connect()
		{
            _scs_button_handler = new _CommandBarButtonEvents_ClickEventHandler(scsButton_Click);
            _call_contact_button_handler = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
            _call_sender_button_handler = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
            _start_meeting_button_handler = new _CommandBarButtonEvents_ClickEventHandler(ItemContext_Click);
		}
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cbar"> commandBar on which the button is added.</param>
        /// <param name="tag"> button tag</param>
        /// <param name="desc">button description</param>
        /// <param name="caption">button caption</param>
        /// <param name="before"></param>
        /// <param name="temp"></param>
        /// <param name="handler"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static CommandBarButton addButton(CommandBar cbar, String tag, String desc, 
            String caption, Object before, bool temp, 
            _CommandBarButtonEvents_ClickEventHandler handler, String parameter)
        {

            CommandBarButton foundButton = (CommandBarButton)cbar.FindControl(
                MsoControlType.msoControlButton,
                Type.Missing, tag, false, true);

            if (foundButton != null)
            {
                foundButton.Caption = caption;
                setClickHandler(foundButton, handler);
                foundButton.Visible = true;
                foundButton.Parameter = parameter;
                return foundButton;
            }

            CommandBarButton button = (CommandBarButton)cbar.Controls.Add(
                MsoControlType.msoControlButton,
                Type.Missing, Type.Missing, before, temp);

            setClickHandler(button, handler);

            button.Tag = tag;
            button.DescriptionText = desc;
            button.BeginGroup = false;
            button.Caption = caption;
            button.Style = MsoButtonStyle.msoButtonIconAndCaption;
            button.Visible = true;
            button.Parameter = parameter;

            return button;
        }
Example #5
0
        //public static bool AutoMaintainCustomTemplate = false;

        /// <summary>
        /// Makes the A new button.
        /// </summary>
        /// <param name="commandBar">The command bar.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="faceID">The face ID.</param>
        /// <param name="beginGroup">if set to <c>true</c> [begin group].</param>
        /// <param name="clickHandler">The click handler.</param>
        /// <returns></returns>
        public static CommandBarButton MakeANewButton(
            Microsoft.Office.Core.CommandBar commandBar, string caption,
            Bitmap facePic, bool beginGroup, _CommandBarButtonEvents_ClickEventHandler clickHandler)
        {
            //Globals.ThisAddIn.PushOldTemplateAndSetCustom();
            object           missing   = System.Reflection.Missing.Value;
            CommandBarButton newButton = null;

            try
            {
                newButton = MakeANewButton(commandBar, caption, beginGroup);
                if (newButton != null)
                {
                    newButton.Click  += clickHandler;
                    newButton.Picture = (IPictureDisp)AxHost2.GettIPictureDispFromPicture(facePic);
                    newButton.Mask    = GetMask(facePic);
                }
            }
            catch (Exception ex)
            {
                LogHelper.DebugException("", ex);
            }

            return(newButton);
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cbar"> commandBar on which the button is added.</param>
        /// <param name="tag"> button tag</param>
        /// <param name="desc">button description</param>
        /// <param name="caption">button caption</param>
        /// <param name="before"></param>
        /// <param name="temp"></param>
        /// <param name="handler"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static CommandBarButton addButton(CommandBar cbar, String tag, String desc,
                                                 String caption, Object before, bool temp,
                                                 _CommandBarButtonEvents_ClickEventHandler handler, String parameter)
        {
            CommandBarButton foundButton = (CommandBarButton)cbar.FindControl(
                MsoControlType.msoControlButton,
                Type.Missing, tag, false, true);

            if (foundButton != null)
            {
                foundButton.Caption = caption;
                setClickHandler(foundButton, handler);
                foundButton.Visible   = true;
                foundButton.Parameter = parameter;
                return(foundButton);
            }

            CommandBarButton button = (CommandBarButton)cbar.Controls.Add(
                MsoControlType.msoControlButton,
                Type.Missing, Type.Missing, before, temp);

            setClickHandler(button, handler);

            button.Tag             = tag;
            button.DescriptionText = desc;
            button.BeginGroup      = false;
            button.Caption         = caption;
            button.Style           = MsoButtonStyle.msoButtonIconAndCaption;
            button.Visible         = true;
            button.Parameter       = parameter;

            return(button);
        }
Example #7
0
 /// <summary>
 ///		Creates a new UI manager for the addin with the given COM ProgID.
 /// </summary>
 /// <param name="progid">The COM ProgID of the addin usin the UI manager</param>
 protected OfficeUIManager(string progid)
 {
     this.progid       = progid;
     controlControlMap = new Hashtable();
     controlWindowMap  = new Hashtable();
     controlProxyMap   = new Hashtable();
     comboBoxChange    = new _CommandBarComboBoxEvents_ChangeEventHandler(combo_Change);
     buttonClick       = new _CommandBarButtonEvents_ClickEventHandler(button_Click);
 }
Example #8
0
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     try
     {
         fixeventHandler  = new _CommandBarButtonEvents_ClickEventHandler(Fix_Click);
         moreeventHandler = new _CommandBarButtonEvents_ClickEventHandler(More_Click);
         Word.Application applicationObject = Globals.ThisAddIn.Application as Word.Application;
         applicationObject.WindowBeforeRightClick += new Microsoft.Office.Interop.Word.ApplicationEvents4_WindowBeforeRightClickEventHandler(App_WindowBeforeRightClick);
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error: " + exception.Message);
     }
 }
Example #9
0
        private void UnregisterButtonClickHandler(CommandBarButton button, _CommandBarButtonEvents_ClickEventHandler clickHandler)
        {
            string methodName = "ThisAddIn.UnregisterButtonClickHandler";

            if (button != null)
            {
                try
                {
                    Log.Info(catalogue.GetString("{0}: Removing archive button click event handler", methodName));
                    button.Click -= new Office._CommandBarButtonEvents_ClickEventHandler(clickHandler);
                }
                catch (Exception ex)
                {
                    log.Error(methodName, ex);
                }
            }
        }
Example #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the button.
        /// </summary>
        /// <param name="caption">The caption.</param>
        /// <param name="bitmapName">Name of the bitmap.</param>
        /// <param name="maskName">Name of the mask.</param>
        /// <param name="eventHandler">The event handler.</param>
        /// <param name="fEnabled">if set to <c>true</c> [f enabled].</param>
        /// <param name="tooltipText">The tooltip text.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        protected CommandBarButton AddButton(string caption, string bitmapName,
                                             string maskName, _CommandBarButtonEvents_ClickEventHandler eventHandler,
                                             bool fEnabled, string tooltipText)
        {
            CommandBarButton btn;

            m_cmdBar.Controls.Add(MsoControlType.msoControlButton, missing, missing,
                                  missing, false);
            btn = (CommandBarButton)m_cmdBar.Controls[m_cmdBar.Controls.Count];
            ImageHelper.SetPicture(btn, bitmapName, maskName);
            btn.Caption = caption;
            btn.Click  += eventHandler;
            btn.Enabled = fEnabled;
            if (tooltipText != null && tooltipText != string.Empty)
            {
                btn.TooltipText = tooltipText;
            }

            return(btn);
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="button"></param>
        /// <param name="handler"></param>
        public static void setClickHandler(CommandBarButton button, _CommandBarButtonEvents_ClickEventHandler handler)
        {
            // Make sure it only fires once.
            try
            {
                do
                {
                    button.Click -= handler;
                } while (true);
            }
            catch (System.Exception ex)
            {
                Logger.WriteEntry(LogLevel.Information, "all click handlers have been successfuly detached from button " + button.Caption + " " + ex.Message);
            }

            finally
            {
                button.Click += handler;
            }
        }
Example #12
0
        /// <summary>
        /// Makes the A new button.
        /// </summary>
        /// <param name="commandBar">The command bar.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="faceID">The face ID.</param>
        /// <param name="beginGroup">if set to <c>true</c> [begin group].</param>
        /// <param name="clickHandler">The click handler.</param>
        /// <returns></returns>
        public static CommandBarButton MakeANewButton(
            Microsoft.Office.Core.CommandBar commandBar, string caption,
            int faceID, bool beginGroup, _CommandBarButtonEvents_ClickEventHandler clickHandler)
        {
            CommandBarButton newButton = null;

            try
            {
                newButton = MakeANewButton(commandBar, caption, beginGroup);
                if (newButton != null)
                {
                    newButton.FaceId = faceID;
                    newButton.Click += clickHandler;
                }
            }
            catch (Exception ex)
            {
                LogHelper.DebugException("", ex);
            }

            return(newButton);
        }
Example #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the button.
		/// </summary>
		/// <param name="caption">The caption.</param>
		/// <param name="bitmapName">Name of the bitmap.</param>
		/// <param name="maskName">Name of the mask.</param>
		/// <param name="eventHandler">The event handler.</param>
		/// <param name="fEnabled">if set to <c>true</c> [f enabled].</param>
		/// <param name="tooltipText">The tooltip text.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected CommandBarButton AddButton(string caption, string bitmapName,
			string maskName, _CommandBarButtonEvents_ClickEventHandler eventHandler,
			bool fEnabled, string tooltipText)
		{
			CommandBarButton btn;
			m_cmdBar.Controls.Add(MsoControlType.msoControlButton, missing, missing,
				missing, false);
			btn = (CommandBarButton)m_cmdBar.Controls[m_cmdBar.Controls.Count];
			ImageHelper.SetPicture(btn, bitmapName, maskName);
			btn.Caption = caption;
			btn.Click += eventHandler;
			btn.Enabled = fEnabled;
			if (tooltipText != null && tooltipText != string.Empty)
				btn.TooltipText = tooltipText;

			return btn;
		}
Example #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="button"></param>
        /// <param name="handler"></param>
        public static void setClickHandler(CommandBarButton button, _CommandBarButtonEvents_ClickEventHandler handler)
        {

            // Make sure it only fires once.
            try
            {
                do
                {
                    button.Click -= handler;
                } while (true);
            }
            catch (System.Exception ex)
            {
                Logger.WriteEntry(LogLevel.Information, "all click handlers have been successfuly detached from button " + button.Caption + " " + ex.Message);
            }

            finally
            {
                button.Click += handler;
            }

        }
        //*************************************************************************
        //  Method: AddContextMenuItem()
        //
        /// <summary>
        /// Adds a custom menu item to a parent CommandBarPopup.
        /// </summary>
        ///
        /// <param name="oCommandBarPopup">
        /// Parent CommandBarPopup to add the custom menu item to.
        /// </param>
        ///
        /// <param name="sText">
        /// Menu item text.
        /// </param>
        ///
        /// <param name="iClickedID">
        /// ID of the single edge or vertex that was selected and right-clicked in
        /// the edge or vertex table.  Can be NoRowID.
        /// </param>
        ///
        /// <param name="oEventHandler">
        /// The menu item's event handler.
        /// </param>
        //*************************************************************************
        protected CommandBarButton AddContextMenuItem(
            CommandBarPopup oCommandBarPopup,
            String sText,
            Int32 iClickedID,
            _CommandBarButtonEvents_ClickEventHandler oEventHandler
            )
        {
            Debug.Assert(oCommandBarPopup != null);
            Debug.Assert( !String.IsNullOrEmpty(sText) );
            Debug.Assert(oEventHandler != null);
            AssertValid();

            // Important Note:
            //
            // Do not use CommandBarButton.Tag to store the clicked ID.  There is
            // a bug in VSTO 2008 that causes all CommandBarButtons with the same
            // Tag to fire their Click events when one such CommandBarButton is
            // clicked.  Here is an online posting discussing this:
            //
            // http://excelusergroup.org/forums/p/700/2153.aspx
            //
            // Instead of the Tag, use the CommandBarButton.Parameter property.

            CommandBarButton oCommandBarButton =
            (CommandBarButton)oCommandBarPopup.Controls.Add(
                MsoControlType.msoControlButton, 1, iClickedID.ToString(),
                Missing.Value, true);

            oCommandBarButton.Caption = sText;
            oCommandBarButton.Style = MsoButtonStyle.msoButtonCaption;
            oCommandBarButton.Enabled = false;
            oCommandBarButton.Click += oEventHandler;

            return (oCommandBarButton);
        }