protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
 {
     TabStrip toolStrip = e.ToolStrip as TabStrip;
     Tab item = e.Item as Tab;
     Rectangle rect = new Rectangle(0, 0, e.Item.Size.Width - 1, e.Item.Size.Height);
     if ((toolStrip != null) && (item != null))
     {
         if (item.Checked)
         {
             e.Graphics.FillRectangle(SystemBrushes.ButtonFace, rect);
             e.Graphics.DrawLine(SystemPens.ControlLightLight, rect.Left, rect.Top, rect.Left, rect.Bottom - 1);
             e.Graphics.DrawLine(SystemPens.ControlLightLight, rect.Left, rect.Top, rect.Right, rect.Top);
             e.Graphics.DrawLine(SystemPens.ControlDarkDark, rect.Right, rect.Top + 1, rect.Right, rect.Bottom - 1);
         }
         else if (item != toolStrip.GetNextTab(toolStrip.SelectedTab, false, false))
         {
             e.Graphics.DrawLine(SystemPens.ControlDark, rect.Right, rect.Top + 2, rect.Right, rect.Bottom - 3);
         }
     }
     else
     {
         if (e.Item.Selected || e.Item.Pressed)
         {
             e.Graphics.FillRectangle(SystemBrushes.ButtonFace, rect);
         }
         base.OnRenderButtonBackground(e);
     }
 }
 /// <summary>
 /// Disables menu item highlighting while mousing over 
 /// a menu item when the app doesn't have focus. 
 /// </summary>
 /// <param name="Args">The event holding the menu item to render.</param>
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs Args)
 {
     if ( AppHasFocus() )
     {
         base.OnRenderMenuItemBackground(Args);
     }
 }
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            Brush triangleBrush = new SolidBrush(Color.Black);
            Point2 itemCenter = new Point2(e.Item.Width / 2, e.Item.Height / 2);
            int triangleSize = 2;

            if (e.Item.Pressed)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(this.ColorTable.ButtonPressedHighlight),
                    1, 1, e.Item.Width - 2, e.Item.Height - 2);
                e.Graphics.DrawRectangle(
                    new Pen(this.ColorTable.ButtonPressedHighlightBorder),
                    1, 1, e.Item.Width - 3, e.Item.Height - 3);
            }
            else if (e.Item.Selected)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(this.ColorTable.ButtonSelectedHighlight),
                    1, 1, e.Item.Width - 2, e.Item.Height - 2);
                e.Graphics.DrawRectangle(
                    new Pen(this.ColorTable.ButtonSelectedHighlightBorder),
                    1, 1, e.Item.Width - 3, e.Item.Height - 3);
            }

            e.Graphics.FillPolygon(triangleBrush, new Point[] {
                new Point(itemCenter.X - triangleSize, (e.Item.Height * 3 / 4) - triangleSize),
                new Point(itemCenter.X + triangleSize + 1, (e.Item.Height * 3 / 4) - triangleSize),
                new Point(itemCenter.X, (e.Item.Height * 3 / 4) + (triangleSize / 2))});
        }
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            if (e.Item.Selected)
            {
                Graphics g = e.Graphics;
                g.SmoothingMode = SmoothingMode.HighQuality;
                GraphicsPath pa = new GraphicsPath();
                Rectangle rect = new Rectangle(2, 1, (int)e.Item.Size.Width - 2, e.Item.Size.Height-1);
                DrawArc(rect, pa);
                LinearGradientBrush lgbrush = new LinearGradientBrush(rect, Color.White, Color.White, LinearGradientMode.Vertical);

                float[] pos = new float[4];
                pos[0] = 0.0F; pos[1] = 0.4F; pos[2] = 0.45F; pos[3] = 1.0F;
                Color[] colors = new Color[4];
                colors[0] = GetColor(0, 50, 100);
                colors[1] = GetColor(0, 0, 30);
                colors[2] = Color.FromArgb(R0, G0, B0);
                colors[3] = GetColor(0, 50, 100);

                ColorBlend mix = new ColorBlend();
                mix.Colors = colors;
                mix.Positions = pos;
                lgbrush.InterpolationColors = mix;
                g.FillPath(lgbrush, pa);
                g.DrawPath(new Pen(StrokeColor), pa);
                lgbrush.Dispose();
            }
            else
            {
                base.OnRenderItemBackground(e);
            }
        }
Esempio n. 5
0
            protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
            {
                base.OnRenderButtonBackground(e);
                if (e.Item.Selected || ((ToolStripButton)e.Item).Checked)
                {
                    var rectBorder = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                    var rect       = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height - 2);
                    var b          = new LinearGradientBrush(rect, ColorToolstripBtnGrad_White, ColorToolstripBtnGrad_Blue,
                                                             LinearGradientMode.Vertical);
                    var b2 = new SolidBrush(ColorToolstripBtn_Border);

                    e.Graphics.FillRectangle(b2, rectBorder);
                    e.Graphics.FillRectangle(b, rect);
                }

                if (e.Item.Pressed)
                {
                    var rectBorder = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                    var rect       = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height - 2);
                    var b          = new LinearGradientBrush(rect, ColorToolstripBtnGrad_White_Pressed, ColorToolstripBtnGrad_Blue_Pressed,
                                                             LinearGradientMode.Vertical);
                    var b2 = new SolidBrush(ColorToolstripBtn_Border);

                    e.Graphics.FillRectangle(b2, rectBorder);
                    e.Graphics.FillRectangle(b, rect);
                }
            }
Esempio n. 6
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderButtonBackground(e);

            var g = e.Graphics;

            var bounds = new Rectangle(Point.Empty, e.Item.Size);

            Color backColor = Color.White;

            var button = e.Item as ToolStripButton;
            // Check button is null value
            if (button == null) return;

            if (button.Pressed || button.Checked)
            {
                backColor = Color.FromArgb(0x4d, 0x4d, 0x4d);
            }
            else if (button.Selected)
            {
                backColor = Color.FromArgb(0xe6, 0xe6, 0xe6);
            }

            using (Brush b = new SolidBrush(backColor))
            {
                g.FillRectangle(b, bounds);
            }
        }
Esempio n. 7
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            if (e.Item.Enabled)
            {
                if (e.Item.Selected)
                {
                    //If item is selected
                    Rectangle Rect = new Rectangle(3, 2, e.Item.Width - 5, e.Item.Height - 3);
                    e.Graphics.FillRectangle(new SolidBrush(itemHover), Rect);
                }

                //If item is MenuHeader and menu is dropped down
                if (((ToolStripMenuItem)e.Item).DropDown.Visible && e.Item.IsOnDropDown == false)
                {
                    Rectangle Rect = new Rectangle(3, 2, e.Item.Width - 5, e.Item.Height - 3);
                    e.Graphics.FillRectangle(new SolidBrush(itemSelect), Rect);
                }

                e.Item.ForeColor = itemColor;
            }
            else
            {
                e.Item.ForeColor = bgColor1;
            }

            base.OnRenderMenuItemBackground(e);
        }
Esempio n. 8
0
 protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
 {
     // base.OnRenderSplitButtonBackground(e);
     ToolStripSplitButton item = e.Item as ToolStripSplitButton;
     if (null == item) return;
     e.Graphics.DrawLine(new Pen(Color.Red), item.Bounds.Location, new Point(item.Bounds.Location.X, item.Height));
 }
Esempio n. 9
0
		protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
		{
			if (!(e.Item.Selected))
			{
				base.OnRenderButtonBackground(e);
			}
		}
 /// <summary>
 /// Disables drop down button highlighting while mousing over 
 /// a drop down button when the app doesn't have focus. 
 /// </summary>
 /// <param name="Args">The event holding the drop down button to render.</param>
 protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs Args)
 {
     if ( AppHasFocus() )
     {
         base.OnRenderDropDownButtonBackground(Args);
     }
 }
Esempio n. 11
0
        protected override void OnRenderDropDownButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            Rectangle rect       = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
            bool      drawBorder = false;

            if (e.Item.Pressed)
            {
                drawBorder = true;
                using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
                {
                    e.Graphics.FillRectangle(b, rect);
                }
            }
            else if (e.Item.Selected)
            {
                drawBorder = true;
                RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, rect);
            }

            if (drawBorder)
            {
                using (Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder))
                {
                    e.Graphics.DrawRectangle(p, rect);
                }
            }
        }
Esempio n. 12
0
 /// <summary>  
 /// 渲染菜单项的背景  
 /// </summary>  
 /// <param name="e"></param>  
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.ToolStrip is MenuStrip)
     {
         //如果被选中或被按下
         if (e.Item.Selected || e.Item.Pressed)
         {
             Blend blend = new Blend();
             float[] fs = new float[5] { 0f, 0.3f, 0.5f, 0.8f, 1f };
             float[] f = new float[5] { 0f, 0.5f, 1f, 0.5f, 0f };
             blend.Positions = fs;
             blend.Factors = f;
             FillLineGradient(e.Graphics, new Rectangle(0, 0, e.Item.Size.Width, e.Item.Size.Height),
                 e.Item.Pressed ? colorconfig.DropDownItemBackColor : colorconfig.MenuItemStartColor,
                 e.Item.Pressed ? colorconfig.DropDownItemBackColor : colorconfig.MenuItemEndColor,
                 90f, blend);
         }
         else
             base.OnRenderMenuItemBackground(e);
     }
     else if (e.ToolStrip is ToolStripDropDown)
     {
         if (e.Item.Selected)
         {
             FillLineGradient(e.Graphics, new Rectangle(2, 2, e.Item.Size.Width-4, e.Item.Size.Height-4), colorconfig.DropDownItemStartColor, colorconfig.DropDownItemEndColor, 90f, null);
         }
     }
     else
     {
         base.OnRenderMenuItemBackground(e);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 渲染菜单项的背景
 /// </summary>
 /// <param name="e"></param>
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     e.Item.ForeColor = Color.White;
     if (e.ToolStrip is MenuStrip)
     {
         //如果被选中或被按下
         if (e.Item.Selected || e.Item.Pressed)
         {
             DrawArc(e.Graphics, new Rectangle(0, 0, e.Item.Size.Width, e.Item.Size.Height), Color.FromArgb(27, 27, 28));
         }
         else
         {
             base.OnRenderMenuItemBackground(e);
         }
     }
     else if (e.ToolStrip is ToolStripDropDown)
     {
         if (e.Item.Selected)
         {
             //FillLineGradient(e.Graphics, new Rectangle(0, 0, e.Item.Size.Width, e.Item.Size.Height), colorconfig.DropDownItemStartColor, colorconfig.DropDownItemEndColor, 90f, null);
             DrawArc(e.Graphics, new Rectangle(0, 0, e.Item.Size.Width, e.Item.Size.Height), Color.FromArgb(45, 45, 45));
         }
     }
     else
     {
         base.OnRenderMenuItemBackground(e);
     }
 }
Esempio n. 14
0
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item.Bounds.Contains(e.ToolStrip.PointToClient(Cursor.Position)))
         e.Graphics.FillRectangle(buttonHover, new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height));
     else
         e.Graphics.FillRectangle(buttonBack, new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height));
 }
Esempio n. 15
0
 protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item is ToolStripButton)
     {
         ToolStripButton button = (ToolStripButton) e.Item;
         SolidBrush solidBrush;
         if (button.Pressed || button.Checked)
         {
             solidBrush = new SolidBrush(Color.FromArgb(193, 210, 238));
         }
         else if (button.Selected)
         {
             solidBrush = new SolidBrush(Color.FromArgb(224, 232, 246));
         }
         else
         {
             base.OnRenderButtonBackground(e);
             return;
         }
         e.Graphics.FillRectangle(solidBrush, 0, 0, e.Item.Width, e.Item.Height);
     }
     else
     {
         base.OnRenderButtonBackground(e);
     }
 }
		protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
		{
			var g = e.Graphics;
			g.Clear(SkinManager.PrimaryColor);

			//Draw background
			var itemRect = GetItemRect(e.Item);
			if (e.Item.IsOnDropDown)
			{
				g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.GetCmsSelectedItemBrush() : new SolidBrush(SkinManager.GetApplicationBackgroundColor()), itemRect);
			}
			else
			{
				g.FillRectangle(e.Item.Selected ? SkinManager.GetFlatButtonPressedBackgroundBrush() : SkinManager.PrimaryColorBrush, itemRect);
			}

			//Ripple animation
			var toolStrip = e.ToolStrip as MaterialContextMenuStrip;
			if (toolStrip != null)
			{
				var animationManager = toolStrip.animationManager;
				var animationSource = toolStrip.animationSource;
				if (toolStrip.animationManager.IsAnimating() && e.Item.Bounds.Contains(animationSource))
				{
					for (int i = 0; i < animationManager.GetAnimationCount(); i++)
					{
						var animationValue = animationManager.GetProgress(i);
						var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.Black));
						var rippleSize = (int)(animationValue * itemRect.Width * 2.5);
						g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, itemRect.Y - itemRect.Height, rippleSize, itemRect.Height * 3));
					}
				}
			}
		}
Esempio n. 17
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            TabStrip tabStrip = e.ToolStrip as TabStrip;
            ToolStripButton button = e.Item as ToolStripButton;
            Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size);

            if (tabStrip != null) {
                System.Windows.Forms.VisualStyles.TabItemState tabState = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                if (button.Checked) {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Selected;
                }
                if (button.Selected) {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Hot;
                }

                TabRenderer.DrawTabItem(e.Graphics, bounds, tabState);

                if (button.Checked) {
                    VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Hot);
                    Padding borderPadding = button.Padding;
                    borderPadding.Top += 4;
                    borderPadding.Bottom += 2;
                    borderPadding.Left -= 2;
                    borderPadding.Right -= 2;
                    Rectangle rect = LayoutUtils.DeflateRect(bounds, borderPadding);

                    ControlPaint.DrawFocusRectangle(e.Graphics, rect);
                }
            }
            else {
                base.OnRenderButtonBackground(e);
            }
        }
 protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
 {
     if (renderer is ToolStripProfessionalRenderer)
     {
         Color back = PluginBase.MainForm.GetThemeColor("ToolStripItem.BackColor");
         Color border = PluginBase.MainForm.GetThemeColor("ToolStripItem.BorderColor");
         if (e.Item.Selected || ((ToolStripButton)e.Item).Checked)
         {
             Rectangle rect = new Rectangle(0, 0, e.Item.Width, e.Item.Height);
             Rectangle rect2 = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height - 2);
             LinearGradientBrush b = new LinearGradientBrush(rect, back == Color.Empty ? DockDrawHelper.ColorSelectedBG_White : back, back == Color.Empty ? DockDrawHelper.ColorSelectedBG_Blue : back, LinearGradientMode.Vertical);
             e.Graphics.FillRectangle(b, rect);
             Rectangle rect3 = new Rectangle(rect2.Left - 1, rect2.Top - 1, rect2.Width + 1, rect2.Height + 1);
             Rectangle rect4 = new Rectangle(rect3.Left + 1, rect3.Top + 1, rect3.Width - 2, rect3.Height - 2);
             e.Graphics.DrawRectangle(new Pen(border == Color.Empty ? DockDrawHelper.ColorSelectedBG_Border : border), rect3);
             e.Graphics.DrawRectangle(new Pen(back == Color.Empty ? DockDrawHelper.ColorSelectedBG_White : back), rect4);
         }
         if (e.Item.Pressed)
         {
             Rectangle rect = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height - 2);
             LinearGradientBrush b = new LinearGradientBrush(rect, back == Color.Empty ? DockDrawHelper.ColorSelectedBG_White : back, back == Color.Empty ? DockDrawHelper.ColorSelectedBG_Blue : back, LinearGradientMode.Vertical);
             e.Graphics.FillRectangle(b, rect);
             Rectangle rect2 = new Rectangle(rect.Left - 1, rect.Top - 1, rect.Width + 1, rect.Height + 1);
             e.Graphics.DrawRectangle(new Pen(border == Color.Empty ? DockDrawHelper.ColorSelectedBG_Border : border), rect2);
         }
     }
     else renderer.DrawButtonBackground(e);
 }
Esempio n. 19
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem tsi = ((e != null) ? e.Item : null);

            if((tsi != null) && ((tsi.Owner is ContextMenuStrip) ||
                (tsi.OwnerItem != null)) && tsi.Selected)
            {
                Rectangle rect = tsi.ContentRectangle;
                rect.Offset(0, -1);
                rect.Height += 1;

                Color clrStart = KeePassTsrColorTable.StartGradient(this.ColorTable.MenuItemSelected);
                Color clrEnd = KeePassTsrColorTable.EndGradient(this.ColorTable.MenuItemSelected);
                Color clrBorder = this.ColorTable.MenuItemBorder;

                if(!tsi.Enabled)
                {
                    Color clrBase = this.ColorTable.MenuStripGradientEnd;
                    clrStart = UIUtil.ColorTowardsGrayscale(clrStart, clrBase, 0.5);
                    clrEnd = UIUtil.ColorTowardsGrayscale(clrEnd, clrBase, 0.2);
                    clrBorder = UIUtil.ColorTowardsGrayscale(clrBorder, clrBase, 0.2);
                }

                Graphics g = e.Graphics;
                if(g != null)
                {
                    LinearGradientBrush br = new LinearGradientBrush(rect,
                        clrStart, clrEnd, LinearGradientMode.Vertical);
                    Pen p = new Pen(clrBorder);

                    SmoothingMode smOrg = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.HighQuality;

                    GraphicsPath gp = UIUtil.CreateRoundedRectangle(rect.X, rect.Y,
                        rect.Width, rect.Height, DpiUtil.ScaleIntY(2));
                    if(gp != null)
                    {
                        g.FillPath(br, gp);
                        g.DrawPath(p, gp);

                        gp.Dispose();
                    }
                    else // Shouldn't ever happen...
                    {
                        Debug.Assert(false);
                        g.FillRectangle(br, rect);
                        g.DrawRectangle(p, rect);
                    }

                    g.SmoothingMode = smOrg;

                    p.Dispose();
                    br.Dispose();
                    return;
                }
                else { Debug.Assert(false); }
            }

            base.OnRenderMenuItemBackground(e);
        }
Esempio n. 20
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem tsi = ((e != null) ? e.Item : null);

            if((tsi != null) && ((tsi.Owner is ContextMenuStrip) ||
                (tsi.OwnerItem != null)) && tsi.Selected && !tsi.Enabled)
            {
                Rectangle rect = tsi.ContentRectangle;
                rect.Offset(0, -1);
                rect.Height += 1;

                // In image area (228, 228, 228), in text area (230, 230, 230)
                Color clrBack = Color.FromArgb(229, 229, 229);
                Color clrBorder = Color.FromArgb(229, 229, 229);

                SolidBrush br = new SolidBrush(clrBack);
                Pen p = new Pen(clrBorder);

                Graphics g = e.Graphics;
                if(g != null)
                {
                    g.FillRectangle(br, rect);
                    g.DrawRectangle(p, rect);
                }
                else { Debug.Assert(false); }

                p.Dispose();
                br.Dispose();
            }
            else base.OnRenderMenuItemBackground(e);
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderButtonBackground(e);

            var button = (NavigationButton)e.Item;
            if (button == null)
                return;

            var gradTop = ColorTable.ToolStripPanelGradientBegin;
            var gradBottom = ColorTable.ToolStripPanelGradientBegin;

            if (button.Pressed || button.Checked)
            {
                gradTop = NavigationColourTable.CHECKED_GRADIENT_BEGIN;
                gradBottom = NavigationColourTable.CHECKED_GRADIENT_END;
            }
            else if (button.Selected)//hover
            {
                gradTop = NavigationColourTable.HOVER_GRADIENT_BEGIN;
                gradBottom = NavigationColourTable.HOVER_GRADIENT_END;
            }

            var bounds = new Rectangle(Point.Empty, e.Item.Size);
            var g = e.Graphics;

            DrawItemBackGround(g, bounds, gradTop, gradBottom);

            if (button.Pressed || button.Checked || button.Selected)
                DrawItemBorder(g, bounds);
        }
Esempio n. 22
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderButtonBackground(e);

            ToolStripButton button = e.Item as ToolStripButton;

            if (null != button)
            {
                if (button.Checked)
                {
                    SolidBrush brush = new SolidBrush(_darkHeaderColor);
                    Pen pen = new Pen(_separatorColor);

                    e.Graphics.FillRectangle(brush, 0, 0, button.Width - 1, button.Height - 1);
                    e.Graphics.DrawRectangle(pen, 0, 0, button.Width - 1, button.Height - 1);
                }
                else if (button.Selected)
                {
                    SolidBrush brush = new SolidBrush(_lightHeaderColor);
                    Pen pen = new Pen(_separatorColor);

                    e.Graphics.FillRectangle(brush, 0, 0, button.Width - 1, button.Height - 1);
                    e.Graphics.DrawRectangle(pen, 0, 0, button.Width - 1, button.Height - 1);
                }
            }
        }
Esempio n. 23
0
        protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            // check if the object being rendered is actually a ToolStripButton
            if (e.Item is System.Windows.Forms.ToolStripButton)
            {
                System.Windows.Forms.ToolStripButton button = e.Item as System.Windows.Forms.ToolStripButton;

                // only render checked items differently
                if (button.Checked)
                {
                    // fill the entire button with a color (will be used as a border)
                    int buttonHeight = button.Size.Height;
                    int buttonWidth  = button.Size.Width;
                    System.Drawing.Rectangle rectButtonFill = new System.Drawing.Rectangle(System.Drawing.Point.Empty, new Size(buttonWidth, buttonHeight));
                    e.Graphics.FillRectangle(_border, rectButtonFill);

                    // fill the entire button offset by 1,1 and height/width subtracted by 2 used as the fill color
                    int backgroundHeight = button.Size.Height - 2;
                    int backgroundWidth  = button.Size.Width - 2;
                    System.Drawing.Rectangle rectBackground = new System.Drawing.Rectangle(1, 1, backgroundWidth, backgroundHeight);
                    e.Graphics.FillRectangle(_checkedBackground, rectBackground);
                }
                // if this button is not checked, use the normal render event
                else
                {
                    base.OnRenderButtonBackground(e);
                }
            }
            // if this object is not a ToolStripButton, use the normal render event
            else
            {
                base.OnRenderButtonBackground(e);
            }
        }
Esempio n. 24
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            //base.OnRenderButtonBackground(e);
            ToolStripButton item = e.Item as ToolStripButton;
            Graphics g = e.Graphics;
            Rectangle bounds = new Rectangle(Point.Empty, item.Size);

            if (item.CheckState == CheckState.Checked)
            {
                RenderCheckedButtonFill(bounds, item, g);
            }
            else
            {
                if (item.Selected)
                {
                    RenderSelectedButtonFill(bounds, g);
                }
                else
                {
                    Color fillColor = ThemeColorTable.BackgroundColor;
                    using (Brush b = new SolidBrush(fillColor))
                    {
                        g.FillRectangle(b, bounds);
                    }
                }

            }
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            GraphicsPath gp;
            Rectangle b = e.Item.Bounds;

            b.X = 0;

            b.Width--;
            b.Height -= (e.Item.Margin.Top * 2) + 1;

            if (e.Item.Pressed)
            {
                gp = CreateRoundedRectanglePath(b, 3);
                e.Graphics.DrawPath(new Pen(Color.FromArgb(200, Color.Black), 1), gp);

                Color c1 = Color.FromArgb(OpacityCalc(100), Color.Black);
                Color c2 = Color.FromArgb(OpacityCalc(30), Color.Black);

                ColorBlend cb = new ColorBlend();

                cb.Colors = new Color[] { c1, c2, Color.FromArgb(0, Color.Black) };
                cb.Positions = new Single[] { 0.0f, 0.1f, 1.0f };

                LinearGradientBrush lgb;

                lgb = new LinearGradientBrush(b, c1, c2, LinearGradientMode.Vertical);
                lgb.InterpolationColors = cb;

                e.Graphics.FillPath(lgb, gp);
                lgb.Dispose();

                lgb = new LinearGradientBrush(b, c1, c2, LinearGradientMode.Horizontal);
                lgb.InterpolationColors = cb;

                e.Graphics.FillPath(lgb, gp);
                lgb.Dispose();
            }
            else if (e.Item.Selected)
            {
                Pen pen = new Pen(Color.FromArgb(200, Color.Black), 1f);

                gp = CreateRoundedRectanglePath(b, 3);
                e.Graphics.DrawPath(pen, gp);

                gp.Dispose();

                b.X++; b.Y++;

                b.Width -= 2;
                b.Height -= 2;

                pen.Color = Color.FromArgb(200, Color.DarkBlue);

                gp = CreateRoundedRectanglePath(b, 3);
                e.Graphics.DrawPath(pen, gp);

                pen.Dispose(); gp.Dispose();
            }
        }
		/// <summary></summary>
		protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e)
		{
			base.OnRenderItemBackground(e);

			string currentTabName = "";
			string currentItemName = "";
			if (null != m_aggregatingSidebar.CurrentTabProperties)
				currentTabName = m_aggregatingSidebar.CurrentTabProperties.Name;
			if (null != m_aggregatingSidebar.CurrentTabItemProperties)
				currentItemName = m_aggregatingSidebar.CurrentTabItemProperties.Name;
			string currentTabButtonName = currentTabName + "_category_button";
			string currentItemButtonName = currentItemName + "_button";

			bool isCurrent = e.Item.Name == currentTabButtonName || e.Item.Name == currentItemButtonName; // is current item or tab, else is normal
			bool isCatTab = e.ToolStrip.Name.Equals("sidebarCategoryArea"); // if is category tab, else is an item
			bool isDepressed = e.Item.Pressed; // Is mouse down
			bool isHover = e.Item.Selected; // Is mouse over

			Color? topColor = null;
			Color? bottomColor = null;

			if (!isCurrent && isCatTab)
			{
				topColor = normalTab_buttonColor_top;
				bottomColor = normalTab_buttonColor_bottom;
			}
			if (!isCurrent && !isCatTab)
			{
				// Don't draw anything special for normal item buttons
				topColor = null;
				bottomColor = null;
			}
			if (isCurrent)
			{
				topColor = currentItem_buttonColor_top;
				bottomColor = currentItem_buttonColor_bottom;
			}
			if (isHover)
			{
				topColor = normalAndPointedItem_buttonColor_top;
				bottomColor = normalAndPointedItem_buttonColor_bottom;
			}
			if (isCurrent && isHover)
			{
				topColor = currentAndPointedItem_buttonColor_top;
				bottomColor = currentAndPointedItem_buttonColor_bottom;
			}
			if (isDepressed)
			{
				topColor = normalPressedItem_buttonColor_top;
				bottomColor = normalPressedItem_buttonColor_bottom;
			}

			if (null != topColor && null != bottomColor)
			{
				Brush brush = new LinearGradientBrush((Rectangle)e.Item.ContentRectangle, (Color)topColor, (Color)bottomColor, 90, true);
				e.Graphics.FillRectangle(brush, (Rectangle)e.Item.ContentRectangle);
			}
		}
Esempio n. 27
0
        protected override void OnRenderLabelBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            base.OnRenderLabelBackground(e);

            RenderBackground(e);

            drawText(e, e.Graphics);
        }
Esempio n. 28
0
        protected new void DrawButtonBackground(ToolStripItemRenderEventArgs e)
        {
            bool chk = false;
            if (e.Item is ToolStripButton)
                chk = (e.Item as ToolStripButton).Checked;

            DrawButtonBackground(e.Graphics, new Rectangle(Point.Empty, e.Item.Size), e.Item.Selected, e.Item.Pressed, chk);
        }
Esempio n. 29
0
			protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) {
				GraphicsHelper helper = new GraphicsHelper(e.Graphics);
				ToolStripButton button = e.Item as ToolStripButton;
				Rectangle bounds = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);

				if (e.Item.Selected) {
					helper.RoundedGradient(UColor.Rgb(0x06, 0x88, 0xB8), UColor.Rgb(0x06, 0x88, 0xB8), bounds, 90, 2);
				}
			}
        protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            if (e.Item.DisplayStyle == ToolStripItemDisplayStyle.Image)
            {
                // Do not paint a background for icon only buttons
                return;
            }

            if (this.inactiveTabBkg == null)
            {
                this.inactiveTabBkg = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.Control, SystemColors.ControlDark);
                this.hoverTabBkg    = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.ControlLight, SystemColors.Control);
                this.pressedTabBkg  = new SolidBrush(SystemColors.ControlLight);
            }

            using (LinearGradientBrush activeTabBkg = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Item.Height), SystemColors.ControlLight, this.GetActiveTabBtmCol(e.ToolStrip, e.Item)))
            {
                ToolStripButton button = (ToolStripButton)e.Item;
                Brush           colour = this.inactiveTabBkg;

                if (button.Checked)
                {
                    colour = activeTabBkg;

                    // Invalidate between the buttons and the bottom of the toolstrip so that it gets repainted
                    e.ToolStrip.Invalidate(new Rectangle(0, e.Item.Bounds.Bottom, e.ToolStrip.Bounds.Width, e.ToolStrip.Bounds.Height - e.Item.Bounds.Bottom));
                }
                else if (e.Item.Selected)
                {
                    if (e.Item.Pressed)
                    {
                        colour = this.pressedTabBkg;
                    }
                    else
                    {
                        colour = this.hoverTabBkg;
                    }
                }

                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                int width  = e.Item.Width - TabSeparation;
                int height = e.Item.Height;

                using (GraphicsPath tab = new GraphicsPath())
                {
                    tab.AddLine(0, height, 0, CurveSize);
                    tab.AddArc(0, 0, CurveSize, CurveSize, 180, 90);
                    tab.AddLine(CurveSize, 0, width - CurveSize, 0);
                    tab.AddArc(width - CurveSize, 0, CurveSize, CurveSize, 270, 90);
                    tab.AddLine(width, CurveSize, width, height);

                    e.Graphics.FillPath(colour, tab);
                    e.Graphics.DrawPath(this.tabBorder, tab);
                }
            }
        }
Esempio n. 31
0
 protected override void OnRenderSplitButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
 {
     if (currentRenderer != null)
     {
         currentRenderer.DrawSplitButton(e);
         return;
     }
     base.OnRenderSplitButtonBackground(e);
 }
Esempio n. 32
0
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) {
     if((e.Item.BackColor != e.ToolStrip.BackColor) && !e.Item.Selected) {
         using(SolidBrush brush = new SolidBrush(e.Item.BackColor)) {
             e.Graphics.FillRectangle(brush, new Rectangle(Point.Empty, e.Item.Size));
             return;
         }
     }
     e.Graphics.FillRectangle(e.Item.Selected ? SystemBrushes.MenuHighlight : SystemBrushes.Menu, new Rectangle(Point.Empty, e.Item.Size));
 }
Esempio n. 33
0
 protected override void OnRenderToolStripStatusLabelBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
 {
     if (currentRenderer != null)
     {
         currentRenderer.DrawToolStripStatusLabelBackground(e);
         return;
     }
     base.OnRenderToolStripStatusLabelBackground(e);
 }
Esempio n. 34
0
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item.Selected)
     {
         var g = e.Graphics;
         var rect = new Rectangle(1, 1, e.Item.Bounds.Width - 2, e.Item.Bounds.Height);
         g.FillRectangle(Brushes.LightGray, rect);
     }
 }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripButton button = e.Item as ToolStripButton;
            if (button != null && button.Enabled)
            {
                if (button.Selected || button.Checked)
                {
                    // Rect of item's content area.
                    Rectangle contentRect = new Rectangle(0, 0, button.Width - 1, button.Height - 1);

                    Color pen;
                    Color brushBegin;
                    Color brushMiddle;
                    Color brushEnd;

                    if (button.Checked)
                    {
                        if (button.Selected)
                        {
                            pen = _table.ButtonCheckedHoveredBorder;
                            brushBegin = _table.ButtonCheckedHoveredBackground;
                            brushMiddle = _table.ButtonCheckedHoveredBackground;
                            brushEnd = _table.ButtonCheckedHoveredBackground;
                        }
                        else
                        {
                            pen = _table.ButtonCheckedBorder;
                            brushBegin = ColorTable.ButtonCheckedGradientBegin;
                            brushMiddle = ColorTable.ButtonCheckedGradientMiddle;
                            brushEnd = ColorTable.ButtonCheckedGradientEnd;
                        }
                    }
                    else if (button.Pressed)
                    {
                        pen = ColorTable.ButtonPressedBorder;
                        brushBegin = ColorTable.ButtonPressedGradientBegin;
                        brushMiddle = ColorTable.ButtonPressedGradientMiddle;
                        brushEnd = ColorTable.ButtonPressedGradientEnd;
                    }
                    else
                    {
                        pen = ColorTable.ButtonSelectedBorder;
                        brushBegin = ColorTable.ButtonSelectedGradientBegin;
                        brushMiddle = ColorTable.ButtonSelectedGradientMiddle;
                        brushEnd = ColorTable.ButtonSelectedGradientEnd;
                    }

                    DrawRectangle(e.Graphics, contentRect,
                        brushBegin, brushMiddle, brushEnd, pen, false);
                }
            }
            else
            {
                base.OnRenderButtonBackground(e);
            }
        }
Esempio n. 36
0
 protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
 {
     if (!e.Item.Selected)
         base.OnRenderButtonBackground(e);
     else
     {
         Rectangle rectangle = new Rectangle(0, 0, e.Item.Size.Width - 1, e.Item.Size.Height - 1);
         e.Graphics.DrawRectangle(Pens.LightGray, rectangle);
     }
 }
Esempio n. 37
0
 protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item.Selected)
     {
         e.Graphics.FillRectangle(hoverBrush, new Rectangle(new Point(0, 0), e.Item.Size));
         e.Graphics.DrawRectangle(highlightPen, new Rectangle(0, 0, e.Item.Width-1, e.Item.Height-1));
     }
     else
         e.Graphics.FillRectangle(normalBrush, new Rectangle(new Point(0, 0), e.Item.Size));
 }
Esempio n. 38
0
        protected override void OnRenderOverflowButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            Rectangle rect    = default(Rectangle);
            Rectangle rectEnd = default(Rectangle);

            rect    = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 2);
            rectEnd = new Rectangle(rect.X - 5, rect.Y, rect.Width - 5, rect.Height);

            if (e.Item.Pressed)
            {
                using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
                {
                    e.Graphics.FillRectangle(b, rect);
                }
            }
            else if (e.Item.Selected)
            {
                RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, rect);
            }
            else
            {
                using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.OverflowBackground))
                {
                    e.Graphics.FillRectangle(b, rect);
                }
            }

            using (Pen P1 = new Pen(this.ColorTable.CommonColorTable.Background))
            {
                RectDrawing.DrawRoundedRectangle(e.Graphics, P1, System.Convert.ToSingle(rectEnd.X), System.Convert.ToSingle(rectEnd.Y), System.Convert.ToSingle(rectEnd.Width), System.Convert.ToSingle(rectEnd.Height), 3);
            }


            // Icon
            int        w              = System.Convert.ToInt32(rect.Width - 1);
            int        h              = System.Convert.ToInt32(rect.Height - 1);
            float      triangleWidth  = w / 2.0F + 1;
            float      triangleLeft   = System.Convert.ToSingle(rect.Left + (w - triangleWidth) / 2.0F + 3);
            float      triangleHeight = triangleWidth / 2.0F;
            float      triangleTop    = System.Convert.ToSingle(rect.Top + (h - triangleHeight) / 2.0F + 7);
            RectangleF arrowRect      = new RectangleF(triangleLeft, triangleTop, triangleWidth, triangleHeight);

            this.DrawCustomArrow(e.Graphics, e.Item, Rectangle.Round(arrowRect));

            using (Pen p = new Pen(this.ColorTable.CommonColorTable.Arrow))
            {
                e.Graphics.DrawLine(p, triangleLeft + 2, triangleTop - 2, triangleLeft + triangleWidth - 2, triangleTop - 2);
            }
        }
Esempio n. 39
0
        protected override void OnRenderSplitButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            base.OnRenderSplitButtonBackground(e);

            bool drawBorder    = false;
            bool drawSeparator = true;

            var item = (ToolStripSplitButton)e.Item;

            Rectangle btnRect    = new Rectangle(0, 0, item.ButtonBounds.Width - 1, item.ButtonBounds.Height - 1);
            Rectangle borderRect = new Rectangle(0, 0, item.Bounds.Width - 1, item.Bounds.Height - 1);

            if (item.DropDownButtonPressed)
            {
                drawBorder    = true;
                drawSeparator = false;
                using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
                {
                    e.Graphics.FillRectangle(b, borderRect);
                }
            }
            else if (item.DropDownButtonSelected)
            {
                drawBorder = true;
                RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, borderRect);
            }

            if (item.ButtonPressed)
            {
                using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
                {
                    e.Graphics.FillRectangle(b, btnRect);
                }
            }

            if (drawBorder)
            {
                using (Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder))
                {
                    e.Graphics.DrawRectangle(p, borderRect);
                    if (drawSeparator)
                    {
                        e.Graphics.DrawRectangle(p, btnRect);
                    }
                }

                this.DrawCustomArrow(e.Graphics, item);
            }
        }
Esempio n. 40
0
        private void RenderBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            //IF ITEM IS SELECTED OR CHECKED
            if (e.Item.Selected | ((ToolStripButton)e.Item).Checked)
            {
                RenderItemBackgroundSelected(e);
            }

            //IF ITEM IS PRESSED
            if (e.Item.Pressed)
            {
                RenderItemBackgroundPressed(e);
            }

            //DEFAULT BACKGROUND
            if (e.Item.Selected == false & e.Item.Pressed == false & ((ToolStripButton)e.Item).Checked == false)
            {
                RenderItemBackground(e);
            }
        }
Esempio n. 41
0
            protected override void OnRenderMenuItemBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
            {
                base.OnRenderMenuItemBackground(e);

                if (e.Item.Enabled)
                {
                    if (!e.Item.IsOnDropDown && e.Item.Selected)
                    {
                        var rect = new Rectangle(3, 2, e.Item.Width - 6, e.Item.Height - 4);
                        var b    = new LinearGradientBrush(rect, ColorSelectedBG_White, ColorSelectedBG_Header_Blue, LinearGradientMode.Vertical);
                        var b2   = new SolidBrush(ColorToolstripBtn_Border);

                        e.Graphics.FillRectangle(b, rect);
                        DrawRoundedRectangle(e.Graphics, rect.Left - 1, rect.Top - 1, rect.Width, rect.Height + 1, 4, ColorToolstripBtn_Border);
                        DrawRoundedRectangle(e.Graphics, rect.Left - 2, rect.Top - 2, rect.Width + 2, rect.Height + 3, 4, Color.White);
                        e.Item.ForeColor = Color.Black;
                    }
                    else if (e.Item.IsOnDropDown && e.Item.Selected)
                    {
                        var rect = new Rectangle(4, 2, e.Item.Width - 6, e.Item.Height - 4);
                        var b    = new LinearGradientBrush(rect, ColorSelectedBG_White, ColorSelectedBG_Blue, LinearGradientMode.Vertical);
                        var b2   = new SolidBrush(ColorSelectedBG_Border);

                        e.Graphics.FillRectangle(b, rect);
                        DrawRoundedRectangle(e.Graphics, rect.Left - 1, rect.Top - 1, rect.Width, rect.Height + 1, 6, ColorSelectedBG_Border);
                        e.Item.ForeColor = Color.Black;
                    }

                    if (((ToolStripMenuItem)e.Item).DropDown.Visible && !e.Item.IsOnDropDown)
                    {
                        var rect = new Rectangle(3, 2, e.Item.Width - 6, e.Item.Height - 4);
                        var b    = new LinearGradientBrush(rect, Color.White, ColorSelectedBG_Drop_Blue, LinearGradientMode.Vertical);
                        var b2   = new SolidBrush(ColorSelectedBG_Drop_Border);

                        e.Graphics.FillRectangle(b, rect);
                        DrawRoundedRectangle(e.Graphics, rect.Left - 1, rect.Top - 1, rect.Width, rect.Height + 1, 4, ColorSelectedBG_Drop_Border);
                        DrawRoundedRectangle(e.Graphics, rect.Left - 2, rect.Top - 2, rect.Width + 2, rect.Height + 3, 4, Color.White);
                        e.Item.ForeColor = Color.Black;
                    }
                }
            }
Esempio n. 42
0
        private void RenderItemBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            if (Theme.ThemeStyle == RibbonOrbStyle.Office_2013)
            {
                Rectangle rect = new Rectangle(0, 0, e.Item.Width, e.Item.Height);

                using (SolidBrush b = new SolidBrush(Theme.ColorTable.RibbonBackground_2013))
                {
                    e.Graphics.FillRectangle(b, rect);
                }
            }
            else
            {
                Rectangle rect = new Rectangle(0, 0, e.Item.Width, e.Item.Height);

                using (SolidBrush b2 = new SolidBrush(Theme.ColorTable.RibbonBackground))
                {
                    e.Graphics.FillRectangle(b2, rect);
                }
            }
        }
Esempio n. 43
0
        protected override void OnRenderMenuItemBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            if (e.Item.Enabled)
            {
                if (e.Item.Selected)
                {
                    if (!e.Item.IsOnDropDown)
                    {
                        Rectangle SelRect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                        RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, SelRect);
                    }
                    else
                    {
                        Rectangle SelRect = new Rectangle(2, 0, e.Item.Width - 4, e.Item.Height - 1);
                        RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, SelRect);
                    }
                }

                if (((ToolStripMenuItem)e.Item).DropDown.Visible && !e.Item.IsOnDropDown)
                {
                    Rectangle BorderRect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height);
                    // Fill the background
                    Rectangle BackgroundRect = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height + 2);
                    using (SolidBrush B1 = new SolidBrush(this.ColorTable.DroppedDownItemBackground))
                    {
                        e.Graphics.FillRectangle(B1, BackgroundRect);
                    }


                    // Draw border
                    using (Pen P1 = new Pen(this.ColorTable.CommonColorTable.DropdownBorder))
                    {
                        RectDrawing.DrawRoundedRectangle(e.Graphics, P1, System.Convert.ToSingle(BorderRect.X), System.Convert.ToSingle(BorderRect.Y), System.Convert.ToSingle(BorderRect.Width), System.Convert.ToSingle(BorderRect.Height), 2);
                    }
                }
                e.Item.ForeColor = this.ColorTable.CommonColorTable.TextColor;
            }
        }
Esempio n. 44
0
            protected override void OnRenderMenuItemBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
            {
                if ((e.Item.Selected))
                {
                    e.Item.ForeColor = Color.Black;
                    Color highlight = default(Color);
                    if ((Theme.B > Theme.R && Theme.B > Theme.G))
                    {
                        highlight = ColorTranslator.FromHtml("#FFC580");
                    }
                    else if ((Theme.G > Theme.R && Theme.G > Theme.B))
                    {
                        highlight = ColorTranslator.FromHtml("#FFFB80");
                    }
                    else
                    {
                        //"#D4EBFF")
                        highlight = ColorTranslator.FromHtml("#A1C8FF");
                    }

                    using (LinearGradientBrush B = new LinearGradientBrush(new Rectangle(e.Item.ContentRectangle.Left, e.Item.ContentRectangle.Top, e.Item.ContentRectangle.Width / 2, e.Item.ContentRectangle.Height), Color.FromArgb(150, highlight), AddColor(highlight, 200), LinearGradientMode.Horizontal))
                    {
                        B.WrapMode = WrapMode.TileFlipXY;
                        e.Graphics.FillRectangle(B, e.Item.ContentRectangle);
                    }

                    using (Pen P = new Pen(AddColor(highlight, -25)))
                    {
                        e.Graphics.DrawRectangle(P, e.Item.ContentRectangle.Left, e.Item.ContentRectangle.Top, e.Item.ContentRectangle.Width - 1, e.Item.ContentRectangle.Height - 1);
                    }
                }
                else
                {
                    e.Item.ForeColor = e.ToolStrip.ForeColor;
                    base.OnRenderMenuItemBackground(e);
                }
            }
Esempio n. 45
0
        private void DrawText(ToolStripItemRenderEventArgs e, Graphics graphics)
        {
            try
            {
                Font font = e.Item.Font;

                if (Theme.Standard.Style == RibbonOrbStyle.Office_2013)
                {
                    if (e.Item.Text != string.Empty)
                    {
                        if (e.Item.Enabled)
                        {
                            var button = e.Item as ToolStripButton;
                            if (button != null)
                            {
                                if (button.Checked)
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemTextSelected_2013;
                                }
                                else if (button.Selected || button.Pressed)
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemTextPressed_2013;
                                }
                                else
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemText_2013;
                                }
                            }
                            else if (e.Item is ToolStripLabel)
                            {
                                e.Item.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemText_2013;
                            }
                        }
                        else
                        {
                            if (e.Item.ForeColor != Color.DarkGray)
                            {
                                e.Item.ForeColor = Color.DarkGray;
                            }
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(e.Item.Text))
                    {
                        if (e.Item.Enabled)
                        {
                            var button = e.Item as ToolStripButton;
                            if (button != null)
                            {
                                if (button.Checked)
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemTextSelected;
                                }
                                else if (button.Selected || button.Pressed)
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemTextPressed;
                                }
                                else
                                {
                                    button.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemText;
                                }
                            }
                            else
                            {
                                e.Item.ForeColor = Theme.Standard.RendererColorTable.ToolStripItemText;
                            }
                        }
                        else
                        {
                            if (e.Item.ForeColor != Color.DarkGray)
                            {
                                e.Item.ForeColor = Color.DarkGray;
                            }
                        }
                    }
                }

                if (e.Item is ToolStripButton | e.Item is ToolStripMenuItem | e.Item is ToolStripDropDownButton | e.Item is ToolStripLabel)
                {
                    switch (e.Item.DisplayStyle)
                    {
                    case ToolStripItemDisplayStyle.Image:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(e.Item.Image.Height + 2, e.Item.Image.Width + 2);
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(e.Item.Image.Width + 2, e.Item.Image.Height + 2);
                            }
                        }
                        break;

                    case ToolStripItemDisplayStyle.ImageAndText:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + e.Item.Image.Height + 10), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8));
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + e.Item.Image.Width + 10), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8));
                            }
                        }

                        e.Item.ImageAlign = ContentAlignment.MiddleLeft;
                        e.Item.TextAlign  = ContentAlignment.MiddleRight;
                        break;

                    case ToolStripItemDisplayStyle.None:
                        break;

                    case ToolStripItemDisplayStyle.Text:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8));
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8));
                            }
                        }
                        break;
                    }
                }
                else if (e.Item is ToolStripSeparator)
                {
                }
                else if (e.Item is ToolStripTextBox)
                {
                }
            }
            catch
            {
            }
        }
 private void RenderItemInternalFilled(ToolStripItemRenderEventArgs e)
 {
     RenderItemInternalFilled(e, /*pressFill=*/ true);
 }
 protected override void OnRenderLabelBackground(ToolStripItemRenderEventArgs e)
 {
     base.OnRenderLabelBackground(e);
 }
Esempio n. 48
0
 protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
 {
     RenderItemInternal(e);
 }
 protected override void OnRenderToolStripStatusLabelBackground(ToolStripItemRenderEventArgs e)
 {
     renderer.DrawToolStripStatusLabelBackground(e);
 }
 protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e)
 {
     renderer.DrawItemBackground(e);
 }
Esempio n. 51
0
        protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            System.Drawing.Rectangle rectangle1;

            System.Drawing.Graphics graphics1 = e.Graphics;
            Oranikle.Studio.Controls.CtrlTabStrip       ctrlTabStrip       = e.ToolStrip as Oranikle.Studio.Controls.CtrlTabStrip;
            Oranikle.Studio.Controls.CtrlTabStripButton ctrlTabStripButton = e.Item as Oranikle.Studio.Controls.CtrlTabStripButton;
            if ((ctrlTabStrip == null) || (ctrlTabStripButton == null))
            {
                if (currentRenderer != null)
                {
                    currentRenderer.DrawButtonBackground(e);
                    return;
                }
                base.OnRenderButtonBackground(e);
                return;
            }
            bool flag1 = ctrlTabStripButton.Checked;
            bool flag2 = ctrlTabStripButton.Selected;
            int  i1 = 0, i2 = 0;

            System.Drawing.Rectangle rectangle3 = ctrlTabStripButton.Bounds;
            int i3 = rectangle3.Width - 1;

            System.Drawing.Rectangle rectangle4 = ctrlTabStripButton.Bounds;
            int i4 = rectangle4.Height - 1;

            if (UseVS)
            {
                if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal)
                {
                    if (!flag1)
                    {
                        i1 = 2;
                        i4--;
                    }
                    else
                    {
                        i1 = 1;
                    }
                    rectangle1 = new System.Drawing.Rectangle(0, 0, i3, i4);
                }
                else
                {
                    if (!flag1)
                    {
                        i2 = 2;
                        i3--;
                    }
                    else
                    {
                        i2 = 1;
                    }
                    rectangle1 = new System.Drawing.Rectangle(0, 0, i4, i3);
                }
                using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(rectangle1.Width, rectangle1.Height))
                {
                    System.Windows.Forms.VisualStyles.VisualStyleElement visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Normal;
                    if (flag1)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Pressed;
                    }
                    if (flag2)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Hot;
                    }
                    if (!ctrlTabStripButton.Enabled)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Disabled;
                    }
                    if (!flag1 || flag2)
                    {
                        rectangle1.Width++;
                    }
                    else
                    {
                        rectangle1.Height++;
                    }
                    using (System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(bitmap))
                    {
                        System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(visualStyleElement);
                        visualStyleRenderer.DrawBackground(graphics2, rectangle1);
                        if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Vertical)
                        {
                            if (Mirrored)
                            {
                                bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
                            }
                            else
                            {
                                bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
                            }
                        }
                        else if (Mirrored)
                        {
                            bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
                        }
                        if (Mirrored)
                        {
                            System.Drawing.Rectangle rectangle5 = ctrlTabStripButton.Bounds;
                            i2 = rectangle5.Width - bitmap.Width - i2;
                            System.Drawing.Rectangle rectangle6 = ctrlTabStripButton.Bounds;
                            i1 = rectangle6.Height - bitmap.Height - i1;
                        }
                        graphics1.DrawImage(bitmap, i2, i1);
                    }
                    return;
                }
            }
            if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal)
            {
                if (!flag1)
                {
                    i1  = ctrlTabStripButton.VerticalOffsetInactive;
                    i4 -= ctrlTabStripButton.VerticalOffsetInactive - 1;
                }
                else
                {
                    i1 = ctrlTabStripButton.VerticalOffset;
                }
                if (Mirrored)
                {
                    i2 = 1;
                    i1 = 0;
                }
                else
                {
                    i1++;
                }
                i3--;
            }
            else
            {
                if (!flag1)
                {
                    i2 = 2;
                    i3--;
                }
                else
                {
                    i2 = 1;
                }
                if (Mirrored)
                {
                    i2 = 0;
                    i1 = 1;
                }
            }
            i4--;
            rectangle1 = new System.Drawing.Rectangle(i2, i1, i3, i4);
            using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                if (Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal))
                {
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top, rectangle1.Left, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Bottom - 3, 2, 2, 90.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + 2, rectangle1.Bottom, rectangle1.Right - 2, rectangle1.Bottom);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Bottom - 3, 2, 2, 0.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Bottom - 2, rectangle1.Right, rectangle1.Top);
                }
                else if (!Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal))
                {
                    int i5 = 1, i6 = 3;
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Bottom, rectangle1.Left, rectangle1.Top + i6);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Top + i6 - 1, i6, i6, 180.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + i6, rectangle1.Top, rectangle1.Right - i6 - i5, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Right - i6 - i5, rectangle1.Top + i6 - 1, i6, i6, 270.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right - i5, rectangle1.Top + i6, rectangle1.Right - i5, rectangle1.Bottom);
                }
                else if (Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Vertical))
                {
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top, rectangle1.Right - 2, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Top + 1, 2, 2, 270.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Top + 2, rectangle1.Right, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Bottom - 3, 2, 2, 0.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right - 2, rectangle1.Bottom, rectangle1.Left, rectangle1.Bottom);
                }
                else
                {
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Top, rectangle1.Left + 2, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Top + 1, 2, 2, 180.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top + 2, rectangle1.Left, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Bottom - 3, 2, 2, 90.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + 2, rectangle1.Bottom, rectangle1.Right, rectangle1.Bottom);
                }
                System.Drawing.Color color1 = ctrlTabStripButton.BackColorInactive;
                if (flag1)
                {
                    color1 = ctrlTabStripButton.BackColor;
                }
                else if (flag2)
                {
                    color1 = ctrlTabStripButton.BackColorHot;
                }
                System.Drawing.Color color2 = ctrlTabStripButton.BackColor2Inactive;
                if (flag1)
                {
                    color2 = ctrlTabStripButton.BackColor2;
                }
                else if (flag2)
                {
                    color2 = ctrlTabStripButton.BackColor2Hot;
                }
                if (renderMode == System.Windows.Forms.ToolStripRenderMode.Professional)
                {
                    color1 = flag2 ? System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientBegin : System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientEnd;
                    using (System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush1 = new System.Drawing.Drawing2D.LinearGradientBrush(ctrlTabStripButton.ContentRectangle, color1, System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientMiddle, System.Drawing.Drawing2D.LinearGradientMode.Vertical))
                    {
                        graphics1.FillPath(linearGradientBrush1, graphicsPath);
                        goto label_1;
                    }
                }
                using (System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush2 = new System.Drawing.Drawing2D.LinearGradientBrush(ctrlTabStripButton.ContentRectangle, color1, color2, System.Drawing.Drawing2D.LinearGradientMode.Vertical))
                {
                    graphics1.FillPath(linearGradientBrush2, graphicsPath);
                }
label_1:
                if (flag1)
                {
                    using (System.Drawing.Pen pen1 = new System.Drawing.Pen(ctrlTabStripButton.BorderColor))
                    {
                        graphics1.DrawPath(pen1, graphicsPath);
                        goto label_2;
                    }
                }
                if (flag2)
                {
                    using (System.Drawing.Pen pen2 = new System.Drawing.Pen(ctrlTabStripButton.BorderColorHot))
                    {
                        graphics1.DrawPath(pen2, graphicsPath);
                        goto label_2;
                    }
                }
                using (System.Drawing.Pen pen3 = new System.Drawing.Pen(ctrlTabStripButton.BorderColorInactive))
                {
                    graphics1.DrawPath(pen3, graphicsPath);
                }
label_2:
                if (ctrlTabStripButton.ShowCloseButton)
                {
                    System.Drawing.Image image = Oranikle.Studio.Controls.Properties.Resources.Icon_Close_Disabled_16;
                    if (flag2)
                    {
                        image = Oranikle.Studio.Controls.Properties.Resources.Icon_Close_16;
                    }
                    System.Drawing.Rectangle rectangle2 = new System.Drawing.Rectangle(i2 + i3 - ctrlTabStripButton.CloseButtonHorizontalOffset, ctrlTabStripButton.CloseButtonVerticalOffset, 8, 8);
                    graphics1.DrawImage(image, rectangle2);
                }
            }
        }
 protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
 {
     renderer.DrawSplitButton(e);
 }
Esempio n. 53
0
        private void drawText(System.Windows.Forms.ToolStripItemRenderEventArgs e, Graphics graphics)
        {
            try
            {
                Font font = e.Item.Font;

                if (Theme.ThemeStyle == RibbonOrbStyle.Office_2013)
                {
                    if (e.Item.Text != string.Empty)
                    {
                        if (e.Item.Enabled == true)
                        {
                            if (e.Item is ToolStripButton)
                            {
                                if ((e.Item.Selected | e.Item.Pressed) & !((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemTextPressed_2013;
                                }
                                else if ((!e.Item.Selected & !e.Item.Pressed) & !((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemText_2013;
                                }
                                else if (((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemTextSelected_2013;
                                }
                            }
                            else if (e.Item is ToolStripLabel)
                            {
                                e.Item.ForeColor = Theme.ColorTable.ToolStripItemText_2013;
                            }
                        }
                        else
                        {
                            if (e.Item.ForeColor != Color.DarkGray)
                            {
                                e.Item.ForeColor = Color.DarkGray;
                            }
                        }
                    }
                }
                else
                {
                    if (e.Item.Text != string.Empty)
                    {
                        if (e.Item.Enabled == true)
                        {
                            if (e.Item is ToolStripButton)
                            {
                                if ((e.Item.Selected | e.Item.Pressed) & !((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemTextPressed;
                                }
                                else if ((!e.Item.Selected & !e.Item.Pressed) & !((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemText;
                                }
                                else if (((ToolStripButton)e.Item).Checked)
                                {
                                    e.Item.ForeColor = Theme.ColorTable.ToolStripItemTextSelected;
                                }
                            }
                            else if (e.Item is ToolStripLabel)
                            {
                                e.Item.ForeColor = Theme.ColorTable.ToolStripItemText;
                            }
                        }
                        else
                        {
                            if (e.Item.ForeColor != Color.DarkGray)
                            {
                                e.Item.ForeColor = Color.DarkGray;
                            }
                        }
                    }
                }

                if (e.Item is ToolStripButton | e.Item is ToolStripMenuItem | e.Item is ToolStripDropDownButton | e.Item is ToolStripLabel)
                {
                    switch (e.Item.DisplayStyle)
                    {
                    case ToolStripItemDisplayStyle.Image:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(e.Item.Image.Height + 2, e.Item.Image.Width + 2);
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(e.Item.Image.Width + 2, e.Item.Image.Height + 2);
                            }
                        }
                        break;

                    case ToolStripItemDisplayStyle.ImageAndText:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + e.Item.Image.Height + 10), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8));
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + e.Item.Image.Width + 10), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8));
                            }
                        }

                        e.Item.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                        e.Item.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                        break;

                    case ToolStripItemDisplayStyle.None:
                        break;

                    case ToolStripItemDisplayStyle.Text:
                        if (!e.Item.AutoSize)
                        {
                            if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Vertical90)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8));
                            }
                            else if (e.Item.GetCurrentParent().TextDirection == ToolStripTextDirection.Horizontal)
                            {
                                e.Item.Size = new Size(Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Width + 8), Convert.ToInt32(graphics.MeasureString(e.Item.Text, font).Height + 8));
                            }
                        }
                        break;
                    }
                }
                else if (e.Item is ToolStripSeparator)
                {
                }
                else if (e.Item is ToolStripTextBox)
                {
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
 {
     renderer.DrawOverflowButtonBackground(e);
 }
Esempio n. 55
0
 protected override void OnRenderLabelBackground(ToolStripItemRenderEventArgs e)
 {
     RenderLabelInternal(e);
 }
Esempio n. 56
0
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripSplitButton splitButton = e.Item as ToolStripSplitButton;
            Graphics             g           = e.Graphics;

            bool  rightToLeft = (splitButton.RightToLeft == RightToLeft.Yes);
            Color arrowColor  = splitButton.Enabled ? SystemColors.ControlText : SystemColors.ControlDark;

            // in right to left - we need to swap the parts so we dont draw  v][ toolStripSplitButton
            VisualStyleElement splitButtonDropDownPart = (rightToLeft) ? VisualStyleElement.ToolBar.SplitButton.Normal : VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
            VisualStyleElement splitButtonPart         = (rightToLeft) ? VisualStyleElement.ToolBar.DropDownButton.Normal : VisualStyleElement.ToolBar.SplitButton.Normal;

            Rectangle bounds = new Rectangle(Point.Empty, splitButton.Size);

            if (ToolStripManager.VisualStylesEnabled &&
                VisualStyleRenderer.IsElementDefined(splitButtonDropDownPart) &&
                VisualStyleRenderer.IsElementDefined(splitButtonPart))
            {
                VisualStyleRenderer vsRenderer = VisualStyleRenderer;

                // Draw the SplitButton Button portion of it.
                vsRenderer.SetParameters(splitButtonPart.ClassName, splitButtonPart.Part, GetSplitButtonItemState(splitButton));

                // the lovely Windows theming for split button comes in three pieces:
                //  SplitButtonDropDown: [ v |
                //  Separator:                |
                //  SplitButton:               |  ]
                // this is great except if you want to swap the button in RTL.  In this case we need
                // to use the DropDownButton instead of the SplitButtonDropDown and paint the arrow ourselves.
                Rectangle splitButtonBounds = splitButton.ButtonBounds;
                if (rightToLeft)
                {
                    // scoot to the left so we dont draw double shadow like so: ][
                    splitButtonBounds.Inflate(2, 0);
                }
                // Draw the button portion of it.
                vsRenderer.DrawBackground(g, splitButtonBounds);

                // Draw the SplitButton DropDownButton portion of it.
                vsRenderer.SetParameters(splitButtonDropDownPart.ClassName, splitButtonDropDownPart.Part, GetSplitButtonDropDownItemState(splitButton));

                // Draw the drop down button portion
                vsRenderer.DrawBackground(g, splitButton.DropDownButtonBounds);

                // fill in the background image
                Rectangle fillRect = splitButton.ContentRectangle;
                if (splitButton.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(g, splitButton.BackgroundImage, splitButton.BackColor, splitButton.BackgroundImageLayout, fillRect, fillRect);
                }

                // draw the separator over it.
                RenderSeparatorInternal(g, splitButton, splitButton.SplitterBounds, true);

                // and of course, now if we're in RTL we now need to paint the arrow
                // because we're no longer using a part that has it built in.
                if (rightToLeft || splitButton.BackgroundImage != null)
                {
                    DrawArrow(new ToolStripArrowRenderEventArgs(g, splitButton, splitButton.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                // Draw the split button button
                Rectangle splitButtonButtonRect = splitButton.ButtonBounds;

                if (splitButton.BackgroundImage != null)
                {
                    // fill in the background image
                    Rectangle fillRect = (splitButton.Selected) ? splitButton.ContentRectangle : bounds;
                    if (splitButton.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, splitButton.BackgroundImage, splitButton.BackColor, splitButton.BackgroundImageLayout, bounds, fillRect);
                    }
                }
                else
                {
                    FillBackground(g, splitButtonButtonRect, splitButton.BackColor);
                }

                ToolBarState state = GetSplitButtonToolBarState(splitButton, false);

                RenderSmall3DBorderInternal(g, splitButtonButtonRect, state, rightToLeft);

                // draw the split button drop down
                Rectangle dropDownRect = splitButton.DropDownButtonBounds;

                // fill the color in the dropdown button
                if (splitButton.BackgroundImage == null)
                {
                    FillBackground(g, dropDownRect, splitButton.BackColor);
                }

                state = GetSplitButtonToolBarState(splitButton, true);

                if ((state == ToolBarState.Pressed) || (state == ToolBarState.Hot))
                {
                    RenderSmall3DBorderInternal(g, dropDownRect, state, rightToLeft);
                }

                DrawArrow(new ToolStripArrowRenderEventArgs(g, splitButton, dropDownRect, arrowColor, ArrowDirection.Down));
            }
        }
Esempio n. 57
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripMenuItem item = e.Item as ToolStripMenuItem;
            Graphics          g    = e.Graphics;

            if (item is MdiControlStrip.SystemMenuItem)
            {
                return; // no highlights are painted behind a system menu item
            }

            //

            if (item != null)
            {
                Rectangle bounds = new Rectangle(Point.Empty, item.Size);
                if (item.IsTopLevel && !ToolStripManager.VisualStylesEnabled)
                {
                    // Classic Mode (3D edges)
                    // Draw box highlight for toplevel items in downlevel platforms
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, item.ContentRectangle);
                    }
                    else if (item.RawBackColor != Color.Empty)
                    {
                        FillBackground(g, item.ContentRectangle, item.BackColor);
                    }
                    // Toplevel menu items do 3D borders.
                    ToolBarState state = GetToolBarState(item);
                    RenderSmall3DBorderInternal(g, bounds, state, (item.RightToLeft == RightToLeft.Yes));
                }
                else
                {
                    // Modern MODE (no 3D edges)
                    // Draw blue filled highlight for toplevel items in themed platforms
                    // or items parented to a drop down
                    Rectangle fillRect = new Rectangle(Point.Empty, item.Size);
                    if (item.IsOnDropDown)
                    {
                        // Scoot in by 2 pixels when selected
                        fillRect.X     += 2;
                        fillRect.Width -= 3; //its already 1 away from the right edge
                    }

                    if (item.Selected || item.Pressed)
                    {
                        // Legacy behavior is to always paint the menu item background. The correct behavior is to only
                        // paint the background if the menu item is enabled.
                        if (item.Enabled)
                        {
                            g.FillRectangle(SystemBrushes.Highlight, fillRect);
                        }

                        Color borderColor = ToolStripManager.VisualStylesEnabled ?
                                            SystemColors.Highlight : ProfessionalColors.MenuItemBorder;

                        // Draw selection border - always drawn regardless of Enabled.
                        using var pen = borderColor.GetCachedPenScope();
                        g.DrawRectangle(pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
                    }
                    else
                    {
                        if (item.BackgroundImage != null)
                        {
                            ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, fillRect);
                        }
                        else if (!ToolStripManager.VisualStylesEnabled && (item.RawBackColor != Color.Empty))
                        {
                            FillBackground(g, fillRect, item.BackColor);
                        }
                    }
                }
            }
        }
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ThemeElements.CurrentTheme.ToolStripPainter.OnRenderOverflowButtonBackground(e);

            base.OnRenderOverflowButtonBackground(e);
        }
Esempio n. 59
0
 protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e)
 {
 }
Esempio n. 60
0
        private void RenderItemBackgroundPressed(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            if (Theme.ThemeStyle == RibbonOrbStyle.Office_2013)
            {
                Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1);
                Rectangle rect       = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2);

                using (SolidBrush b = new SolidBrush(Theme.ColorTable.ButtonPressed_2013))
                {
                    using (SolidBrush sb = new SolidBrush(Theme.ColorTable.ButtonBorderOut))
                    {
                        e.Graphics.FillRectangle(sb, rectBorder);
                    }

                    e.Graphics.FillRectangle(b, rect);
                }
            }
            else
            {
                Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1);
                Rectangle rect       = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2);

                Rectangle innerR  = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, e.Item.Height - 2);
                Rectangle glossyR = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, 1 + Convert.ToInt32((double)e.Item.Bounds.Height * .36));

                using (SolidBrush brus = new SolidBrush(Theme.ColorTable.ButtonPressedBgOut))
                {
                    e.Graphics.FillRectangle(brus, rectBorder);
                }

                //Border
                using (Pen p = new Pen(Theme.ColorTable.ButtonPressedBorderOut))
                {
                    e.Graphics.DrawRectangle(p, rectBorder);
                }

                //Inner border
                Rectangle RoundedRect = Rectangle.Round(innerR);
                using (Pen p = new Pen(Theme.ColorTable.ButtonPressedBorderIn))
                {
                    e.Graphics.DrawRectangle(p, RoundedRect);
                }

                #region Main Bg
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(new Rectangle(1, 1, e.Item.Width, e.Item.Height * 2));
                    path.CloseFigure();
                    using (PathGradientBrush gradient = new PathGradientBrush(path))
                    {
                        gradient.WrapMode       = WrapMode.Clamp;
                        gradient.CenterPoint    = new PointF(Convert.ToSingle(1 + e.Item.Width / 2), Convert.ToSingle(e.Item.Bounds.Height));
                        gradient.CenterColor    = Theme.ColorTable.ButtonPressedBgCenter;
                        gradient.SurroundColors = new Color[] { Theme.ColorTable.ButtonPressedBgOut };

                        Blend blend = new Blend(3);
                        blend.Factors   = new float[] { 0f, 0.8f, 0f };
                        blend.Positions = new float[] { 0f, 0.30f, 1f };


                        Region lastClip = e.Graphics.Clip;
                        Region newClip  = new Region(rectBorder);
                        newClip.Intersect(lastClip);
                        e.Graphics.SetClip(newClip.GetBounds(e.Graphics));
                        e.Graphics.FillPath(gradient, path);
                        e.Graphics.Clip = lastClip;
                    }
                }
                #endregion

                //Glossy effect
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddRectangle(Rectangle.Round(glossyR));
                    using (LinearGradientBrush b = new LinearGradientBrush(glossyR, Theme.ColorTable.ButtonPressedGlossyNorth, Theme.ColorTable.ButtonPressedGlossySouth, 90))
                    {
                        b.WrapMode = WrapMode.TileFlipXY;
                        e.Graphics.FillPath(b, path);
                    }
                }
            }
        }