protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics graphics = e.Graphics; if ((toolStrip is ToolStripDropDown) && (e.Item is ToolStripMenuItem)) { Rectangle imageRectangle = e.ImageRectangle; if (e.Item.RightToLeft == RightToLeft.Yes) { imageRectangle.X -= 2; } else { imageRectangle.X += 2; } imageRectangle.Width = 13; imageRectangle.Y++; imageRectangle.Height -= 3; using (new SmoothingModeGraphics(graphics)) { using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(imageRectangle); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = Color.White; brush.SurroundColors = new Color[] { ControlPaint.Light(this.ColorTable.Back) }; Blend blend = new Blend(); float[] numArray = new float[3]; numArray[1] = 0.3f; numArray[2] = 1f; blend.Positions = numArray; float[] numArray2 = new float[3]; numArray2[1] = 0.5f; numArray2[2] = 1f; blend.Factors = numArray2; brush.Blend = blend; graphics.FillRectangle(brush, imageRectangle); } } using (Pen pen = new Pen(ControlPaint.Light(this.ColorTable.Back))) { graphics.DrawRectangle(pen, imageRectangle); } ControlPaintEx.DrawCheckedFlag(graphics, imageRectangle, this.ColorTable.Fore); return; } } base.OnRenderItemCheck(e); }
protected override void OnRenderItemCheck( ToolStripItemImageRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics g = e.Graphics; if (toolStrip is ToolStripDropDown && e.Item is ToolStripMenuItem) { bool bDrawLogo = NeedDrawLogo(toolStrip); int offsetMargin = bDrawLogo ? OffsetMargin : 0; Rectangle rect = e.ImageRectangle; if (e.Item.RightToLeft == RightToLeft.Yes) { rect.X -= offsetMargin + 2; } else { rect.X += offsetMargin + 2; } rect.Width = 13; rect.Y += 1; rect.Height -= 3; using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(rect); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = Color.White; brush.SurroundColors = new Color[] { ControlPaint.Light(ColorTable.BackNormal) }; Blend blend = new Blend(); blend.Positions = new float[] { 0f, 0.3f, 1f }; blend.Factors = new float[] { 0f, 0.5f, 1f }; brush.Blend = blend; g.FillRectangle(brush, rect); } } using (Pen pen = new Pen(ControlPaint.Light(ColorTable.BackNormal))) { g.DrawRectangle(pen, rect); } ControlPaintEx.DrawCheckedFlag(g, rect, ColorTable.Fore); } } else { base.OnRenderItemCheck(e); } }