35 lines
1004 B
C#
35 lines
1004 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace _29WxOrder.MyControl
|
|
{
|
|
public class MyProgressBar : ProgressBar
|
|
{
|
|
public MyProgressBar()
|
|
{
|
|
base.SetStyle(ControlStyles.UserPaint, true);
|
|
}
|
|
|
|
//重写OnPaint方法
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
SolidBrush brush = null;
|
|
Rectangle bounds = new Rectangle(0, 0, base.Width, base.Height);
|
|
//...
|
|
//e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 1, 1, bounds.Width, bounds.Height);
|
|
bounds.Height -= 4;
|
|
bounds.Width = ((int)(bounds.Width * (((double)base.Value) / ((double)base.Maximum)))) - 4;
|
|
brush = new SolidBrush(Color.FromArgb(33, 113, 202));
|
|
e.Graphics.FillRectangle(brush, 2, 2, bounds.Width, bounds.Height);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|