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 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(); }
private void DrawProgressBar(IntPtr hWnd) { bool flag; Graphics graphics = this._bufferedGraphics.Graphics; graphics.Clear(Color.Transparent); Rectangle rect = new Rectangle(System.Drawing.Point.Empty, base.Size); float basePosition = (flag = (this.Style != ProgressBarStyle.Marquee) || base.DesignMode) ? 0.3f : 0.45f; SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics); if (this.Back != null) { Bitmap bitmap = new Bitmap(this.Back, base.Size); SkinTools.CreateControlRegion(this, bitmap, 200); graphics.DrawImage(this.Back, rect); } else { RenderHelper.RenderBackgroundInternal(graphics, rect, this.TrackBack, this.Border, this.InnerBorder, this.RadiusStyle, this.Radius, basePosition, true, this.Glass, LinearGradientMode.Vertical); } Rectangle rectangle2 = rect; rectangle2.Inflate(-this.BarMinusSize.Width, -this.BarMinusSize.Height); if (!flag) { GraphicsState gstate = graphics.Save(); graphics.SetClip(rectangle2); rectangle2.X = this._trackX; rectangle2.Width = 100; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(rectangle2); graphics.SetClip(path, CombineMode.Intersect); } RenderHelper.RenderBackgroundInternal(graphics, rectangle2, this.TrackFore, this.Border, this.InnerBorder, RoundStyle.None, 8, basePosition, false, this.BarGlass, LinearGradientMode.Vertical); using (LinearGradientBrush brush2 = new LinearGradientBrush(rectangle2, this.InnerBorder, Color.Transparent, 0f)) { Blend blend = new Blend(); float[] numArray = new float[3]; numArray[1] = 1f; blend.Factors = numArray; float[] numArray2 = new float[3]; numArray2[1] = 0.5f; numArray2[2] = 1f; blend.Positions = numArray2; brush2.Blend = blend; graphics.FillRectangle(brush2, rectangle2); } graphics.Restore(gstate); goto Label_02F1; } rectangle2.Width = (int)((((double)base.Value) / ((double)(base.Maximum - base.Minimum))) * rectangle2.Width); if (this.BarBack != null) { if (this.BarBackStyle == BackStyle.Tile) { using (TextureBrush brush = new TextureBrush(this.BarBack)) { brush.WrapMode = WrapMode.Tile; graphics.FillRectangle(brush, rectangle2); goto Label_019B; } } Bitmap image = new Bitmap(this.BarBack, base.Size); graphics.DrawImageUnscaledAndClipped(image, rectangle2); } else { RenderHelper.RenderBackgroundInternal(graphics, rectangle2, this.TrackFore, this.Border, this.InnerBorder, this.BarRadiusStyle, this.BarRadius, basePosition, false, this.BarGlass, LinearGradientMode.Vertical); } Label_019B: if (!string.IsNullOrEmpty(this._formatString) && this.TxtShow) { TextRenderer.DrawText(graphics, string.Format(this._formatString, ((double)base.Value) / ((double)(base.Maximum - base.Minimum))), base.Font, rect, base.ForeColor, TextFormatFlags.WordEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); } Label_02F1: graphics2.Dispose(); IntPtr dC = NativeMethods.GetDC(hWnd); this._bufferedGraphics.Render(dC); NativeMethods.ReleaseDC(hWnd, dC); }
private void DrawProgressBar(IntPtr hWnd) { Graphics g = _bufferedGraphics.Graphics; g.Clear(Color.Transparent); Rectangle rect = new Rectangle(Point.Empty, Size); bool bBlock = Style != ProgressBarStyle.Marquee || base.DesignMode; float basePosition = bBlock ? .30f : .45f; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); if (Back != null) { Bitmap btm = new Bitmap(Back, this.Size); if (Create) { SkinTools.CreateControlRegion(this, btm, 200); } g.DrawImage(Back, rect); } else { RenderHelper.RenderBackgroundInternal( g, rect, TrackBack, Border, InnerBorder, RadiusStyle, Radius, basePosition, true, Glass, LinearGradientMode.Vertical); } Rectangle trackRect = rect; trackRect.Inflate(-BarMinusSize.Width, -BarMinusSize.Height); if (bBlock) { trackRect.Width = (int)(((double)Value / (Maximum - Minimum)) * trackRect.Width); if (BarBack != null) { if (BarBackStyle == BackStyle.Tile) { using (TextureBrush Txbrus = new TextureBrush(BarBack)) { Txbrus.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile; g.FillRectangle(Txbrus, trackRect); } } else { Bitmap btm = new Bitmap(BarBack, this.Size); g.DrawImageUnscaledAndClipped(btm, trackRect); } } else { RenderHelper.RenderBackgroundInternal( g, trackRect, TrackFore, Border, InnerBorder, BarRadiusStyle, BarRadius, basePosition, false, BarGlass, LinearGradientMode.Vertical); } if (!string.IsNullOrEmpty(_formatString) && TextFormat == TxtFormat.Percentage) { TextRenderer.DrawText( g, string.Format(_formatString, (double)Value / (Maximum - Minimum)), base.Font, rect, base.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis); } else if (TextFormat == TxtFormat.Proportion) { TextRenderer.DrawText( g, Value + "/" + Maximum, base.Font, rect, base.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis); } } else { GraphicsState state = g.Save(); g.SetClip(trackRect); trackRect.X = _trackX; trackRect.Width = MarqueeWidth; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(trackRect); g.SetClip(path, CombineMode.Intersect); } RenderHelper.RenderBackgroundInternal( g, trackRect, TrackFore, Border, InnerBorder, RoundStyle.None, 8, basePosition, false, BarGlass, LinearGradientMode.Vertical); using (LinearGradientBrush brush = new LinearGradientBrush( trackRect, InnerBorder, Color.Transparent, 0f)) { Blend blend = new Blend(); blend.Factors = new float[] { 0f, 1f, 0f }; blend.Positions = new float[] { 0f, .5f, 1f }; brush.Blend = blend; g.FillRectangle(brush, trackRect); } g.Restore(state); } sg.Dispose(); IntPtr hDC = NativeMethods.GetDC(hWnd); _bufferedGraphics.Render(hDC); NativeMethods.ReleaseDC(hWnd, hDC); }
private void DrawProgressBar(IntPtr hWnd) { System.Drawing.Graphics g = _bufferedGraphics.Graphics; Rectangle rect = new Rectangle(Point.Empty, Size); ProgressBarColorTable colorTable = ColorTable; bool bBlock = Style != ProgressBarStyle.Marquee || base.DesignMode; float basePosition = bBlock ? .30f : .45f; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); RenderHelper.RenderBackgroundInternal( g, rect, colorTable.TrackBack, colorTable.Border, colorTable.InnerBorder, RoundStyle.All, 8, basePosition, true, true, LinearGradientMode.Vertical); Rectangle trackRect = rect; trackRect.Inflate(-2, -2); if (bBlock) { trackRect.Width = (int)(((double)Value / (Maximum - Minimum)) * trackRect.Width); RenderHelper.RenderBackgroundInternal( g, trackRect, colorTable.TrackFore, colorTable.Border, colorTable.InnerBorder, RoundStyle.All, 8, basePosition, false, true, LinearGradientMode.Vertical); if (!string.IsNullOrEmpty(_formatString)) { TextRenderer.DrawText( g, string.Format(_formatString, (double)Value / (Maximum - Minimum)), base.Font, rect, base.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis); } } else { GraphicsState state = g.Save(); g.SetClip(trackRect); trackRect.X = _trackX; trackRect.Width = MarqueeWidth; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(trackRect); g.SetClip(path, CombineMode.Intersect); } RenderHelper.RenderBackgroundInternal( g, trackRect, colorTable.TrackFore, colorTable.Border, colorTable.InnerBorder, RoundStyle.None, 8, basePosition, false, false, LinearGradientMode.Vertical); using (LinearGradientBrush brush = new LinearGradientBrush( trackRect, colorTable.InnerBorder, Color.Transparent, 0f)) { Blend blend = new Blend(); blend.Factors = new float[] { 0f, 1f, 0f }; blend.Positions = new float[] { 0f, .5f, 1f }; brush.Blend = blend; g.FillRectangle(brush, trackRect); } g.Restore(state); } sg.Dispose(); IntPtr hDC = NativeMethods.GetDC(hWnd); _bufferedGraphics.Render(hDC); NativeMethods.ReleaseDC(hWnd, hDC); }
protected virtual void OnRenderTrack(PaintEventArgs e) { System.Drawing.Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; bool horizontal = base.Orientation == Orientation.Horizontal; float mode = horizontal ? 0f : 270f; if (horizontal) { rect.Inflate(0, 1); } else { rect.Inflate(1, 0); } SmoothingModeGraphics sg = new SmoothingModeGraphics(g); using (GraphicsPath path = GraphicsPathHelper.CreatePath( rect, 4, RoundStyle.All, true)) { using (LinearGradientBrush brush = new LinearGradientBrush( rect, ColorTable.TrackBegin, ColorTable.TrackEnd, mode)) { g.FillPath(brush, path); } using (Pen pen = new Pen(ColorTable.TrackBorder)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreatePath( rect, 4, RoundStyle.All, true)) { using (Pen pen = new Pen(ColorTable.TrackInnerBorder)) { g.DrawPath(pen, path); } } sg.Dispose(); }