Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- public class ColorProgressBar : ProgressBar
- {
- public ColorProgressBar()
- {
- base.SetStyle(ControlStyles.UserPaint |
- ControlStyles.AllPaintingInWmPaint |
- ControlStyles.OptimizedDoubleBuffer, true);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- Brush backBrush = new SolidBrush(this.BackColor);
- Brush foreBrush = new SolidBrush(this.ForeColor);
- e.Graphics.FillRectangle(backBrush, this.ClientRectangle);
- int chunksWidth = (int)(
- (double)this.ClientSize.Width *
- (double)(this.Value - this.Minimum) /
- (double)(this.Maximum - this.Minimum));
- Rectangle chunksRect = new Rectangle(0, 0,
- chunksWidth, this.ClientSize.Height);
- e.Graphics.FillRectangle(foreBrush, chunksRect);
- backBrush.Dispose();
- foreBrush.Dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement