using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Drawing; using System.Windows.Forms; namespace ProcessHacker.Components { public partial class ProgressBar : System.Windows.Forms.ProgressBar { public ProgressBar() { InitializeComponent(); } int val = 0; // Current progress Color BarColor = Color.Blue; // Color of progress meter protected override void OnResize(EventArgs e) { // Invalidate the control to get a repaint. this.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; SolidBrush brush = new SolidBrush(BarColor); float percent = (float)(val - this.Minimum) / (float)(this.Maximum - this.Minimum); Rectangle rect = this.ClientRectangle; // Calculate area for drawing the progress. rect.Width = (int)((float)rect.Width * percent); // Draw the progress meter. g.FillRectangle(brush, rect); // Draw a three-dimensional border around the control. Draw3DBorder(g); // Clean up. brush.Dispose(); g.Dispose(); } public Color ProgressBarColor { get { return BarColor; } set { BarColor = value; // Invalidate the control to get a repaint. this.Invalidate(); } } private void Draw3DBorder(Graphics g) { int PenWidth = (int)Pens.White.Width; g.DrawLine(Pens.DarkGray, new Point(this.ClientRectangle.Left, this.ClientRectangle.Top), new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top)); g.DrawLine(Pens.DarkGray, new Point(this.ClientRectangle.Left, this.ClientRectangle.Top), new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth)); g.DrawLine(Pens.White, new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth), new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth)); g.DrawLine(Pens.White, new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top), new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth)); } } }