using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace wsControls
{
[ToolboxItem(true), ToolboxBitmap(typeof(System.Windows.Forms.ProgressBar))]
public class wsProgressBar : System.Windows.Forms.UserControl
{
int progress = 0;
#region [ Property ] Progress, MaxProgress
public int Progress
{
get { return progress; }
set
{
progress = value;
this.Refresh();
}
}
public int MaxProgress { get { return 1000; } }
#endregion
Color corbegin = Color.Green;
Color corend = Color.Yellow;
#region [ Property ] ColorBegin, ColorEnd
public Color ColorBegin
{
get { return corbegin; }
set
{
corbegin = value;
this.Refresh();
}
}
public Color ColorEnd
{
get { return corend; }
set
{
corend = value;
this.Refresh();
}
}
#endregion
public wsProgressBar()
{
this.Size = new Size(30, 200);
this.ForeColor = Color.White;
this.BackColor = Color.Black;
Progress = 500;
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(this.ForeColor);
if (progress > 0)
{
Rectangle rect = this.DisplayRectangle;
int h = progress * Height / MaxProgress;
rect.Width -= 1;
rect.Height = h > Height ? Height : h;
rect.Location = new Point(0, Height - rect.Height);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, corbegin, corend, -90F);
e.Graphics.FillRectangle(brush, rect);
brush.Dispose();
}
e.Graphics.DrawRectangle(new Pen(this.BackColor), 0, 0, Width - 1, Height-1);
}
}
}