-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNewProgressBar.cs
34 lines (30 loc) · 1.03 KB
/
NewProgressBar.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
33
34
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BedrockLauncher.Bootstrap
{
public class NewProgressBar : ProgressBar
{
public NewProgressBar()
{
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush brush = null;
Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
double scaleFactor = (((double)Value - (double)Minimum) / ((double)Maximum - (double)Minimum));
brush = new SolidBrush(this.BackColor);
e.Graphics.FillRectangle(brush, 0, 0, rec.Width, rec.Height);
rec.Width = (int)((rec.Width * scaleFactor) - 2);
rec.Height -= 2;
brush = new SolidBrush(this.ForeColor);
e.Graphics.FillRectangle(brush, 0, 0, rec.Width, rec.Height);
}
}
}