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) { Graphics g = this._bufferedGraphics.Graphics; g.Clear(Color.Transparent); Rectangle rect = new Rectangle(System.Drawing.Point.Empty, base.Size); bool bBlock = (this.Style != ProgressBarStyle.Marquee) || base.DesignMode; float basePosition = bBlock ? 0.3f : 0.45f; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); if (this.Back != null) { Bitmap btm = new Bitmap(this.Back, base.Size); UpdateForm.CreateControlRegion(this, btm, 200); g.DrawImage(this.Back, rect); } else { RenderHelper.RenderBackgroundInternal(g, rect, this.TrackBack, this.Border, this.InnerBorder, this.RadiusStyle, this.Radius, basePosition, true, this.Glass, LinearGradientMode.Vertical); } Rectangle trackRect = rect; trackRect.Inflate(-this.BarMinusSize.Width, -this.BarMinusSize.Height); if (!bBlock) { GraphicsState state = g.Save(); g.SetClip(trackRect); trackRect.X = this._trackX; trackRect.Width = 100; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(trackRect); g.SetClip(path, CombineMode.Intersect); } RenderHelper.RenderBackgroundInternal(g, trackRect, this.TrackFore, this.Border, this.InnerBorder, RoundStyle.None, 8, basePosition, false, this.BarGlass, LinearGradientMode.Vertical); using (LinearGradientBrush brush = new LinearGradientBrush(trackRect, this.InnerBorder, Color.Transparent, 0f)) { Blend blend = new Blend(); float[] CS_0_0002 = new float[3]; CS_0_0002[1] = 1f; blend.Factors = CS_0_0002; float[] CS_0_0003 = new float[3]; CS_0_0003[1] = 0.5f; CS_0_0003[2] = 1f; blend.Positions = CS_0_0003; brush.Blend = blend; g.FillRectangle(brush, trackRect); } g.Restore(state); goto Label_02F1; } trackRect.Width = (int) ((((double) base.Value) / ((double) (base.Maximum - base.Minimum))) * trackRect.Width); if (this.BarBack != null) { if (this.BarBackStyle == BackStyle.Tile) { using (TextureBrush Txbrus = new TextureBrush(this.BarBack)) { Txbrus.WrapMode = WrapMode.Tile; g.FillRectangle(Txbrus, trackRect); goto Label_019B; } } Bitmap btm = new Bitmap(this.BarBack, base.Size); g.DrawImageUnscaledAndClipped(btm, trackRect); } else { RenderHelper.RenderBackgroundInternal(g, trackRect, 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(g, 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: sg.Dispose(); IntPtr hDC = CCWin.Win32.NativeMethods.GetDC(hWnd); this._bufferedGraphics.Render(hDC); CCWin.Win32.NativeMethods.ReleaseDC(hWnd, hDC); }
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripButton item = e.Item as ToolStripButton; Graphics g = e.Graphics; if (item == null) { return; } LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; CCWin.SkinControl.ControlPaintEx.DrawBackgroundImage(g, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect); } Bitmap btm = null; Color color = Color.Red; if (item.CheckState == CheckState.Unchecked) { if (item.Selected) { btm = item.Pressed ? ((Bitmap) this.ColorTable.BaseItemDown) : ((Bitmap) this.ColorTable.BaseItemMouse); if (btm != null) { CCWin.ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } else { color = this.ColorTable.BaseItemHover; if (item.Pressed) { color = this.ColorTable.BaseItemPressed; } RenderHelperStrip.RenderBackgroundInternal(g, bounds, color, 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)) { g.FillRectangle(brush, bounds); goto Label_0302; } } btm = (Bitmap)this.ColorTable.BaseItemMouse; color = ControlPaint.Light(this.ColorTable.ItemHover); if (item.Selected) { color = this.ColorTable.ItemHover; btm = (Bitmap) this.ColorTable.BaseItemMouse; } if (item.Pressed) { color = this.ColorTable.ItemPressed; btm = (Bitmap) this.ColorTable.BaseItemDown; } if (btm == null) { RenderHelperStrip.RenderBackgroundInternal(g, bounds, color, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode); } else { CCWin.ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1); } Label_0302: sg.Dispose(); }
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 g = e.Graphics; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (item.Pressed && item.HasDropDownItems) { if (this.ColorTable.BaseItemDown != null) { CCWin.ImageDrawRect.DrawRect(g, (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(g, bounds, 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) { CCWin.ImageDrawRect.DrawRect(g, (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(g, bounds, 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)) { g.FillRectangle(brush, bounds); goto Label_0256; } } base.OnRenderDropDownButtonBackground(e); } Label_0256: sg.Dispose(); }
protected override void OnRenderButtonBackground( ToolStripItemRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; ToolStripButton item = e.Item as ToolStripButton; Graphics g = e.Graphics; if (item != null) { LinearGradientMode mode = toolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; SmoothingModeGraphics sg = new SmoothingModeGraphics(g); Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (item.BackgroundImage != null) { Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds; ControlPaintEx.DrawBackgroundImage( g, item.BackgroundImage, ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect); } if (item.CheckState == CheckState.Unchecked) { if (item.Selected) { Bitmap btm = item.Pressed ? (Bitmap)ColorTable.BaseItemDown : (Bitmap)ColorTable.BaseItemMouse; if (btm != null) { ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1); } else { Color color = ColorTable.BaseItemHover; if (item.Pressed) { color = ColorTable.BaseItemPressed; } RenderHelperStrip.RenderBackgroundInternal2( g, bounds, color, ColorTable.BaseItemBorder, ColorTable.Back, ColorTable.BaseItemRadiusStyle, ColorTable.BaseItemRadius, ColorTable.BaseItemBorderShow, ColorTable.BaseItemAnamorphosis, mode); } } else { if (toolStrip is ToolStripOverflow) { using (Brush brush = new SolidBrush(ColorTable.ItemHover)) { g.FillRectangle(brush, bounds); } } } } else { Bitmap btm = (Bitmap)ColorTable.BaseItemMouse; Color color = ControlPaint.Light(ColorTable.ItemHover); if (item.Selected) { color = ColorTable.ItemHover; btm = (Bitmap)ColorTable.BaseItemMouse; } if (item.Pressed) { color = ColorTable.ItemPressed; btm = (Bitmap)ColorTable.BaseItemDown; } if (btm == null) { RenderHelperStrip.RenderBackgroundInternal2( g, bounds, color, ColorTable.BaseItemBorder, ColorTable.Back, ColorTable.BaseItemRadiusStyle, ColorTable.BaseItemRadius, ColorTable.BaseItemBorderShow, ColorTable.BaseItemAnamorphosis, mode); } else { ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1); } } sg.Dispose(); } }