author | sarias |
Wed, 23 Sep 2009 11:10:02 +0200 | |
changeset 82 | c37122b567fa |
parent 77 | e95e916eb018 |
child 89 | f9a931434910 |
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; |
|
45 | 190 |
} |
191 |
catch (Exception ex) { } |
|
192 |
} |
|
60 | 193 |
|
194 |
private void UserControlPivot_EH_SurfaceButtonPlayer1_ContactDown(object sender, EventArgs e) |
|
195 |
{ |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
196 |
|
60 | 197 |
if (!isCreatedP1) |
198 |
{ |
|
82 | 199 |
//1-Creation du control Screen |
200 |
UserControlScreen Screen1 = new UserControlScreen(); |
|
201 |
Screen1.Name = "Screen1"; |
|
202 |
Screen1.contexteGrid = Grid1.Name.ToString(); |
|
203 |
//2-Rajout du screen dans la grid correspondante |
|
204 |
Grid1.Children.Add(Screen1); |
|
205 |
||
206 |
//3-Creation de la ListVideo |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
207 |
UserControlListVideo ListVideo1 = new UserControlListVideo(); |
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
208 |
ListVideo1.Name = "ListVideo1"; |
77 | 209 |
|
82 | 210 |
//4-Ajout de la ListVideo au ControlScreen |
211 |
Screen1.AddToGrid(ListVideo1); |
|
77 | 212 |
|
82 | 213 |
//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
|
214 |
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
|
215 |
ListVideo1.EH_ItemVideo2_ContactDown += new System.EventHandler(this.ListVideo1_EH_ItemVideo2_ContactDown); |
82 | 216 |
|
60 | 217 |
} |
218 |
} |
|
219 |
||
220 |
private void UserControlPivot_EH_SurfaceButtonPlayer2_ContactDown(object sender, EventArgs e) |
|
221 |
{ |
|
222 |
if (!isCreatedP2) |
|
223 |
{ |
|
224 |
UserControlUserPanel UserPanel2 = new UserControlUserPanel(); |
|
225 |
UserPanel2.Name = "UserPanel2"; |
|
226 |
Grid2.Children.Add(UserPanel2); |
|
227 |
isCreatedP2 = true; |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
private void UserControlPivot_EH_SurfaceButtonPlayer3_ContactDown(object sender, EventArgs e) |
|
232 |
{ |
|
233 |
if (!isCreatedP3) |
|
234 |
{ |
|
235 |
UserControlUserPanel UserPanel3 = new UserControlUserPanel(); |
|
236 |
UserPanel3.Name = "UserPanel3"; |
|
237 |
Grid3.Children.Add(UserPanel3); |
|
238 |
isCreatedP3 = true; |
|
239 |
} |
|
240 |
} |
|
241 |
||
242 |
private void UserControlPivot_EH_SurfaceButtonPlayer4_ContactDown(object sender, EventArgs e) |
|
243 |
{ |
|
244 |
if (!isCreatedP4) |
|
245 |
{ |
|
246 |
UserControlUserPanel UserPanel4 = new UserControlUserPanel(); |
|
247 |
UserPanel4.Name = "UserPanel4"; |
|
248 |
Grid4.Children.Add(UserPanel4); |
|
249 |
isCreatedP4 = true; |
|
250 |
} |
|
251 |
} |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
252 |
|
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
253 |
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
|
254 |
{ |
77 | 255 |
|
256 |
//Creation d'un ScatterView Item |
|
257 |
//ScatterViewItem scatterViewItemSessionInput = new ScatterViewItem(); |
|
258 |
//scatterViewItemSessionInput.Name = "ScatterViewItemSessionInput"; |
|
259 |
|
|
260 |
|
|
82 | 261 |
//1-Creation d'une nouvelle seance. |
73 | 262 |
UserControlSessionInput SessionInput = new UserControlSessionInput(); |
263 |
SessionInput.Name = "SessionInput"; |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
264 |
|
73 | 265 |
try{ |
82 | 266 |
//2-Recuperer la Grid qui contient le UCListVideo et l'ajouter. |
73 | 267 |
Grid actualGrid = (Grid)(((UserControlListVideo)sender).Parent); |
268 |
actualGrid.Children.Add(SessionInput); |
|
269 |
||
82 | 270 |
//3-Creation des Events |
73 | 271 |
SessionInput.EH_SurfaceButtonSubmit_ContactDown += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
82 | 272 |
//4-Supression du UC List Video |
73 | 273 |
actualGrid.Children.Remove((UserControlListVideo)sender); |
77 | 274 |
|
82 | 275 |
|
77 | 276 |
//Init Scatter View Properties and Add it to the scatter view. |
277 |
/*scatterViewItemSessionInput.Content = SessionInput; |
|
278 |
scatterViewItemSessionInput.CanMove = true; |
|
279 |
scatterViewItemSessionInput.CanScale = false; |
|
280 |
scatterViewItemSessionInput.CanRotate = true; |
|
281 |
scatterViewItemSessionInput.Center = new Point((double)actualGrid.ActualWidth,(double)actualGrid.ActualHeight); |
|
282 |
scaterview.Items.Add(scatterViewItemSessionInput);*/ |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
283 |
} |
73 | 284 |
catch (Exception ex) { } |
285 |
isCreatedP1 = true; |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
286 |
} |
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
287 |
|
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
288 |
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
|
289 |
{ |
73 | 290 |
//ToDo |
291 |
} |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
292 |
|
73 | 293 |
//Button Submit du control SessionInput |
294 |
private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
|
295 |
{ |
|
296 |
try |
|
297 |
{ |
|
82 | 298 |
//1-Recuperation de actualGrid (LayoutRoot du UC Screen) |
73 | 299 |
Grid actualGrid = (Grid)(((UserControlSessionInput)sender).Parent); |
82 | 300 |
//2-Suppression UCSession Input |
73 | 301 |
actualGrid.Children.Remove((UserControlSessionInput)sender); |
82 | 302 |
//3-Suppression du UC Screen |
303 |
Grid root = (Grid) ((UserControlScreen)actualGrid.Parent).Parent; |
|
304 |
root.Children.Remove((UserControlScreen)actualGrid.Parent); |
|
305 |
//4-Creation du User Panel |
|
73 | 306 |
UserControlUserPanel UserPanel1 = new UserControlUserPanel(); |
307 |
UserPanel1.Name = "UserPanel1"; |
|
82 | 308 |
//5-Rajout sur la Grid Root |
309 |
root.Children.Add(UserPanel1); |
|
73 | 310 |
|
311 |
} |
|
312 |
catch (Exception ex) { } |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
313 |
} |
73 | 314 |
|
77 | 315 |
|
316 |
||
45 | 317 |
} |
318 |
} |