forked from thezerothcat/LMRItemTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiCountTrackerLabel.cs
62 lines (57 loc) · 2.05 KB
/
MultiCountTrackerLabel.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
namespace LMRItemTracker
{
class PistolAmmoTrackerLabel : System.Windows.Forms.Label
{
protected static System.Drawing.Font SMALL_FONT = new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
protected static System.Drawing.Font LARGE_FONT = new System.Drawing.Font("Arial", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
private static int CLIP_MAX = 3;
private static int BULLET_MAX = 6;
public int ClipCount { get; set; }
public int BulletCount { get; set; }
public PistolAmmoTrackerLabel()
{
ClipCount = 0;
BulletCount = 0;
}
public void UpdateCount(int newCount, bool clip)
{
if (newCount >= 0 && newCount <= (clip ? CLIP_MAX : BULLET_MAX))
{
if (InvokeRequired)
{
Invoke(new System.Action(() =>
{
if(clip)
{
ClipCount = newCount;
}
else
{
BulletCount = newCount;
}
Text = string.Format("{0}:{1}", ClipCount, BulletCount);
Font = Text.Length > 3 ? SMALL_FONT : LARGE_FONT;
Refresh();
}));
}
else
{
if (clip)
{
ClipCount = newCount;
}
else
{
BulletCount = newCount;
}
Text = string.Format("{0}:{1}", ClipCount, BulletCount);
Font = Text.Length > 3 ? SMALL_FONT : LARGE_FONT;
}
}
}
public void UpdateTextColor()
{
ForeColor = Properties.Settings.Default.TextColor;
}
}
}