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