-
Notifications
You must be signed in to change notification settings - Fork 5
/
KeyFairyTrackerBox.cs
112 lines (102 loc) · 3.6 KB
/
KeyFairyTrackerBox.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
using System;
namespace LMRItemTracker
{
class KeyFairyTrackerBox : System.Windows.Forms.PictureBox
{
private bool miracleCollected;
private bool mekuriCollected;
public KeyFairyTrackerBox()
{
miracleCollected = false;
mekuriCollected = false;
Paint += new System.Windows.Forms.PaintEventHandler(HandlePaint);
}
public void ToggleState(bool isCollected, bool isMiracle)
{
if(isMiracle)
{
miracleCollected = isCollected;
}
else
{
mekuriCollected = isCollected;
}
Redraw();
}
protected virtual void DetermineImage()
{
if (miracleCollected && mekuriCollected)
{
BackgroundImage = Properties.Resources.Icon_keyfairy;
}
else
{
string mode = Properties.Settings.Default.BackgroundMode;
if ("shaded".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keyfairy_blank;
}
else if ("solid".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keyfairy_solid;
}
else
{
BackgroundImage = null;
}
}
Visible = !"hide".Equals(Properties.Settings.Default.BackgroundMode) || (miracleCollected && mekuriCollected);
}
public void Redraw()
{
if (InvokeRequired)
{
Invoke(new System.Action(() =>
{
DetermineImage();
Refresh();
}));
}
else
{
DetermineImage();
Refresh();
}
}
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 ((!miracleCollected || !mekuriCollected) && "solid".Equals(Properties.Settings.Default.BackgroundMode) && !LaMulanaItemTrackerForm.DialogOpen)
{
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_keyfairy_solid, new System.Drawing.Rectangle(0, 0, 40, 40), 0, 0, 40, 40, System.Drawing.GraphicsUnit.Pixel, imageAttributes);
}
}
}
}