using System.Drawing; using System.Windows.Forms; namespace Workplace.CheckItems { public class MyProgressBar : ProgressBar { public int ColorId = 0; public MyProgressBar() { this.SetStyle(ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { Rectangle rec = e.ClipRectangle; rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4; if(ProgressBarRenderer.IsSupported) ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle); rec.Height = rec.Height - 4; Brush brush = (ColorId == 1) ? Brushes.Yellow : (ColorId == 2) ? Brushes.Red : Brushes.Green; e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height); } } }