author | sarias |
Mon, 05 Oct 2009 18:29:32 +0200 | |
changeset 131 | 9331c3dea175 |
parent 119 | 7a370bfb4d77 |
child 132 | bc7c039b4bff |
permissions | -rw-r--r-- |
45 | 1 |
using System; |
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Windows; |
|
6 |
using System.Windows.Controls; |
|
7 |
using System.Windows.Data; |
|
8 |
using System.Windows.Documents; |
|
9 |
using System.Windows.Input; |
|
10 |
using System.Windows.Media; |
|
11 |
using System.Windows.Media.Imaging; |
|
12 |
using System.Windows.Shapes; |
|
13 |
using System.Windows.Threading; |
|
14 |
using Microsoft.Surface; |
|
15 |
using Microsoft.Surface.Presentation; |
|
16 |
using Microsoft.Surface.Presentation.Controls; |
|
17 |
||
60 | 18 |
using FingersDance.Control.UserPanel; |
82 | 19 |
using FingersDance.Control.Screen; |
131 | 20 |
using FingersDance.Control.Close; |
82 | 21 |
|
60 | 22 |
|
45 | 23 |
namespace FingersDance |
24 |
{ |
|
25 |
/// <summary> |
|
26 |
/// Interaction logic for SurfaceWindow1.xaml |
|
27 |
/// </summary> |
|
28 |
public partial class SurfaceWindow1 : SurfaceWindow |
|
29 |
{ |
|
30 |
/// <summary> |
|
31 |
/// Default constructor. |
|
32 |
/// </summary> |
|
54
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
33 |
/// |
60 | 34 |
#region Variables |
112 | 35 |
private UserControlUserPanel Panel1 = null; |
36 |
private UserControlUserPanel Panel2 = null; |
|
37 |
private UserControlUserPanel Panel3 = null; |
|
38 |
private UserControlUserPanel Panel4 = null; |
|
60 | 39 |
#endregion |
54
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
40 |
|
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
41 |
ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator(); |
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
42 |
|
45 | 43 |
public SurfaceWindow1() |
44 |
{ |
|
45 |
InitializeComponent(); |
|
46 |
||
60 | 47 |
//Permet d'initialiser l'inertie du Pivot une fois relach�. |
48 |
InitPivotInertia(); |
|
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
49 |
//Permet d'initialiser les quand Grid � la position initiale du pivot |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
50 |
InitGridPositions(); |
45 | 51 |
// Add handlers for Application activation events |
52 |
AddActivationHandlers(); |
|
53 |
} |
|
54 |
||
60 | 55 |
private void InitPivotInertia() |
56 |
{ |
|
57 |
try |
|
58 |
{ |
|
77 | 59 |
ScatterViewItem item = (ScatterViewItem)scaterview.Items.GetItemAt(0); |
60 | 60 |
item.DecelerationRate = double.NaN; |
61 |
} |
|
62 |
catch (Exception ex) { } |
|
63 |
} |
|
64 |
||
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
65 |
private void InitGridPositions() |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
66 |
{ |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
67 |
//Initialise les 4 Grids � la positions initiale du Pivot. |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
68 |
try |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
69 |
{ |
77 | 70 |
ScatterViewItem item = (ScatterViewItem)scaterview.Items.GetItemAt(0); |
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
71 |
Grid1.Width =item.Center.X; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
72 |
Grid1.Height = item.Center.Y; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
73 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
74 |
Grid2.Width = item.Center.X; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
75 |
Grid2.Height = 768 - item.Center.Y; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
76 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
77 |
Grid3.Width = 1024 - item.Center.X; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
78 |
Grid3.Height = 768 - item.Center.Y; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
79 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
80 |
Grid4.Width = 1024 - item.Center.X; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
81 |
Grid4.Height = item.Center.Y; |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
82 |
} |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
83 |
catch (Exception ex) { } |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
84 |
} |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
85 |
|
45 | 86 |
|
87 |
/// <summary> |
|
88 |
/// Occurs when the window is about to close. |
|
89 |
/// </summary> |
|
90 |
/// <param name="e"></param> |
|
91 |
protected override void OnClosed(EventArgs e) |
|
92 |
{ |
|
93 |
base.OnClosed(e); |
|
94 |
||
95 |
// Remove handlers for Application activation events |
|
96 |
RemoveActivationHandlers(); |
|
97 |
} |
|
98 |
||
99 |
/// <summary> |
|
100 |
/// Adds handlers for Application activation events. |
|
101 |
/// </summary> |
|
102 |
private void AddActivationHandlers() |
|
103 |
{ |
|
104 |
// Subscribe to surface application activation events |
|
105 |
ApplicationLauncher.ApplicationActivated += OnApplicationActivated; |
|
106 |
ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; |
|
107 |
ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; |
|
108 |
} |
|
109 |
||
110 |
/// <summary> |
|
111 |
/// Removes handlers for Application activation events. |
|
112 |
/// </summary> |
|
113 |
private void RemoveActivationHandlers() |
|
114 |
{ |
|
115 |
// Unsubscribe from surface application activation events |
|
116 |
ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; |
|
117 |
ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; |
|
118 |
ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; |
|
119 |
} |
|
120 |
||
121 |
/// <summary> |
|
122 |
/// This is called when application has been activated. |
|
123 |
/// </summary> |
|
124 |
/// <param name="sender"></param> |
|
125 |
/// <param name="e"></param> |
|
126 |
private void OnApplicationActivated(object sender, EventArgs e) |
|
127 |
{ |
|
128 |
//TODO: enable audio, animations here |
|
129 |
} |
|
130 |
||
131 |
/// <summary> |
|
132 |
/// This is called when application is in preview mode. |
|
133 |
/// </summary> |
|
134 |
/// <param name="sender"></param> |
|
135 |
/// <param name="e"></param> |
|
136 |
private void OnApplicationPreviewed(object sender, EventArgs e) |
|
137 |
{ |
|
138 |
//TODO: Disable audio here if it is enabled |
|
139 |
||
140 |
//TODO: optionally enable animations here |
|
141 |
} |
|
142 |
||
143 |
/// <summary> |
|
144 |
/// This is called when application has been deactivated. |
|
145 |
/// </summary> |
|
146 |
/// <param name="sender"></param> |
|
147 |
/// <param name="e"></param> |
|
148 |
private void OnApplicationDeactivated(object sender, EventArgs e) |
|
149 |
{ |
|
150 |
//TODO: disable audio, animations here |
|
151 |
} |
|
152 |
||
77 | 153 |
private void scaterview_ContactChanged(object sender, ContactEventArgs e) |
112 | 154 |
{ } |
77 | 155 |
|
156 |
private void ScatterViewItemPivot_ContactChanged(object sender, ContactEventArgs e) |
|
45 | 157 |
{ |
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
158 |
//Permet la MAJ des 4 Grids � la position du pivot |
45 | 159 |
try |
160 |
{ |
|
161 |
Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
|
162 |
Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
163 |
||
60 | 164 |
Grid3.Width = e.GetPosition(mainSurfaceWindow).X; |
45 | 165 |
Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
166 |
||
167 |
Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
60 | 168 |
Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
169 |
||
170 |
Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
171 |
Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
89 | 172 |
|
91 | 173 |
//GRISAGE |
174 |
//Grid1 |
|
175 |
if (Grid1.Width < (1024 / 4) || Grid2.Height < (768 / 4)) |
|
89 | 176 |
{ |
91 | 177 |
try |
178 |
{Grid1.Children[1].Visibility = Visibility.Hidden;} |
|
179 |
catch (Exception) { } |
|
89 | 180 |
} |
91 | 181 |
else |
182 |
{ |
|
183 |
try |
|
184 |
{ Grid1.Children[1].Visibility = Visibility.Visible; } |
|
185 |
catch (Exception) { } |
|
186 |
} |
|
187 |
//Grid2 |
|
188 |
if (Grid2.Width < (1024 / 4) || Grid2.Height < (768 / 4)) |
|
89 | 189 |
{ |
91 | 190 |
try |
191 |
{ Grid2.Children[1].Visibility = Visibility.Hidden; } |
|
192 |
catch (Exception) { } |
|
193 |
} |
|
194 |
else |
|
195 |
{ |
|
196 |
try |
|
197 |
{ Grid2.Children[1].Visibility = Visibility.Visible; } |
|
198 |
catch (Exception) { } |
|
89 | 199 |
} |
91 | 200 |
//Grid3 |
201 |
if (Grid3.Width < (1024 / 4) || Grid3.Height < (768 / 4)) |
|
89 | 202 |
{ |
91 | 203 |
try |
204 |
{ Grid3.Children[1].Visibility = Visibility.Hidden; } |
|
205 |
catch (Exception) { } |
|
206 |
} |
|
207 |
else |
|
208 |
{ |
|
209 |
try |
|
210 |
{ Grid3.Children[1].Visibility = Visibility.Visible; } |
|
211 |
catch (Exception) { } |
|
89 | 212 |
} |
91 | 213 |
//Grid4 |
214 |
if (Grid4.Width < (1024 / 4) || Grid4.Height < (768 / 4)) |
|
89 | 215 |
{ |
91 | 216 |
try |
217 |
{ Grid4.Children[1].Visibility = Visibility.Hidden; } |
|
218 |
catch (Exception) { } |
|
89 | 219 |
} |
91 | 220 |
else |
221 |
{ |
|
222 |
try |
|
223 |
{ Grid4.Children[1].Visibility = Visibility.Visible; } |
|
224 |
catch (Exception) { } |
|
225 |
} |
|
45 | 226 |
} |
91 | 227 |
catch (Exception) { } |
45 | 228 |
} |
60 | 229 |
|
112 | 230 |
private void UserControlPivot_EH_SurfaceButtonPlayer_ContactDown(object sender, EventArgs e) |
60 | 231 |
{ |
112 | 232 |
switch ((int)sender) |
60 | 233 |
{ |
112 | 234 |
case 1: |
235 |
if (Panel1 == null) |
|
236 |
{ |
|
237 |
//1-Creation du control Screen |
|
238 |
UserControlScreen Screen = new UserControlScreen(1); |
|
239 |
Screen.Name = "Screen1"; |
|
240 |
Screen.contexteGrid = Grid1.Name.ToString(); |
|
241 |
//2-Rajout du screen dans la grid correspondante |
|
242 |
Grid1.Children.Add(Screen); |
|
243 |
||
244 |
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
|
245 |
} |
|
131 | 246 |
else //Affichage du message de confirmation |
247 |
{ |
|
248 |
UserControlClose UCclose = new UserControlClose(1); |
|
249 |
UCclose.Name = "CloseAlert1"; |
|
250 |
Grid1.Children.Add(UCclose); |
|
251 |
UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); |
|
252 |
} |
|
112 | 253 |
break; |
254 |
case 2: |
|
255 |
if (Panel2 == null) |
|
256 |
{ |
|
257 |
//1-Creation du control Screen |
|
258 |
UserControlScreen Screen = new UserControlScreen(2); |
|
259 |
Screen.Name = "Screen2"; |
|
260 |
Screen.contexteGrid = Grid2.Name.ToString(); |
|
261 |
//2-Rajout du screen dans la grid correspondante |
|
262 |
Grid2.Children.Add(Screen); |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
263 |
|
112 | 264 |
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
265 |
} |
|
131 | 266 |
else //Affichage du message de confirmation |
267 |
{ |
|
268 |
UserControlClose UCclose = new UserControlClose(2); |
|
269 |
UCclose.Name = "CloseAlert2"; |
|
270 |
Grid2.Children.Add(UCclose); |
|
271 |
UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); |
|
272 |
} |
|
112 | 273 |
break; |
274 |
case 3: |
|
275 |
if (Panel3 == null) |
|
276 |
{ |
|
277 |
//1-Creation du control Screen |
|
278 |
UserControlScreen Screen = new UserControlScreen(3); |
|
279 |
Screen.Name = "Screen3"; |
|
280 |
Screen.contexteGrid = Grid3.Name.ToString(); |
|
281 |
//2-Rajout du screen dans la grid correspondante |
|
282 |
Grid3.Children.Add(Screen); |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
283 |
|
112 | 284 |
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
285 |
} |
|
131 | 286 |
else //Affichage du message de confirmation |
287 |
{ |
|
288 |
UserControlClose UCclose = new UserControlClose(3); |
|
289 |
UCclose.Name = "CloseAlert3"; |
|
290 |
Grid3.Children.Add(UCclose); |
|
291 |
UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); |
|
292 |
} |
|
112 | 293 |
break; |
294 |
case 4: |
|
295 |
if (Panel4 == null) |
|
296 |
{ |
|
297 |
//1-Creation du control Screen |
|
298 |
UserControlScreen Screen = new UserControlScreen(4); |
|
299 |
Screen.Name = "Screen4"; |
|
300 |
Screen.contexteGrid = Grid4.Name.ToString(); |
|
301 |
//2-Rajout du screen dans la grid correspondante |
|
302 |
Grid4.Children.Add(Screen); |
|
303 |
||
304 |
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
|
305 |
} |
|
131 | 306 |
else //Affichage du message de confirmation |
307 |
{ |
|
308 |
UserControlClose UCclose = new UserControlClose(4); |
|
309 |
UCclose.Name = "CloseAlert4"; |
|
310 |
Grid4.Children.Add(UCclose); |
|
311 |
UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); |
|
312 |
} |
|
112 | 313 |
break; |
314 |
} |
|
315 |
|
|
73 | 316 |
} |
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
317 |
|
73 | 318 |
//Button Submit du control SessionInput |
319 |
private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
|
320 |
{ |
|
321 |
try |
|
322 |
{ |
|
112 | 323 |
//1-Suppression du UC Screen |
104 | 324 |
Grid root = (Grid)(((UserControlScreen)sender).Parent); |
325 |
root.Children.Remove(((UserControlScreen)sender)); |
|
112 | 326 |
//2-Creation du User Panel |
327 |
switch (((UserControlScreen)sender).id) |
|
328 |
{ |
|
329 |
case 1: |
|
119 | 330 |
Panel1 = new UserControlUserPanel(((UserControlScreen)sender).Path); |
112 | 331 |
Panel1.Name = "UserPanel1"; |
332 |
//3-Rajout sur la Grid Root |
|
333 |
root.Children.Add(Panel1); |
|
334 |
break; |
|
335 |
case 2: |
|
119 | 336 |
Panel2 = new UserControlUserPanel(((UserControlScreen)sender).Path); |
112 | 337 |
Panel2.Name = "UserPanel2"; |
338 |
//3-Rajout sur la Grid Root |
|
339 |
root.Children.Add(Panel2); |
|
340 |
break; |
|
341 |
case 3: |
|
119 | 342 |
Panel3 = new UserControlUserPanel(((UserControlScreen)sender).Path); |
112 | 343 |
Panel3.Name = "UserPanel3"; |
344 |
//3-Rajout sur la Grid Root |
|
345 |
root.Children.Add(Panel3); |
|
346 |
break; |
|
347 |
case 4: |
|
119 | 348 |
Panel4 = new UserControlUserPanel(((UserControlScreen)sender).Path); |
112 | 349 |
Panel4.Name = "UserPanel4"; |
350 |
//3-Rajout sur la Grid Root |
|
351 |
root.Children.Add(Panel4); |
|
352 |
break; |
|
353 |
} |
|
73 | 354 |
} |
355 |
catch (Exception ex) { } |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
356 |
} |
73 | 357 |
|
131 | 358 |
//Actions du boutton Alert selon l'action close OK ou NON |
359 |
private void CloseAlert_EH_SurfaceButton_ContactDown(object sender, EventArgs e) |
|
360 |
{ |
|
361 |
Grid root = (Grid)(((UserControlClose)sender).Parent); |
|
362 |
if(((UserControlClose) sender).close) |
|
363 |
{ |
|
364 |
switch(((UserControlClose)sender).Id) |
|
365 |
{ |
|
366 |
case 1: |
|
367 |
root.Children.Remove(Panel1); |
|
368 |
break; |
|
369 |
case 2: |
|
370 |
root.Children.Remove(Panel2); |
|
371 |
break; |
|
372 |
case 3: |
|
373 |
root.Children.Remove(Panel3); |
|
374 |
break; |
|
375 |
case 4: |
|
376 |
root.Children.Remove(Panel4); |
|
377 |
break; |
|
378 |
} |
|
379 |
} |
|
380 |
root.Children.Remove(((UserControlClose)sender)); |
|
381 |
} |
|
77 | 382 |
|
45 | 383 |
} |
384 |
} |