Example #1
0
        protected virtual Color GetTextColor(ButtonItem button, ItemPaintArgs pa, Office2007ButtonItemColorTable buttonColorTable, bool isExpandPart)
        {
            Color textColor = Color.Empty;

            bool isMouseOver = button.IsMouseOver;
            if (isMouseOver)
            {
                if (isExpandPart)
                {
                    if (!button.IsMouseOverExpand)
                        isMouseOver = false;
                }
                else if (!button.IsMouseOverExpand && button.SplitButton)
                    isMouseOver = false;
            }

            if (isMouseOver)
            {
                if (!button.HotForeColor.IsEmpty)
                    textColor = button.HotForeColor;
            }
            else if (!button.ForeColor.IsEmpty)
                textColor = button.ForeColor;

            if (textColor.IsEmpty)
            {
                if (buttonColorTable != null)
                {
                    if (!button.GetEnabled(pa.ContainerControl))
                    {
                        if (buttonColorTable.Disabled != null)
                            textColor = buttonColorTable.Disabled.Text;
                    }
                    else if (button.IsMouseDown)
                        textColor = buttonColorTable.Pressed.Text;
                    else if (isMouseOver && !(button.EffectiveStyle == eDotNetBarStyle.Metro && button.Expanded))
                        textColor = buttonColorTable.MouseOver.Text;
                    else if (button.Expanded)
                        textColor = buttonColorTable.Expanded.Text;
                    else if (button.Checked && !IsOnMenu(button, pa))
                        textColor = buttonColorTable.Checked.Text;
                    else
                        textColor = buttonColorTable.Default.Text;
                }
            }

            if (textColor.IsEmpty)
                return base.GetTextColor(button, pa);

            return textColor;
        }
Example #2
0
		public override void PaintButton(ButtonItem button, ItemPaintArgs pa)
        {
			bool isOnMenu=IsOnMenu(button, pa);
            if(isOnMenu && button.Parent is ItemContainer)
                isOnMenu=false;
			bool bIsOnMenuBar=pa.IsOnMenuBar;
			bool bThemed=button.IsThemed;
            Graphics g = pa.Graphics;

            Region oldClip = g.Clip as Region;
            try
            {
                g.SetClip(button.DisplayRectangle, CombineMode.Intersect);

                if (!pa.IsOnMenu && !bIsOnMenuBar && bThemed)
                {
                    if (pa.ContainerControl is ButtonX)
                        ThemedButtonXPainter.PaintButton(button, pa);
                    else
                        ThemedButtonItemPainter.PaintButton(button, pa);
                    return;
                }

                Rectangle itemRect = button.DisplayRectangle;

                Color textColor = GetTextColor(button, pa);
                CompositeImage image = button.GetImage(textColor);
                Rectangle imageRect = GetImageRectangle(button, pa, image);

                PaintButtonBackground(button, pa, image);

                Rectangle customizeCheckRect = GetCustomizeMenuCheckRectangle(button, pa);
                Rectangle checkRect = GetCheckRectangle(button, pa, image);
                Rectangle mouseOverRect = GetMouseOverRectangle(button, pa, image);

                bool mouseOver = button.IsMouseOver;
                if (button.Expanded && !isOnMenu)
                    mouseOver = false;
                if (isOnMenu && button.Expanded && pa.ContainerControl != null && pa.ContainerControl.Parent != null)
                {
                    if (!pa.ContainerControl.Parent.Bounds.Contains(System.Windows.Forms.Control.MousePosition))
                        mouseOver = true;
                }

                if (button.HotTrackingStyle != eHotTrackingStyle.None)
                {
                    if (mouseOver || button.IsMouseDown && !button.DesignMode)
                        PaintButtonMouseOver(button, pa, image, mouseOverRect);
                }

                if (isOnMenu && button.IsOnCustomizeMenu && button.Visible && !button.SystemItem)
                    PaintCustomizeCheck(button, pa, customizeCheckRect);

                if (button.Checked && !button.IsOnCustomizeMenu && (button.GetEnabled(pa.ContainerControl) || isOnMenu))
                    PaintButtonCheck(button, pa, image, checkRect);

                if ((image != null || !string.IsNullOrEmpty(button.Symbol)) && button.ButtonStyle != eButtonStyle.TextOnlyAlways)
                    PaintButtonImage(button, pa, image, imageRect);

                if (!(button is ApplicationButton) || button.EffectiveStyle == eDotNetBarStyle.Office2010 || button.EffectiveStyle == eDotNetBarStyle.Metro)
                    PaintButtonText(button, pa, textColor, image);

                PaintExpandButton(button, pa);

                if (button.Focused && button.DesignMode)
                {
                    Rectangle r = itemRect;
                    r.Inflate(-1, -1);
                    DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
                }

                if (image != null)
                    image.Dispose();
            }
            finally
            {
                if (oldClip != null)
                {
                    g.Clip = oldClip;
                    oldClip.Dispose();
                }
                else
                    g.ResetClip();
            }
		}