protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripItem item = e.Item; if (item.Enabled) { Graphics g = e.Graphics; Rectangle rect = new Rectangle(Point.Empty, e.Item.Size); if (toolStrip is MenuStrip) { LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; if (item.Selected) { RenderHelperStrip.RenderBackgroundInternal(g, rect, this.ColorTable.ItemHover, this.ColorTable.ItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, true, true, mode); } else if (item.Pressed) { RenderHelperStrip.RenderBackgroundInternal(g, rect, this.ColorTable.ItemPressed, this.ColorTable.ItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, true, true, mode); } else { base.OnRenderMenuItemBackground(e); } } else if (toolStrip is ToolStripDropDown) { rect = new Rectangle(new Point(-2, 0), new Size(e.Item.Size.Width + 5, e.Item.Size.Height + 1)); if (item.RightToLeft == RightToLeft.Yes) { rect.X += 4; } else { rect.X += 4; } rect.Width -= 8; rect.Height--; if (item.Selected) { RenderHelperStrip.RenderBackgroundInternal(g, rect, this.ColorTable.ItemHover, this.ColorTable.ItemBorder, this.ColorTable.Back, this.ColorTable.ItemRadiusStyle, this.ColorTable.ItemRadius, this.ColorTable.ItemBorderShow, this.ColorTable.ItemAnamorphosis, 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) { return; } LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; Graphics graphics = e.Graphics; SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics); Rectangle r = new Rectangle(Point.Empty, item.Size); if (item.Pressed && item.HasDropDownItems) { if (this.ColorTable.BaseItemDown != null) { ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, r, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { RenderHelperStrip.RenderBackgroundInternal(graphics, r, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } } else if (item.Selected) { if (this.ColorTable.BaseItemDown != null) { ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemMouse, r, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { RenderHelperStrip.RenderBackgroundInternal(graphics, r, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } } else { if (toolStrip is ToolStripOverflow) { using (Brush brush = new SolidBrush(this.ColorTable.Back)) { graphics.FillRectangle(brush, r); goto Label_0256; } } base.OnRenderDropDownButtonBackground(e); } Label_0256: graphics2.Dispose(); }
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics g = e.Graphics; Rectangle affectedBounds = e.AffectedBounds; if (toolStrip is ToolStripDropDown) { RegionHelper.CreateRegion(toolStrip, affectedBounds, this.ColorTable.BackRadius, this.ColorTable.RadiusStyle); using (SolidBrush brush = new SolidBrush(this.ColorTable.Back)) { g.FillRectangle(brush, affectedBounds); return; } } LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; RenderHelperStrip.RenderBackgroundInternal(g, affectedBounds, this.ColorTable.Base, this.ColorTable.ItemBorder, this.ColorTable.Back, this.ColorTable.RadiusStyle, this.ColorTable.BackRadius, 0.35f, false, false, mode); }
public void RenderOverflowBackground(ToolStripItemRenderEventArgs e, bool rightToLeft) { bool flag2; Color empty = Color.Empty; Graphics g = e.Graphics; ToolStrip toolStrip = e.ToolStrip; ToolStripOverflowButton item = e.Item as ToolStripOverflowButton; Rectangle bounds = new Rectangle(Point.Empty, item.Size); Rectangle withinBounds = bounds; bool flag = !(item.GetCurrentParent() is MenuStrip); if (flag2 = toolStrip.Orientation == Orientation.Horizontal) { bounds.X += (bounds.Width - 12) + 1; bounds.Width = 12; if (rightToLeft) { bounds = LayoutUtils.RTLTranslate(bounds, withinBounds); } } else { bounds.Y = (bounds.Height - 12) + 1; bounds.Height = 12; } if (item.Pressed) { empty = this.ColorTable.ItemPressed; } else if (item.Selected) { empty = this.ColorTable.ItemHover; } else { empty = this.ColorTable.Base; } if (flag) { using (Pen pen = new Pen(this.ColorTable.Base)) { 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; } g.DrawLine(pen, point, point2); } } LinearGradientMode mode = flag2 ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; RenderHelperStrip.RenderBackgroundInternal(g, bounds, empty, this.ColorTable.ItemBorder, this.ColorTable.Back, RoundStyle.None, 0, 0.35f, false, false, mode); if (flag) { using (Brush brush = new SolidBrush(this.ColorTable.Base)) { if (flag2) { 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; } g.FillRectangle(brush, point3.X, point3.Y, 1, 1); g.FillRectangle(brush, point4.X, point4.Y, 1, 1); } else { g.FillRectangle(brush, bounds.Width - 3, bounds.Top - 1, 1, 1); g.FillRectangle(brush, bounds.Width - 2, bounds.Top - 2, 1, 1); } } using (Brush brush2 = new SolidBrush(this.ColorTable.Base)) { if (flag2) { Rectangle rect = new Rectangle(bounds.X - 1, 0, 1, 1); if (rightToLeft) { rect.X = bounds.Right; } g.FillRectangle(brush2, rect); } else { g.FillRectangle(brush2, bounds.X, bounds.Top - 1, 1, 1); } } } }
protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; 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); new SmoothingModeGraphics(graphics); Color arrowColor = toolStrip.Enabled ? this.ColorTable.Fore : SystemColors.ControlDark; if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect); } if (item.ButtonPressed) { if (this.ColorTable.BaseItemDown != null) { ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { Rectangle buttonBounds = item.ButtonBounds; Padding padding = (item.RightToLeft == RightToLeft.Yes) ? new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1); buttonBounds = LayoutUtils.DeflateRect(buttonBounds, padding); RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); buttonBounds.Inflate(-1, -1); graphics.SetClip(buttonBounds); RenderHelperStrip.RenderBackgroundInternal(graphics, buttonBounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, RoundStyle.Left, false, true, mode); graphics.ResetClip(); using (Pen pen = new Pen(this.ColorTable.BaseItemSplitter)) { 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)); } else if (!item.Pressed && !item.DropDownButtonPressed) { if (item.Selected) { if (this.ColorTable.BaseItemMouse != null) { ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); using (Pen pen2 = new Pen(this.ColorTable.BaseItemSplitter)) { graphics.DrawLine(pen2, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom); } } base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); } else { base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); } } else { if (this.ColorTable.BaseItemDown != null) { ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down)); } } else { base.OnRenderSplitButtonBackground(e); } }
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripButton item = e.Item as ToolStripButton; Graphics graphics = e.Graphics; if (item == null) { return; } LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics); Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect); } if (item.CheckState == CheckState.Unchecked) { if (item.Selected) { Bitmap img = item.Pressed ? ((Bitmap)this.ColorTable.BaseItemDown) : ((Bitmap)this.ColorTable.BaseItemMouse); if (img != null) { ImageDrawRect.DrawRect(graphics, img, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { Color baseItemHover = this.ColorTable.BaseItemHover; if (item.Pressed) { baseItemHover = this.ColorTable.BaseItemPressed; } RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, baseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } goto Label_0302; } if (!(toolStrip is ToolStripOverflow)) { goto Label_0302; } using (Brush brush = new SolidBrush(this.ColorTable.ItemHover)) { graphics.FillRectangle(brush, bounds); goto Label_0302; } } Bitmap baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse; Color baseColor = ControlPaint.Light(this.ColorTable.ItemHover); if (item.Selected) { baseColor = this.ColorTable.ItemHover; baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse; } if (item.Pressed) { baseColor = this.ColorTable.ItemPressed; baseItemMouse = (Bitmap)this.ColorTable.BaseItemDown; } if (baseItemMouse == null) { RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, baseColor, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } else { ImageDrawRect.DrawRect(graphics, baseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } Label_0302: graphics2.Dispose(); }