-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigimonEvolutionOption.cs
More file actions
100 lines (89 loc) · 2.91 KB
/
DigimonEvolutionOption.cs
File metadata and controls
100 lines (89 loc) · 2.91 KB
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
using System.ComponentModel;
namespace Cyber_Sleuth_Mod_Evolution_Analyzer
{
public partial class DigimonEvolutionOption : UserControl
{
List<Digimon> options = [];
public DigimonEvolutionOption()
{
InitializeComponent();
valueBox.DataSource = new List<Digimon>(options);
valueBox.SelectedIndex = -1;
}
private void clearButton_Click(object sender, EventArgs e)
{
valueBox.DataSource = null;
valueBox.SelectedIndex = -1;
valueBox.Visible = false;
clearButton.Visible = false;
jumpButton.Visible = false;
enableButton.Visible = true;
SelectedDigimonChanged?.Invoke(this, e);
}
private void enableButton_Click(object sender, EventArgs e)
{
valueBox.DataSource = options;
valueBox.SelectedIndex = 0;
valueBox.Visible = true;
clearButton.Visible = true;
jumpButton.Visible = true;
enableButton.Visible = false;
SelectedDigimonChanged?.Invoke(this, e);
}
private void jumpButton_Click(object sender, EventArgs e)
{
JumpToSelectedDigimon?.Invoke(this, e);
}
private void valueBox_SelectionChangeCommitted(object sender, EventArgs e)
{
SelectedDigimonChanged?.Invoke(this, e);
}
[Browsable(true)]
public List<Digimon> Options
{
get => options;
set
{
options = value;
valueBox.DataSource = new List<Digimon>(options);
}
}
[Browsable(true)]
public event EventHandler? SelectedDigimonChanged;
[Browsable(true)]
public event EventHandler? JumpToSelectedDigimon;
[Browsable(true)]
public Digimon? SelectedDigimon
{
get
{
if (valueBox.SelectedIndex > -1)
{
return options[valueBox.SelectedIndex];
}
return null;
}
set
{
if (value != null && options.Contains(value))
{
valueBox.DataSource = options;
valueBox.SelectedIndex = options.IndexOf(value);
valueBox.Visible = true;
clearButton.Visible = true;
jumpButton.Visible = true;
enableButton.Visible = false;
}
else
{
valueBox.DataSource = null;
valueBox.SelectedIndex = -1;
valueBox.Visible = false;
clearButton.Visible = false;
jumpButton.Visible = false;
enableButton.Visible = true;
}
}
}
}
}