-
Notifications
You must be signed in to change notification settings - Fork 11
/
ProgressBarEX.cs
32 lines (27 loc) · 1.03 KB
/
ProgressBarEX.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace CoffeeShop
{
internal class ProgressBarEx : ProgressBar
{
public ProgressBarEx()
{
// this.ForeColor = Color.FromArgb(255, 0, 0);
// this.BackColor = Color.FromArgb(150, 0, 0);
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
LinearGradientBrush brush = null;
Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
if (ProgressBarRenderer.IsSupported)
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
rec.Width = (int)(rec.Width * ((double)base.Value / Maximum)) - 4;
rec.Height -= 4;
brush = new LinearGradientBrush(rec, this.ForeColor, this.BackColor, LinearGradientMode.Vertical);
e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
}
}
}