forked from thezerothcat/LMRItemTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrackerLabel.cs
47 lines (43 loc) · 1.56 KB
/
TrackerLabel.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
namespace LMRItemTracker
{
class TrackerLabel : System.Windows.Forms.Label
{
private static System.Drawing.Font SMALL_FONT = new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
private static System.Drawing.Font LARGE_FONT = new System.Drawing.Font("Arial", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
public int Count { get; set; }
public int Max { get; set; }
public string FormatString { get; set; }
public bool TreatAsAmmo { get; set; }
public TrackerLabel()
{
Count = 0;
FormatString = "{0}";
}
public void UpdateCount(int newCount)
{
if (newCount >= 0 && newCount <= Max)
{
if (InvokeRequired)
{
Invoke(new System.Action(() =>
{
Count = newCount;
Text = string.Format(FormatString, newCount, Max);
Font = Text.Length > 3 ? SMALL_FONT : LARGE_FONT;
Refresh();
}));
}
else
{
Count = newCount;
Text = string.Format(FormatString, Count, Max);
Font = Text.Length > 3 ? SMALL_FONT : LARGE_FONT;
}
}
}
public void UpdateTextColor()
{
ForeColor = Properties.Settings.Default.TextColor;
}
}
}