-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrmParametre.vb
257 lines (223 loc) · 9.53 KB
/
FrmParametre.vb
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
''Thibault ANIN 2019 -- Dedi Orsay TP2E --
Public Class frmParametre
Dim reglesPred() As String = {"Aucune", "Vie", "HighLife", "Vie3-4", "Prolifération", "Day&Night"}
Dim selecteurTouche As Boolean
Dim touche, toucheMod As Keys
Public couleurFond, couleurGrille, couleurCellule As Color
Private Sub FrmParametre_Load(sender As Object, e As EventArgs) Handles MyBase.Load
chkBoxAfficherGrille.Checked = MoteurUI.afficherGrille
chkBoxMultiCouleur.Checked = MoteurUI.multicolor
couleurFond = MoteurUI.couleurFondChoisi
couleurGrille = MoteurUI.couleurGrilleChoisi
couleurCellule = MoteurUI.couleurCelluleChoisi
pnlCouleurFond.BackColor = couleurFond
pnlCouleurGrille.BackColor = couleurGrille
pnlCouleurCellule.BackColor = couleurCellule
If MoteurUI.UseMur Then
chkBoxMur.Checked = MoteurUI.mur
Else
chkBoxMur.Hide()
End If
For Each regle As String In reglesPred
cboBoxReglePred.Items.Add(regle)
Next
For Each ctrl In pnlNbCellNaissance.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If MoteurUI.tabNbCellNaissance(CInt(c.Text)) <> 0 Then
c.Checked = True
End If
Next
For Each ctrl In pnlNbCellVie.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If MoteurUI.tabNbCellMort(CInt(c.Text)) <> 0 Then
c.Checked = True
End If
Next
cboBoxReglePred.SelectedIndex = MoteurUI.reglePred
End Sub
Private Sub BtnAppliquer_Click(sender As Object, e As EventArgs) Handles btnAppliquer.Click
MoteurUI.afficherGrille = chkBoxAfficherGrille.Checked
MoteurUI.multicolor = chkBoxMultiCouleur.Checked
MoteurUI.setCouleurFond(couleurFond)
MoteurUI.setCouleurGrille(couleurGrille)
MoteurUI.setCouleurCellule(couleurCellule)
If MoteurUI.UseMur Then
MoteurUI.mur = chkBoxMur.Checked
MoteurUI.DefMur(chkBoxMur.Checked)
End If
regle()
MoteurUI.majRegle()
MoteurUI.Invalidate()
Close()
End Sub
Private Sub BtnAnnuler_Click(sender As Object, e As EventArgs) Handles btnAnnuler.Click
couleurFond = MoteurUI.couleurFondChoisi
couleurGrille = MoteurUI.couleurGrilleChoisi
couleurCellule = MoteurUI.couleurCelluleChoisi
pnlCouleurFond.BackColor = couleurFond
pnlCouleurGrille.BackColor = couleurGrille
pnlCouleurCellule.BackColor = couleurCellule
Close()
End Sub
Sub regle()
Dim chckBoxTemp As New CheckBox
Dim cpt As Integer = 8
For Each ctrl In pnlNbCellNaissance.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True And c.Text <> "" Then
MoteurUI.tabNbCellNaissance(cpt) = CInt((c.Text))
Else
MoteurUI.tabNbCellNaissance(cpt) = 0
End If
cpt -= 1
Next
cpt = 8
For Each ctrl In pnlNbCellVie.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True And c.Text <> "" Then
MoteurUI.tabNbCellMort(cpt) = CInt((c.Text))
Else
MoteurUI.tabNbCellMort(cpt) = 0
End If
cpt -= 1
Next
End Sub
Sub regleRecap()
Dim cptNaissance As Integer
Dim cptMort As Integer
Dim textRecapNaissance As String = ""
Dim textRecapMort As String = ""
For i = 0 To 8
If MoteurUI.tabNbCellNaissance(i) > 0 Then
cptNaissance += 1
End If
If MoteurUI.tabNbCellMort(i) > 0 Then
cptMort += 1
End If
Next
For i = 8 To 0 Step -1
If MoteurUI.tabNbCellNaissance(i) > 0 Then
textRecapNaissance += " " + CStr(MoteurUI.tabNbCellNaissance(i))
cptNaissance -= 1
If cptNaissance > 1 Then
textRecapNaissance += ","
ElseIf cptNaissance <= 1 And cptNaissance > 0 Then
textRecapNaissance += " ou"
End If
End If
If MoteurUI.tabNbCellMort(i) > 0 Then
textRecapMort += " " + CStr(MoteurUI.tabNbCellMort(i))
cptMort -= 1
If cptMort > 1 Then
textRecapMort += ","
ElseIf cptMort <= 1 And cptMort > 0 Then
textRecapMort += " ou"
End If
End If
Next
lblRegleRecap.Text = "Si une cellule morte a" & textRecapNaissance & " voisine(s), elle naît.
Si une cellule vivante a" & textRecapMort & " voisine(s), elle meurt, sinon elle continue à vivre."
textRecapNaissance = ""
textRecapMort = ""
End Sub
Private Sub BtnChckN_CheckedChanged(sender As Object, e As EventArgs) Handles btnChckN1.MouseClick,
btnChckN2.MouseClick, btnChckN3.MouseClick, btnChckN4.MouseClick, btnChckN5.MouseClick,
btnChckN6.MouseClick, btnChckN7.MouseClick, btnChckN8.MouseClick,
btnChckV1.MouseClick, btnChckV2.MouseClick, btnChckV3.MouseClick, btnChckV4.MouseClick,
btnChckV5.MouseClick, btnChckV6.MouseClick, btnChckV7.MouseClick, btnChckV8.MouseClick
regle()
regleRecap()
End Sub
Private Sub PnlCouleurFond_Click(sender As Object, e As EventArgs) Handles pnlCouleurFond.Click
couleurFond = RecupCouleur(pnlCouleurFond.BackColor)
pnlCouleurFond.BackColor = couleurFond
End Sub
Private Sub PnlCouleurGrille_Click(sender As Object, e As EventArgs) Handles pnlCouleurGrille.Click
couleurGrille = RecupCouleur(pnlCouleurGrille.BackColor)
pnlCouleurGrille.BackColor = couleurGrille
End Sub
Private Sub PnlCouleurCellule_Click(sender As Object, e As EventArgs) Handles pnlCouleurCellule.Click
couleurCellule = RecupCouleur(pnlCouleurCellule.BackColor)
pnlCouleurCellule.BackColor = couleurCellule
End Sub
Function RecupCouleur(ByVal couleur As Color) As Color
Dim couleurs As DialogResult
couleurs = paletteCouleur.ShowDialog()
If couleurs = Windows.Forms.DialogResult.OK Then
Return paletteCouleur.Color
Else
Return couleur
End If
End Function
Private Sub CboBoxReglePred_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboBoxReglePred.SelectedIndexChanged
MoteurUI.reglePred = cboBoxReglePred.SelectedIndex
If cboBoxReglePred.SelectedIndex <> 0 Then
For Each ctrl In pnlNbCellNaissance.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True Then
c.Checked = False
End If
Next
For Each ctrl In pnlNbCellVie.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True Then
c.Checked = False
End If
Next
Else
pbDemoReglePred.Image = Nothing
End If
Select Case cboBoxReglePred.SelectedIndex
Case 1
btnChckV2.Checked = True
btnChckV3.Checked = True
btnChckN3.Checked = True
pbDemoReglePred.Image = My.Resources.heure
Case 2
btnChckV2.Checked = True
btnChckV3.Checked = True
btnChckN3.Checked = True
btnChckN6.Checked = True
pbDemoReglePred.Image = My.Resources.Conways_game_of_life_breeder_animation
Case 3
btnChckV3.Checked = True
btnChckV4.Checked = True
btnChckN3.Checked = True
btnChckN4.Checked = True
pbDemoReglePred.Image = My.Resources.Gospers_glider_gun
Case 4
btnChckV8.Checked = True
btnChckN1.Checked = True
pbDemoReglePred.Image = My.Resources.IncredibleShamefulCalf_max_1mb
Case 5
btnChckV3.Checked = True
btnChckV4.Checked = True
btnChckV6.Checked = True
btnChckV7.Checked = True
btnChckV8.Checked = True
btnChckN3.Checked = True
btnChckN4.Checked = True
btnChckN6.Checked = True
btnChckN7.Checked = True
btnChckN8.Checked = True
pbDemoReglePred.Image = My.Resources.Day_and_night
End Select
End Sub
Private Sub BtnDefaut_Click(sender As Object, e As EventArgs) Handles btnDefaut.Click
For Each ctrl In pnlNbCellNaissance.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True Then
c.Checked = False
End If
Next
For Each ctrl In pnlNbCellVie.Controls
Dim c As CheckBox = CType(ctrl, CheckBox)
If c.Checked = True Then
c.Checked = False
End If
Next
btnChckV2.Checked = True
btnChckV3.Checked = True
btnChckN3.Checked = True
End Sub
End Class