This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIHM.cs
205 lines (169 loc) · 9.09 KB
/
IHM.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
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
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Touch;
using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;
using System.Threading;
using Grand_Robot;
enum Couleurs { rouge, orange, jaune, vert, bleu, indigo, violet };
namespace GR
{
class IHM
{
#region Attributs
GHI.Glide.Display.Window fenetreSelection, fenetreAffichage, fenetrePhase;
Couleur m_equipe = Couleur.Null;
int m_disposition = 0;
public bool validation = false;
#endregion
#region Attributs selection
GHI.Glide.UI.Button BoutonBleu;
GHI.Glide.UI.Button BoutonJaune;
GHI.Glide.UI.Button BoutonDispo1;
GHI.Glide.UI.Button BoutonDispo2;
GHI.Glide.UI.Button BoutonDispo3;
GHI.Glide.UI.Button BoutonDispo4;
GHI.Glide.UI.Button BoutonDispo5;
GHI.Glide.UI.Button BoutonValider;
TextBlock TexteCouleur;
TextBlock TexteDispo;
#endregion
#region Attributs affichage
TextBlock TexteAffichage;
string[] liste = new string[150];
int nbLignes;
int hauteurLigne;
int largeurLigne;
#endregion
public IHM()
{
GlideTouch.Initialize();
Debug.Print("IHM created");
fenetreSelection = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.fenetreSelection));
Glide.MainWindow = fenetreSelection;
//Charge le fichier XML pour la fenetre de selection
fenetreAffichage = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.fenetreAffichage)); // -- -- -- -- -- -- -- -- -- -- -- -- -- d'affichage
fenetrePhase = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.fenetrePhase));
Debug.Print("IHM completed");
Glide.FitToScreen = true; //Dimensionne la fenetre pour l'adapter à l'écran LCD
}
/// <summary>
/// Selection de l'équipe et de la disposition du terrais parmi les 5 différentes
/// </summary>
///
///
public Couleur getEquipe()
{
return m_equipe;
}
public int getDisposition()
{
return m_disposition;
}
public void retourPhase(Couleurs couleur)
{
switch(couleur)
{
case Couleurs.rouge :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Red;
break;
case Couleurs.orange :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Orange;
break;
case Couleurs.jaune :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Yellow;
break;
case Couleurs.vert :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Green;
break;
case Couleurs.bleu :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Blue;
break;
case Couleurs.indigo :
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Cyan;
break;
case Couleurs.violet:
fenetrePhase.BackColor = Microsoft.SPOT.Presentation.Media.Colors.Purple;
break;
}
Glide.MainWindow = fenetrePhase;
}
public void Selection()
{
Glide.MainWindow = fenetreSelection; //Affiche la fenetre de selection sur l'écran LCD
BoutonBleu = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonBleu"); //Créer les différents boutons
BoutonJaune = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonJaune");
BoutonDispo1 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonHomologation");
BoutonDispo2 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo2");
BoutonDispo3 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo3");
BoutonDispo4 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo4");
BoutonDispo5 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo5");
BoutonValider = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonValider");
TexteCouleur = (TextBlock)fenetreSelection.GetChildByName("TexteCouleur"); //Bloc de texte pour la selection (affiche la couleur et la disposition choisie)
TexteDispo = (TextBlock)fenetreSelection.GetChildByName("TexteDispo"); //
BoutonBleu.TapEvent += new OnTap(sender => { m_equipe = Couleur.Bleu;
TexteCouleur.Text = "Equipe bleue";
TexteCouleur.BackColor = (Color)0xE8D630;
fenetreSelection.FillRect(TexteCouleur.Rect);
TexteCouleur.Invalidate(); });
BoutonJaune.TapEvent += new OnTap(sender => { m_equipe = Couleur.Jaune;
TexteCouleur.Text = "Equipe jaune";
TexteCouleur.BackColor = (Color)0x1E7FCB;
fenetreSelection.FillRect(TexteCouleur.Rect);
TexteCouleur.Invalidate(); });
BoutonDispo1.TapEvent += new OnTap(sender => { m_disposition = 1;
TexteDispo.Text = "Stratégie 1";
fenetreSelection.FillRect(TexteDispo.Rect);
TexteDispo.Invalidate(); });
BoutonDispo2.TapEvent += new OnTap(sender => { m_disposition = 2;
TexteDispo.Text = "Stratégie 2";
fenetreSelection.FillRect(TexteDispo.Rect);
TexteDispo.Invalidate(); });
BoutonDispo3.TapEvent += new OnTap(sender => { m_disposition = 3;
TexteDispo.Text = "Dispo. no. 3";
fenetreSelection.FillRect(TexteDispo.Rect);
TexteDispo.Invalidate(); });
BoutonDispo4.TapEvent += new OnTap(sender => { m_disposition = 4;
TexteDispo.Text = "Dispo. no. 4";
fenetreSelection.FillRect(TexteDispo.Rect);
TexteDispo.Invalidate(); });
BoutonDispo5.TapEvent += new OnTap(sender => { m_disposition = 5;
TexteDispo.Text = "Dispo. no. 5";
fenetreSelection.FillRect(TexteDispo.Rect);
TexteDispo.Invalidate(); });
while (m_equipe == Couleur.Null || m_disposition == 0) //Execution de la boucle tant que l'equipe et la disposition du terrain ne sont pas validés
while (validation == false)
{
BoutonValider.TapEvent += new OnTap(sender => { validation = true; });
}
Fermer(); //ferme la fenetre de selection
Glide.MainWindow = fenetreAffichage; //Affiche la fenetre d'affichage sur l'écran LCD
TexteAffichage = (TextBlock)fenetreAffichage.GetChildByName("TexteAffichage"); //Bloc de texte pour l'affichage des instructions
}
/// <summary>
/// Affiche un message sur l'IHM
/// </summary>
/// <param name="message">Message a afficher sur l'IHM</param>
public void Afficher(string message)
{
//TexteAffichage.Font.ComputeTextInRect("", out largeurLigne, out hauteurLigne); //Retourne la largeur d'une ligne et la hauteur d'une ligne
//nbLignes = TexteAffichage.Height / hauteurLigne;
TexteAffichage.Text = message + '\n';
fenetreAffichage.FillRect(TexteAffichage.Rect);
TexteAffichage.Invalidate();
Thread.Sleep(500); //test
}
/// <summary>
/// Ferme la fenetre
/// </summary>
public void Fermer()
{
Glide.MainWindow = null;
Glide.Screen.Clear();
Glide.Screen.Flush();
}
}
}