author | sarias |
Tue, 15 Sep 2009 16:57:45 +0200 | |
changeset 60 | b4008a356f90 |
parent 58 | d7313fb1806c |
child 72 | f1ca0958c992 |
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; |
19 |
||
45 | 20 |
namespace FingersDance |
21 |
{ |
|
22 |
/// <summary> |
|
23 |
/// Interaction logic for SurfaceWindow1.xaml |
|
24 |
/// </summary> |
|
25 |
public partial class SurfaceWindow1 : SurfaceWindow |
|
26 |
{ |
|
27 |
/// <summary> |
|
28 |
/// Default constructor. |
|
29 |
/// </summary> |
|
54
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
30 |
/// |
60 | 31 |
#region Variables |
32 |
private bool isCreatedP1 = false; |
|
33 |
private bool isCreatedP2 = false; |
|
34 |
private bool isCreatedP3 = false; |
|
35 |
private bool isCreatedP4 = false; |
|
36 |
#endregion |
|
54
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
37 |
|
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
38 |
ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator(); |
c724ac229181
Singleton de la factory
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
45
diff
changeset
|
39 |
|
45 | 40 |
public SurfaceWindow1() |
41 |
{ |
|
42 |
InitializeComponent(); |
|
43 |
||
60 | 44 |
//Permet d'initialiser l'inertie du Pivot une fois relach�. |
45 |
InitPivotInertia(); |
|
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
46 |
//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
|
47 |
InitGridPositions(); |
45 | 48 |
// Add handlers for Application activation events |
49 |
AddActivationHandlers(); |
|
50 |
} |
|
51 |
||
60 | 52 |
private void InitPivotInertia() |
53 |
{ |
|
54 |
try |
|
55 |
{ |
|
56 |
ScatterViewItem item = (ScatterViewItem)ScaterView.Items.GetItemAt(0); |
|
57 |
item.DecelerationRate = double.NaN; |
|
58 |
} |
|
59 |
catch (Exception ex) { } |
|
60 |
} |
|
61 |
||
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
62 |
private void InitGridPositions() |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
63 |
{ |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
64 |
//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
|
65 |
try |
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 |
ScatterViewItem item = (ScatterViewItem)ScaterView.Items.GetItemAt(0); |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
74 |
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
|
75 |
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
|
76 |
|
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
77 |
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
|
78 |
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
|
79 |
} |
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
80 |
catch (Exception ex) { } |
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 |
|
45 | 83 |
|
84 |
/// <summary> |
|
85 |
/// Occurs when the window is about to close. |
|
86 |
/// </summary> |
|
87 |
/// <param name="e"></param> |
|
88 |
protected override void OnClosed(EventArgs e) |
|
89 |
{ |
|
90 |
base.OnClosed(e); |
|
91 |
||
92 |
// Remove handlers for Application activation events |
|
93 |
RemoveActivationHandlers(); |
|
94 |
} |
|
95 |
||
96 |
/// <summary> |
|
97 |
/// Adds handlers for Application activation events. |
|
98 |
/// </summary> |
|
99 |
private void AddActivationHandlers() |
|
100 |
{ |
|
101 |
// Subscribe to surface application activation events |
|
102 |
ApplicationLauncher.ApplicationActivated += OnApplicationActivated; |
|
103 |
ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; |
|
104 |
ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; |
|
105 |
} |
|
106 |
||
107 |
/// <summary> |
|
108 |
/// Removes handlers for Application activation events. |
|
109 |
/// </summary> |
|
110 |
private void RemoveActivationHandlers() |
|
111 |
{ |
|
112 |
// Unsubscribe from surface application activation events |
|
113 |
ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; |
|
114 |
ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; |
|
115 |
ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; |
|
116 |
} |
|
117 |
||
118 |
/// <summary> |
|
119 |
/// This is called when application has been activated. |
|
120 |
/// </summary> |
|
121 |
/// <param name="sender"></param> |
|
122 |
/// <param name="e"></param> |
|
123 |
private void OnApplicationActivated(object sender, EventArgs e) |
|
124 |
{ |
|
125 |
//TODO: enable audio, animations here |
|
126 |
} |
|
127 |
||
128 |
/// <summary> |
|
129 |
/// This is called when application is in preview mode. |
|
130 |
/// </summary> |
|
131 |
/// <param name="sender"></param> |
|
132 |
/// <param name="e"></param> |
|
133 |
private void OnApplicationPreviewed(object sender, EventArgs e) |
|
134 |
{ |
|
135 |
//TODO: Disable audio here if it is enabled |
|
136 |
||
137 |
//TODO: optionally enable animations here |
|
138 |
} |
|
139 |
||
140 |
/// <summary> |
|
141 |
/// This is called when application has been deactivated. |
|
142 |
/// </summary> |
|
143 |
/// <param name="sender"></param> |
|
144 |
/// <param name="e"></param> |
|
145 |
private void OnApplicationDeactivated(object sender, EventArgs e) |
|
146 |
{ |
|
147 |
//TODO: disable audio, animations here |
|
148 |
} |
|
149 |
||
150 |
private void ScaterView_ContactChanged(object sender, ContactEventArgs e) |
|
151 |
{ |
|
58
d7313fb1806c
Initialisation de la position du Pivot au centre et des positions des 4 Grids
sarias
parents:
54
diff
changeset
|
152 |
//Permet la MAJ des 4 Grids � la position du pivot |
45 | 153 |
try |
154 |
{ |
|
155 |
Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
|
156 |
Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
157 |
||
60 | 158 |
Grid3.Width = e.GetPosition(mainSurfaceWindow).X; |
45 | 159 |
Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
160 |
||
161 |
Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
60 | 162 |
Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
163 |
||
164 |
Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
165 |
Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; |
|
45 | 166 |
} |
167 |
catch (Exception ex) { } |
|
168 |
} |
|
60 | 169 |
|
170 |
private void UserControlPivot_EH_SurfaceButtonPlayer1_ContactDown(object sender, EventArgs e) |
|
171 |
{ |
|
172 |
if (!isCreatedP1) |
|
173 |
{ |
|
174 |
UserControlUserPanel UserPanel1 = new UserControlUserPanel(); |
|
175 |
UserPanel1.Name = "UserPanel1"; |
|
176 |
Grid1.Children.Add(UserPanel1); |
|
177 |
isCreatedP1 = true; |
|
178 |
} |
|
179 |
} |
|
180 |
||
181 |
private void UserControlPivot_EH_SurfaceButtonPlayer2_ContactDown(object sender, EventArgs e) |
|
182 |
{ |
|
183 |
if (!isCreatedP2) |
|
184 |
{ |
|
185 |
UserControlUserPanel UserPanel2 = new UserControlUserPanel(); |
|
186 |
UserPanel2.Name = "UserPanel2"; |
|
187 |
Grid2.Children.Add(UserPanel2); |
|
188 |
isCreatedP2 = true; |
|
189 |
} |
|
190 |
} |
|
191 |
||
192 |
private void UserControlPivot_EH_SurfaceButtonPlayer3_ContactDown(object sender, EventArgs e) |
|
193 |
{ |
|
194 |
if (!isCreatedP3) |
|
195 |
{ |
|
196 |
UserControlUserPanel UserPanel3 = new UserControlUserPanel(); |
|
197 |
UserPanel3.Name = "UserPanel3"; |
|
198 |
Grid3.Children.Add(UserPanel3); |
|
199 |
isCreatedP3 = true; |
|
200 |
} |
|
201 |
} |
|
202 |
||
203 |
private void UserControlPivot_EH_SurfaceButtonPlayer4_ContactDown(object sender, EventArgs e) |
|
204 |
{ |
|
205 |
if (!isCreatedP4) |
|
206 |
{ |
|
207 |
UserControlUserPanel UserPanel4 = new UserControlUserPanel(); |
|
208 |
UserPanel4.Name = "UserPanel4"; |
|
209 |
Grid4.Children.Add(UserPanel4); |
|
210 |
isCreatedP4 = true; |
|
211 |
} |
|
212 |
} |
|
45 | 213 |
} |
214 |
} |