Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static CommandBarButton MakeANewButton(
            Microsoft.Office.Core.CommandBar commandBar, string caption,
            Bitmap facePic, bool beginGroup, string onAction)
        {
            CommandBarButton newButton = null;

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

            return(newButton);
        }
Exemplo n.º 3
0
        private static IPictureDisp GetMask(Bitmap facePic)
        {
            Bitmap bmp = new Bitmap(facePic);

            Color back = Color.FromArgb(255, 255, 255, 255);

            for (int x = 0; x < bmp.Size.Width; x++)
            {
                for (int y = 0; y < bmp.Size.Height; y++)
                {
                    if (facePic.GetPixel(x, y).A > 0)
                    {
                        bmp.SetPixel(x, y, Color.Black);
                    }
                    else
                    {
                        bmp.SetPixel(x, y, Color.White);
                    }
                }
            }

            return((IPictureDisp)AxHost2.GettIPictureDispFromPicture(bmp));
        }