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