156 userPositionDetector = new UserPositionDetector(debug.getMinDist(), debug.getMaxDist(), debug.getZeroPoint(), debug.getMinDistHands(), debug.getMaxDistHands()); |
156 userPositionDetector = new UserPositionDetector(debug.getMinDist(), debug.getMaxDist(), debug.getZeroPoint(), debug.getMinDistHands(), debug.getMaxDistHands()); |
157 |
157 |
158 //On connecte le serveur à l'adresse locale sur le port 80. |
158 //On connecte le serveur à l'adresse locale sur le port 80. |
159 try |
159 try |
160 { |
160 { |
161 server = new Server(debug.getConnexionHost(), debug.getConnexionPort(), debug.getTimerElapsing()); |
161 server = new Server(debug.getTuioConnexionHost(), debug.getTuioConnexionPort(), debug.getTuioTimerElapsing(), debug.getWsConnexionHost(), debug.getWsConnexionPort(), debug.getWsTimerElapsing()); |
162 //On crée le gestionnaire de modes. |
162 //On crée le gestionnaire de modes. |
163 modeManagement = new ModeManagement(server, debug, this); |
163 modeManagement = new ModeManagement(server, debug, this); |
164 } |
164 } |
165 catch (Exception) |
165 catch (Exception) |
166 { |
166 { |
170 //On écoute l'événement de clic sur le bouton on/off du debug. |
170 //On écoute l'événement de clic sur le bouton on/off du debug. |
171 //Car on lancera l'intitialisation/fermeture de la kinect. |
171 //Car on lancera l'intitialisation/fermeture de la kinect. |
172 debug.getSwitch().Click += new RoutedEventHandler(Switch_ClickInKinectMain); |
172 debug.getSwitch().Click += new RoutedEventHandler(Switch_ClickInKinectMain); |
173 debug.Loaded += new RoutedEventHandler(Window_LoadedInKinectMain); |
173 debug.Loaded += new RoutedEventHandler(Window_LoadedInKinectMain); |
174 debug.Closed += new EventHandler(Window_CloseInKinectMain); |
174 debug.Closed += new EventHandler(Window_CloseInKinectMain); |
175 /*debug.getQuitMenu().Click += new RoutedEventHandler(Quit_ClickInKinectMain); |
|
176 debug.getParametersWindow().getModButton().Click += new RoutedEventHandler(updateParameters);*/ |
|
177 |
|
178 /*Console.WriteLine("DEBUG"); |
|
179 |
|
180 Console.WriteLine("searchMinDistance:" + debug.getMinDistHands()); |
|
181 Console.WriteLine("minDistance:" + debug.getMinDist()); |
|
182 Console.WriteLine("connexionHost:" + debug.getConnexionHost()); |
|
183 Console.WriteLine("timerElapsing:" + debug.getTimerElapsing()); |
|
184 Console.WriteLine("takenPoints:" + debug.getTakenPoints()); |
|
185 Console.WriteLine("directionChangeTresholdXY:" + debug.getDirectionChangeTresholdXY()); |
|
186 Console.WriteLine("connexionPort:" + debug.getConnexionPort()); |
|
187 Console.WriteLine("imagesToShow:" + debug.getImagesToShow()); |
|
188 Console.WriteLine("searchMaxDistance:" + debug.getMaxDistHands()); |
|
189 Console.WriteLine("maxDistance:" + debug.getMaxDist()); |
|
190 Console.WriteLine("zeroPoint:" + debug.getZeroPoint()); |
|
191 Console.WriteLine("directionChangeTresholdZ:" + debug.getDirectionChangeTresholdZ());*/ |
|
192 |
175 |
193 //On affiche la fenêtre de debug. |
176 //On affiche la fenêtre de debug. |
194 try |
177 try |
195 { |
178 { |
196 debug.ShowDialog(); |
179 debug.ShowDialog(); |
197 } |
180 } |
198 catch(Exception){ |
181 catch(Exception){ |
199 } |
182 } |
200 } |
|
201 |
|
202 /*public bool loadParameters() |
|
203 { |
|
204 try |
|
205 { |
|
206 string[] lines = System.IO.File.ReadAllLines(@"config.txt"); |
|
207 |
|
208 foreach (string line in lines) |
|
209 { |
|
210 Console.WriteLine(line); |
|
211 } |
|
212 |
|
213 /*minDistHands = Properties.Settings.Default.searchMinDistance; |
|
214 maxDistHands = Properties.Settings.Default.searchMaxDistance; |
|
215 minDist = Properties.Settings.Default.minDistance; |
|
216 maxDist = Properties.Settings.Default.maxDistance; |
|
217 zeroPoint = Properties.Settings.Default.zeroPoint; |
|
218 connexionHost = Properties.Settings.Default.connexionHost; |
|
219 connexionPort = Properties.Settings.Default.connexionPort; |
|
220 timerElapsing = Properties.Settings.Default.timerElapsing; |
|
221 imagesToShow = Properties.Settings.Default.imagesToShow; |
|
222 takenPoints = Properties.Settings.Default.takenPoints; |
|
223 directionChangeTresholdXY = Properties.Settings.Default.directionChangeTresholdXY; |
|
224 directionChangeTresholdZ = Properties.Settings.Default.directionChangeTresholdZ;*/ |
|
225 /*} |
|
226 catch (Exception) |
|
227 { |
|
228 return false; |
|
229 } |
|
230 |
|
231 if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist || |
|
232 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist || |
|
233 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 || |
|
234 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0) |
|
235 { |
|
236 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect"); |
|
237 Console.WriteLine(ExceptionLbl.Content); |
|
238 return false; |
|
239 } |
|
240 return true; |
|
241 } |
|
242 |
|
243 /* |
|
244 * Envoi les paramètres mis à jour dans les différents modules. |
|
245 */ |
|
246 public void updateParameters(object sender, RoutedEventArgs e) |
|
247 { |
|
248 userPositionDetector.setParams(debug.getMinDist(), debug.getMaxDist(), debug.getMinDistHands(), debug.getMaxDistHands(), debug.getZeroPoint()); |
|
249 server = new Server(debug.getConnexionHost(), debug.getConnexionPort(), debug.getTimerElapsing()); |
|
250 } |
183 } |
251 |
184 |
252 /* |
185 /* |
253 * Initialisation du sensor de la Kinect. |
186 * Initialisation du sensor de la Kinect. |
254 */ |
187 */ |
564 //Si la main droite est dans le champ, on lance l'événement approprié. |
497 //Si la main droite est dans le champ, on lance l'événement approprié. |
565 if (handRight.Position.Z < debug.getMaxDistHands() && handRight.Position.Z > debug.getMinDistHands()) |
498 if (handRight.Position.Z < debug.getMaxDistHands() && handRight.Position.Z > debug.getMinDistHands()) |
566 { |
499 { |
567 RightHandTrackedEventArgs rightHandTrackedEvent = new RightHandTrackedEventArgs(server, debug, handRight, handRight.Position.Z); |
500 RightHandTrackedEventArgs rightHandTrackedEvent = new RightHandTrackedEventArgs(server, debug, handRight, handRight.Position.Z); |
568 OnRightHandTrackedEvent(rightHandTrackedEvent); |
501 OnRightHandTrackedEvent(rightHandTrackedEvent); |
569 /*if (circleDetector.CheckForRightCircle()) |
|
570 { |
|
571 CircleEventArgs circleEvent = new CircleEventArgs(server, debug); |
|
572 OnCircleEvent(circleEvent); |
|
573 //Console.Out.WriteLine("CIRCLE"); |
|
574 }*/ |
|
575 } |
502 } |
576 //Si la main droite quitte le champ, on lance l'événement approprié. |
503 //Si la main droite quitte le champ, on lance l'événement approprié. |
577 else |
504 else |
578 { |
505 { |
579 RightHandQuitEventArgs rightHandQuitEvent = new RightHandQuitEventArgs(server, debug); |
506 RightHandQuitEventArgs rightHandQuitEvent = new RightHandQuitEventArgs(server, debug); |