13 using System.Windows.Threading; |
13 using System.Windows.Threading; |
14 using Microsoft.Surface; |
14 using Microsoft.Surface; |
15 using Microsoft.Surface.Presentation; |
15 using Microsoft.Surface.Presentation; |
16 using Microsoft.Surface.Presentation.Controls; |
16 using Microsoft.Surface.Presentation.Controls; |
17 |
17 |
|
18 using FingersDance.Control.UserPanel; |
|
19 |
18 namespace FingersDance |
20 namespace FingersDance |
19 { |
21 { |
20 /// <summary> |
22 /// <summary> |
21 /// Interaction logic for SurfaceWindow1.xaml |
23 /// Interaction logic for SurfaceWindow1.xaml |
22 /// </summary> |
24 /// </summary> |
24 { |
26 { |
25 /// <summary> |
27 /// <summary> |
26 /// Default constructor. |
28 /// Default constructor. |
27 /// </summary> |
29 /// </summary> |
28 /// |
30 /// |
|
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 |
29 |
37 |
30 ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator(); |
38 ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator(); |
31 |
39 |
32 public SurfaceWindow1() |
40 public SurfaceWindow1() |
33 { |
41 { |
34 InitializeComponent(); |
42 InitializeComponent(); |
35 |
43 |
|
44 //Permet d'initialiser l'inertie du Pivot une fois relaché. |
|
45 InitPivotInertia(); |
36 //Permet d'initialiser les quand Grid à la position initiale du pivot |
46 //Permet d'initialiser les quand Grid à la position initiale du pivot |
37 InitGridPositions(); |
47 InitGridPositions(); |
38 // Add handlers for Application activation events |
48 // Add handlers for Application activation events |
39 AddActivationHandlers(); |
49 AddActivationHandlers(); |
|
50 } |
|
51 |
|
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) { } |
40 } |
60 } |
41 |
61 |
42 private void InitGridPositions() |
62 private void InitGridPositions() |
43 { |
63 { |
44 //Initialise les 4 Grids à la positions initiale du Pivot. |
64 //Initialise les 4 Grids à la positions initiale du Pivot. |
133 try |
153 try |
134 { |
154 { |
135 Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
155 Grid1.Width = e.GetPosition(mainSurfaceWindow).X; |
136 Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
156 Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; |
137 |
157 |
138 Grid2.Width = e.GetPosition(mainSurfaceWindow).X; |
158 Grid3.Width = e.GetPosition(mainSurfaceWindow).X; |
139 Grid2.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
|
140 |
|
141 Grid3.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
142 Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
159 Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
143 |
160 |
144 Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
161 Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
145 Grid4.Height = e.GetPosition(mainSurfaceWindow).Y; |
162 Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; |
|
163 |
|
164 Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; |
|
165 Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; |
146 } |
166 } |
147 catch (Exception ex) { } |
167 catch (Exception ex) { } |
148 } |
168 } |
|
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 } |
149 } |
213 } |
150 } |
214 } |