protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripItem item = e.Item; if (!item.Enabled) { return; } Graphics graphics = e.Graphics; var rect = new Rectangle(Point.Empty, e.Item.Size); if (toolStrip is MenuStrip) { } else if (toolStrip is ToolStripDropDown) { bool drawLogo = DrawLogo(toolStrip); int offsetMargin = drawLogo ? OffsetMargin : 0; if (item.RightToLeft == RightToLeft.Yes) { rect.X += 4; } else { rect.X += offsetMargin + 4; } rect.Width -= offsetMargin + 8; rect.Height--; if (item.Selected) { GraphicsHelper.DrawBackground( graphics, rect, StyleSet.ToolStripMenuItemHoveredBackColor, StyleSet.ToolStripMenuItemBorderColor, StyleSet.ToolStripMenuItemInnerBorderColor, RoundStyle.All, 4, 0.25f, true, true, LinearGradientMode.Vertical); } else { base.OnRenderMenuItemBackground(e); } } else { base.OnRenderMenuItemBackground(e); } }
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripDropDownItem item = e.Item as ToolStripDropDownItem; if (item != null) { LinearGradientMode mode = toolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; Graphics graphics = e.Graphics; SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics); Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (item.Pressed && item.HasDropDownItems) { GraphicsHelper.DrawBackground( graphics, bounds, StyleSet.HeadToolStripItemPressedBackColor, StyleSet.HeadToolStripItemBorderColor, StyleSet.HeadToolStripItemInnerBorderColor, RoundStyle.All, 8, 0.45f, true, true, mode); } else if (item.Selected) { GraphicsHelper.DrawBackground( graphics, bounds, StyleSet.HeadToolStripItemHoveringBackColor, StyleSet.HeadToolStripItemBorderColor, StyleSet.HeadToolStripItemInnerBorderColor, RoundStyle.All, 8, 0.45f, true, true, mode); } else if (toolStrip is ToolStripOverflow) { using (Brush brush = new SolidBrush(StyleSet.HeadToolStripItemInnerBorderColor)) { graphics.FillRectangle(brush, bounds); } } else { base.OnRenderDropDownButtonBackground(e); } sg.Dispose(); } }
private void DrawGroundFormCloseBox(Graphics g, Rectangle rect, ControlState state, bool isActive, bool ifHasMinimizeBox, bool ifHasMaximizeBox) { Color baseColor = StyleSet.ControlBoxActiveColor; if (state == ControlState.Pressed) { baseColor = StyleSet.CloseControlBoxPressedColor; } else if (state == ControlState.Hovering) { baseColor = StyleSet.CloseControlBoxHoveringColor; } else { baseColor = isActive ? StyleSet.ControlBoxActiveColor : StyleSet.ControlBoxInActiveColor; } RoundStyle roundStyle = ifHasMinimizeBox || ifHasMaximizeBox ?RoundStyle.BottomRight : RoundStyle.Bottom; using (SmoothingModeGraphics antiGraphics = new SmoothingModeGraphics(g)) { GraphicsHelper.DrawBackground( g, rect, baseColor, baseColor, StyleSet.ControlBoxInnerBorderColor, roundStyle, 6, .38F, true, false, LinearGradientMode.Vertical); using (Pen pen = new Pen(StyleSet.FormBorderColor)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } using (GraphicsPath path = CreateCloseGraphicsPath(rect)) { g.FillPath(Brushes.White, path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } }
private void DrawCaptionBackground(Graphics g, Rectangle captionRect, bool isActive) { Color baseColor = isActive ? StyleSet.CaptionActiveColor : StyleSet.CaptionInactiveColor; GraphicsHelper.DrawBackground( g, captionRect, baseColor, StyleSet.FormBorderColor, //StyleSet.FormInnerBorderColor, StyleSet.FormBorderColor, RoundStyle.None, 0, //.25f, .00f, false, false, LinearGradientMode.Vertical); }
internal void RenderOverflowBackground(ToolStripItemRenderEventArgs e, bool rightToLeft) { Color color = Color.Empty; Graphics graphics = e.Graphics; ToolStrip toolStrip = e.ToolStrip; ToolStripOverflowButton item = e.Item as ToolStripOverflowButton; Rectangle bounds = new Rectangle(Point.Empty, item.Size); Rectangle withinBounds = bounds; bool bParentIsMenuStrip = !(item.GetCurrentParent() is MenuStrip); bool bHorizontal = toolStrip.Orientation == Orientation.Horizontal; if (bHorizontal) { bounds.X += (bounds.Width - 12) + 1; bounds.Width = 12; if (rightToLeft) { bounds = GraphicsHelper.RTLTranslate(bounds, withinBounds); } } else { bounds.Y = (bounds.Height - 12) + 1; bounds.Height = 12; } if (item.Pressed) { color = StyleSet.HeadToolStripItemPressedBackColor; } else if (item.Selected) { color = StyleSet.HeadToolStripItemHoveringBackColor; } else { color = StyleSet.HeadToolStripBackColor; } if (bParentIsMenuStrip) { using (Pen pen = new Pen(StyleSet.HeadToolStripBackColor)) { Point point = new Point(bounds.Left - 1, bounds.Height - 2); Point point2 = new Point(bounds.Left, bounds.Height - 2); if (rightToLeft) { point.X = bounds.Right + 1; point2.X = bounds.Right; } graphics.DrawLine(pen, point, point2); } } LinearGradientMode mode = bHorizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; GraphicsHelper.DrawBackground( graphics, bounds, color, StyleSet.HeadToolStripItemBorderColor, StyleSet.HeadToolStripItemInnerBorderColor, RoundStyle.None, 0, .35f, false, false, mode); if (bParentIsMenuStrip) { using (Brush brush = new SolidBrush(StyleSet.HeadToolStripBackColor)) { if (bHorizontal) { Point point3 = new Point(bounds.X - 2, 0); Point point4 = new Point(bounds.X - 1, 1); if (rightToLeft) { point3.X = bounds.Right + 1; point4.X = bounds.Right; } graphics.FillRectangle(brush, point3.X, point3.Y, 1, 1); graphics.FillRectangle(brush, point4.X, point4.Y, 1, 1); } else { graphics.FillRectangle(brush, bounds.Width - 3, bounds.Top - 1, 1, 1); graphics.FillRectangle(brush, bounds.Width - 2, bounds.Top - 2, 1, 1); } } using (Brush brush = new SolidBrush(StyleSet.HeadToolStripBackColor)) { if (bHorizontal) { Rectangle rect = new Rectangle(bounds.X - 1, 0, 1, 1); if (rightToLeft) { rect.X = bounds.Right; } graphics.FillRectangle(brush, rect); } else { graphics.FillRectangle(brush, bounds.X, bounds.Top - 1, 1, 1); } } } }
protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; var isHeadControl = false; if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$")) { isHeadControl = true; } ToolStripSplitButton item = e.Item as ToolStripSplitButton; if (item != null) { Graphics graphics = e.Graphics; LinearGradientMode mode = toolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; Rectangle bounds = new Rectangle(Point.Empty, item.Size); SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics); Color arrowColor = SystemColors.ControlDarkDark; if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; GraphicsHelper.DrawBackgroundImage( graphics, item.BackgroundImage, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, item.BackgroundImageLayout, bounds, clipRect); } if (item.ButtonPressed) { Rectangle buttonBounds = item.ButtonBounds; Padding padding = (item.RightToLeft == RightToLeft.Yes) ? new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1); buttonBounds = GraphicsHelper.DeflateRect(buttonBounds, padding); GraphicsHelper.DrawBackground( graphics, bounds, isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ? 8 : 0, isHeadControl ? 0.45f : 0f, true, true, mode); buttonBounds.Inflate(-1, -1); graphics.SetClip(buttonBounds); GraphicsHelper.DrawBackground( graphics, buttonBounds, isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ? 8 : 0, isHeadControl ? 0.45f : 0f, false, true, mode); graphics.ResetClip(); using (Pen pen = new Pen(StyleSet.HeadToolStripItemBorderColor)) { graphics.DrawLine( pen, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom); } base.DrawArrow( new ToolStripArrowRenderEventArgs( graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); return; } if (item.Pressed || item.DropDownButtonPressed) { GraphicsHelper.DrawBackground( graphics, bounds, isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ? 8 : 0, isHeadControl ? 0.45f : 0f, true, true, mode); base.DrawArrow( new ToolStripArrowRenderEventArgs( graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); return; } if (item.Selected) { GraphicsHelper.DrawBackground( graphics, bounds, isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ? 8 : 0, isHeadControl ? 0.45f : 0f, true, true, mode); using (Pen pen = new Pen(StyleSet.HeadToolStripItemBorderColor)) { graphics.DrawLine( pen, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom); } base.DrawArrow( new ToolStripArrowRenderEventArgs( graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); return; } base.DrawArrow( new ToolStripArrowRenderEventArgs( graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); return; } base.OnRenderSplitButtonBackground(e); }
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; var isHeadControl = false; if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$")) { isHeadControl = true; } var item = e.Item as ToolStripButton; Graphics graphcs = e.Graphics; if (item != null) { LinearGradientMode mode = toolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; var smoothGraphics = new SmoothingModeGraphics(graphcs); var bounds = new Rectangle(Point.Empty, item.Size); if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; GraphicsHelper.DrawBackgroundImage( graphcs, item.BackgroundImage, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, item.BackgroundImageLayout, bounds, clipRect); } if (item.CheckState == CheckState.Unchecked) { if (item.Selected) { Color color = isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor; if (item.Pressed) { color = isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor; } GraphicsHelper.DrawBackground( graphcs, bounds, color, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ?8:0, isHeadControl ?0.45f:0f, true, true, mode); } else { if (toolStrip is ToolStripOverflow) { using (Brush brush = new SolidBrush(isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor)) { graphcs.FillRectangle(brush, bounds); } } } } else { Color color = ControlPaint.Light(isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor); if (item.Selected) { color = isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor; } if (item.Pressed) { color = isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor; } GraphicsHelper.DrawBackground( graphcs, bounds, color, isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor, isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor, isHeadControl ? RoundStyle.All : RoundStyle.None, isHeadControl ? 8 : 0, isHeadControl ? 0.45f : 0f, true, true, mode); } smoothGraphics.Dispose(); } }