author | PAMPHILE Jonathan <pamphile@efrei.fr> |
Thu, 24 Sep 2009 15:20:59 +0200 | |
changeset 104 | 1a428e733fea |
parent 97 | 31b24064b28f |
child 112 | 08bc8eac9e71 |
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 |
34 |
private bool isCreatedP1 = false; |
|
35 |
private bool isCreatedP2 = false; |
|
36 |
private bool isCreatedP3 = false; |
|
37 |
private bool isCreatedP4 = false; |
|
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) |
153 |
{ |
|
154 |
//Permet la MAJ des 4 Grids � la position du pivot |
|
155 |
/*try |
|
156 |
{ |
|
157 |
Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
|
158 |
Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
159 |
||
160 |
Grid3.Width = e.GetPosition(mainSurfaceWindow).X; |
|
161 |
Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
|
162 |
||
163 |
Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
164 |
Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
|
165 |
||
166 |
Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
167 |
Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
168 |
} |
|
169 |
catch (Exception ex) { }*/ |
|
170 |
} |
|
171 |
||
172 |
private void ScatterViewItemPivot_ContactChanged(object sender, ContactEventArgs e) |
|
45 | 173 |
{ |
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
174 |
//Permet la MAJ des 4 Grids � la position du pivot |
45 | 175 |
try |
176 |
{ |
|
177 |
Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
|
178 |
Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
179 |
||
60 | 180 |
Grid3.Width = e.GetPosition(mainSurfaceWindow).X; |
45 | 181 |
Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
182 |
||
183 |
Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
60 | 184 |
Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
185 |
||
186 |
Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
187 |
Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
89 | 188 |
|
91 | 189 |
//GRISAGE |
190 |
//Grid1 |
|
191 |
if (Grid1.Width < (1024 / 4) || Grid2.Height < (768 / 4)) |
|
89 | 192 |
{ |
91 | 193 |
try |
194 |
{Grid1.Children[1].Visibility = Visibility.Hidden;} |
|
195 |
catch (Exception) { } |
|
89 | 196 |
} |
91 | 197 |
else |
198 |
{ |
|
199 |
try |
|
200 |
{ Grid1.Children[1].Visibility = Visibility.Visible; } |
|
201 |
catch (Exception) { } |
|
202 |
} |
|
203 |
//Grid2 |
|
204 |
if (Grid2.Width < (1024 / 4) || Grid2.Height < (768 / 4)) |
|
89 | 205 |
{ |
91 | 206 |
try |
207 |
{ Grid2.Children[1].Visibility = Visibility.Hidden; } |
|
208 |
catch (Exception) { } |
|
209 |
} |
|
210 |
else |
|
211 |
{ |
|
212 |
try |
|
213 |
{ Grid2.Children[1].Visibility = Visibility.Visible; } |
|
214 |
catch (Exception) { } |
|
89 | 215 |
} |
91 | 216 |
//Grid3 |
217 |
if (Grid3.Width < (1024 / 4) || Grid3.Height < (768 / 4)) |
|
89 | 218 |
{ |
91 | 219 |
try |
220 |
{ Grid3.Children[1].Visibility = Visibility.Hidden; } |
|
221 |
catch (Exception) { } |
|
222 |
} |
|
223 |
else |
|
224 |
{ |
|
225 |
try |
|
226 |
{ Grid3.Children[1].Visibility = Visibility.Visible; } |
|
227 |
catch (Exception) { } |
|
89 | 228 |
} |
91 | 229 |
//Grid4 |
230 |
if (Grid4.Width < (1024 / 4) || Grid4.Height < (768 / 4)) |
|
89 | 231 |
{ |
91 | 232 |
try |
233 |
{ Grid4.Children[1].Visibility = Visibility.Hidden; } |
|
234 |
catch (Exception) { } |
|
89 | 235 |
} |
91 | 236 |
else |
237 |
{ |
|
238 |
try |
|
239 |
{ Grid4.Children[1].Visibility = Visibility.Visible; } |
|
240 |
catch (Exception) { } |
|
241 |
} |
|
45 | 242 |
} |
91 | 243 |
catch (Exception) { } |
45 | 244 |
} |
60 | 245 |
|
246 |
private void UserControlPivot_EH_SurfaceButtonPlayer1_ContactDown(object sender, EventArgs e) |
|
247 |
{ |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
248 |
|
60 | 249 |
if (!isCreatedP1) |
250 |
{ |
|
82 | 251 |
//1-Creation du control Screen |
252 |
UserControlScreen Screen1 = new UserControlScreen(); |
|
253 |
Screen1.Name = "Screen1"; |
|
254 |
Screen1.contexteGrid = Grid1.Name.ToString(); |
|
255 |
//2-Rajout du screen dans la grid correspondante |
|
256 |
Grid1.Children.Add(Screen1); |
|
257 |
||
104 | 258 |
Screen1.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
60 | 259 |
} |
260 |
} |
|
261 |
||
262 |
private void UserControlPivot_EH_SurfaceButtonPlayer2_ContactDown(object sender, EventArgs e) |
|
263 |
{ |
|
264 |
if (!isCreatedP2) |
|
265 |
{ |
|
104 | 266 |
|
60 | 267 |
} |
268 |
} |
|
269 |
||
270 |
private void UserControlPivot_EH_SurfaceButtonPlayer3_ContactDown(object sender, EventArgs e) |
|
271 |
{ |
|
272 |
if (!isCreatedP3) |
|
273 |
{ |
|
274 |
UserControlUserPanel UserPanel3 = new UserControlUserPanel(); |
|
275 |
UserPanel3.Name = "UserPanel3"; |
|
276 |
Grid3.Children.Add(UserPanel3); |
|
277 |
isCreatedP3 = true; |
|
278 |
} |
|
279 |
} |
|
280 |
||
281 |
private void UserControlPivot_EH_SurfaceButtonPlayer4_ContactDown(object sender, EventArgs e) |
|
282 |
{ |
|
283 |
if (!isCreatedP4) |
|
284 |
{ |
|
285 |
UserControlUserPanel UserPanel4 = new UserControlUserPanel(); |
|
286 |
UserPanel4.Name = "UserPanel4"; |
|
287 |
Grid4.Children.Add(UserPanel4); |
|
288 |
isCreatedP4 = true; |
|
289 |
} |
|
290 |
} |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
291 |
|
104 | 292 |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
293 |
|
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
294 |
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
|
295 |
{ |
73 | 296 |
//ToDo |
297 |
} |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
298 |
|
73 | 299 |
//Button Submit du control SessionInput |
300 |
private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
|
301 |
{ |
|
302 |
try |
|
303 |
{ |
|
82 | 304 |
//3-Suppression du UC Screen |
104 | 305 |
Grid root = (Grid)(((UserControlScreen)sender).Parent); |
306 |
root.Children.Remove(((UserControlScreen)sender)); |
|
82 | 307 |
//4-Creation du User Panel |
73 | 308 |
UserControlUserPanel UserPanel1 = new UserControlUserPanel(); |
309 |
UserPanel1.Name = "UserPanel1"; |
|
82 | 310 |
//5-Rajout sur la Grid Root |
311 |
root.Children.Add(UserPanel1); |
|
73 | 312 |
|
313 |
} |
|
314 |
catch (Exception ex) { } |
|
72
f1ca0958c992
Travail sur le control List Video et comunication entre ListVideo et FingersDance
sarias
parents:
60
diff
changeset
|
315 |
} |
73 | 316 |
|
77 | 317 |
|
318 |
||
45 | 319 |
} |
320 |
} |