blob: a13bbf8061f3d5e7623ef75867bf0fc0e62bc788 (
plain) (
blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShiftOS.Frontend.GraphicsSubsystem;
using static ShiftOS.Engine.SkinEngine;
namespace ShiftOS.Frontend.GUI
{
public class ProgressBar : Control
{
private int _maximum = 100;
private int _value = 0;
public int Maximum
{
get
{
return _maximum;
}
set
{
_maximum = value;
}
}
public int Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
protected override void OnPaint(GraphicsContext gfx)
{
gfx.Clear(LoadedSkin.ProgressBarBackgroundColor.ToMonoColor());
int w = (int)linear(_value, 0, _maximum, 0, Width);
gfx.DrawRectangle(0, 0, w, Height, LoadedSkin.ProgressColor.ToMonoColor());
}
static public double linear(double x, double x0, double x1, double y0, double y1)
{
if ((x1 - x0) == 0)
{
return (y0 + y1) / 2;
}
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
}
}
|