forked from thezerothcat/LMRItemTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeySwordTrackerBox.cs
116 lines (106 loc) · 3.65 KB
/
KeySwordTrackerBox.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
namespace LMRItemTracker
{
class KeySwordTrackerBox : System.Windows.Forms.PictureBox
{
private bool keySwordCollected;
private bool mantrasRecited;
public KeySwordTrackerBox()
{
keySwordCollected = false;
mantrasRecited = false;
Paint += new System.Windows.Forms.PaintEventHandler(HandlePaint);
}
public void ToggleState(bool isCollected, bool isKeySword)
{
if(isKeySword)
{
keySwordCollected = isCollected;
}
else
{
mantrasRecited = isCollected;
}
Redraw();
}
public void Redraw()
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
DetermineImage();
Refresh();
}));
}
else
{
DetermineImage();
Refresh();
}
}
private void DetermineImage()
{
if (keySwordCollected && mantrasRecited)
{
BackgroundImage = Properties.Resources.Icon_keysword_awakened;
}
else if (keySwordCollected)
{
BackgroundImage = Properties.Resources.Icon_keysword;
}
else
{
string mode = Properties.Settings.Default.BackgroundMode;
if ("shaded".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keysword_blank;
}
else if ("solid".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keysword_solid;
}
else
{
BackgroundImage = null;
}
}
Visible = !"hide".Equals(Properties.Settings.Default.BackgroundMode) || keySwordCollected;
}
private void HandlePaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
UpdateImage(e);
}));
}
else
{
UpdateImage(e);
}
}
private void UpdateImage(System.Windows.Forms.PaintEventArgs e)
{
if (!keySwordCollected && "solid".Equals(Properties.Settings.Default.BackgroundMode))
{
e.Graphics.Clear(Properties.Settings.Default.BackgroundColor);
System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
new float[][]{
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {Properties.Settings.Default.ItemColor.R / 255.0f,
Properties.Settings.Default.ItemColor.G / 255.0f,
Properties.Settings.Default.ItemColor.B / 255.0f,
0, 1}
});
imageAttributes.SetColorMatrix(colorMatrix);
e.Graphics.DrawImage(Properties.Resources.Icon_keysword_solid, new System.Drawing.Rectangle(0, 0, 40, 40), 0, 0, 40, 40, System.Drawing.GraphicsUnit.Pixel, imageAttributes);
}
}
}
}