middleware/src/MainModule/Events/PushListener.cs
changeset 15 4b78f179e7ce
child 17 fda26bfcabef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/MainModule/Events/PushListener.cs	Mon Apr 02 16:30:56 2012 +0200
@@ -0,0 +1,63 @@
+/*
+* This file is part of the TraKERS\Middleware package.
+*
+* (c) IRI <http://www.iri.centrepompidou.fr/>
+*
+* For the full copyright and license information, please view the LICENSE_MIDDLEWARE
+* file that was distributed with this source code.
+*/
+
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : MainModule/Events
+ * Classe : PushListener
+ * 
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ * 
+ * Fonctionnalités : Ce listener écoute l'événement du type : L'utilisateur a effectué un push.
+ * Il contient le code a être éxecuté au cas où cet événement survient.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Trakers.MainModule.Events
+{
+    public class PushListener
+    {
+        /*
+        * Méthode appelée lorsque on a l'événement : L'utilisateur a effectué un push.
+        */
+        public void showAndSend(object o, PushEventArgs e)
+        {
+            //On l'indique dans le debug.
+            //Lorsqu'il s'agit d'un push/pull de la main gauche/droite/deux deux on envoie le message
+            //correspondant.
+            String code = "";
+            if (e.direction == Gestures.PushDetector.Direction.PUSH)
+            {
+                if (e.hand == Gestures.PushDetector.Hand.RIGHT)
+                    code = "PUSH-RIGHT";
+                else if (e.hand == Gestures.PushDetector.Hand.LEFT)
+                    code = "PUSH-LEFT";
+                else
+                    code = "PUSH-BOTH";
+            }
+            else
+            {
+                if (e.hand == Gestures.PushDetector.Hand.RIGHT)
+                    code = "PULL-RIGHT";
+                else if (e.hand == Gestures.PushDetector.Hand.LEFT)
+                    code = "PULL-LEFT";
+                else
+                    code = "PULL-BOTH";
+            }
+            
+            e.debug.showGesture(code);
+            e.server.GesturePerformed(code);
+        }
+    }
+}