mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
b745a6a335
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1960 21ef857c-d57f-4fe0-8362-d861dc6d29cd
83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
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));
|
|
}
|
|
}
|
|
}
|
|
|