middleware/Debug/DebugWindow.xaml.cs
changeset 37 37ebedd84755
parent 28 9ccef81f02ab
child 41 d2f735d7763f
--- a/middleware/Debug/DebugWindow.xaml.cs	Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/DebugWindow.xaml.cs	Thu Jun 21 16:52:56 2012 +0200
@@ -31,6 +31,7 @@
 using System.Reflection;
 using System.Timers;
 using System.Configuration;
+using System.IO;
 
 namespace Trakers.Debug
 {
@@ -101,10 +102,22 @@
                 connexionHost = "127.0.0.1";
                 connexionPort = 80;
                 timerElapsing = 1000;
+                imagesToShow = 20;
+                takenPoints = 10;
+                directionChangeTresholdXY = 10;
+                directionChangeTresholdZ = 0.01f;
+                /*minDistHands = 1.0f;
+                maxDistHands = 5.5f;
+                minDist = 1.0f;
+                maxDist = 6.0f;
+                zeroPoint = 1.7f;
+                connexionHost = "127.0.0.1";
+                connexionPort = 80;
+                timerElapsing = 1000;
                 imagesToShow = 25;
                 takenPoints = 10;
                 directionChangeTresholdXY = 10;
-                directionChangeTresholdZ = 0.01f;
+                directionChangeTresholdZ = 0.01f;*/
             }
 
             //On charge la fenêtre de paramètres.
@@ -255,6 +268,64 @@
             }
         }
 
+        /*public void showCorrect(bool C1, bool C2, bool C3, bool C4, bool C5, bool C6, bool C7, bool C8, bool C9, bool C10, bool C11)
+        {
+            if(C1)
+                R0.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R0.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C2)
+                R1.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R1.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C3)
+                R2.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R2.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C4)
+                R3.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R3.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C5)
+                R4.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R4.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C6)
+                R5.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R5.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C7)
+                R6.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R6.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C8)
+                R7.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R7.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C9)
+                R8.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R8.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C10)
+                R9.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R9.Fill = System.Windows.Media.Brushes.DarkGray;
+
+            if (C11)
+                R10.Fill = System.Windows.Media.Brushes.Blue;
+            else
+                R10.Fill = System.Windows.Media.Brushes.DarkGray;
+        }*/
+
         /*
         * Affiche la distance de l'utilisateur dans le rendu visuel.
         * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
@@ -641,6 +712,7 @@
                 Bitmap bitmap = null;
                 //S'il s'agit de telle ou telle gesture, on prend l'image correspondante dans les ressources,
                 //on la convertit et on l'affiche.
+
                 switch (gesture)
                 {
                     case "SWIPE-LEFT": bitmap = getImage(imgLocation + "\\swipe_left.png");
@@ -659,13 +731,15 @@
                         break;
                     case "PULL-BOTH": bitmap = getImage(imgLocation + "\\pull_both.png");
                         break;
-                    case "WAVE": bitmap = getImage(imgLocation + "\\wave.png");
+                    case "WAVE": bitmap = getImage(imgLocation + "\\hello.png");
                         break;
                     case "BEND": bitmap = getImage(imgLocation + "\\bend.png");
                         break;
-                    case "CROSS": bitmap = getImage(imgLocation + "\\cross.png");
+                    case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png");
                         break;
-                    case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png");
+                    case "JUMP": bitmap = getImage(imgLocation + "\\jump.png");
+                        break;
+                    case "FALL": bitmap = getImage(imgLocation + "\\fall.png");
                         break;
                 }
                 Gestures.Source = CreateBitmapSourceFromBitmap(bitmap);
@@ -701,7 +775,7 @@
         /*
         *  Méthode de chargement des paramètres (position du champ de recherche...).
         */
-        public bool loadParameters()
+        /*public bool loadParameters()
         {
             try
             {
@@ -732,6 +806,74 @@
                 return false;
             }
             return true;
+        }*/
+
+        public bool loadParameters()
+        {
+            try
+            {
+                String[] lines = System.IO.File.ReadAllLines("config.txt");
+
+                minDistHands = float.Parse(lines[0].Split(':')[1]);
+                minDist = float.Parse(lines[1].Split(':')[1]);
+                connexionHost = lines[2].Split(':')[1];
+                timerElapsing = int.Parse(lines[3].Split(':')[1]);
+                takenPoints = int.Parse(lines[4].Split(':')[1]);
+                directionChangeTresholdXY = int.Parse(lines[5].Split(':')[1]);
+                connexionPort = int.Parse(lines[6].Split(':')[1]);
+                imagesToShow = int.Parse(lines[7].Split(':')[1]);
+                maxDistHands = float.Parse(lines[8].Split(':')[1]);
+                maxDist = float.Parse(lines[9].Split(':')[1]);
+                zeroPoint = float.Parse(lines[10].Split(':')[1]);
+                directionChangeTresholdZ = float.Parse(lines[11].Split(':')[1]);
+            }
+            catch (Exception e)
+            {
+                StreamWriter SW;
+                try
+                {
+                    SW = File.CreateText("ErrorFile.txt");
+                    SW.WriteLine(e.Message);
+                    SW.Close();
+                }
+                catch { }
+
+                return false;
+            }
+
+            if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist ||
+                minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist ||
+                zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 ||
+                takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0)
+            {
+                ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
+
+                StreamWriter SW;
+                try
+                {
+                    SW = File.CreateText("ErrorFile.txt");
+                    if (maxDistHands <= 0f) { SW.WriteLine("searchMaxDistance <= 0"); }
+                    if (minDistHands <= 0f) { SW.WriteLine("minDistance <= 0"); }
+                    if (maxDistHands > maxDist) { SW.WriteLine("searchMaxDistance > maxDistance"); }
+                    if (minDistHands > maxDist) { SW.WriteLine("searchMinDistance > maxDistance"); }
+                    if (minDistHands >= maxDistHands) { SW.WriteLine("searchMinDistance >= searchMaxDistance"); }
+                    if (zeroPoint < maxDistHands) { SW.WriteLine("zeroPoint < searchMaxDistance"); }
+                    if (minDistHands > minDist) { SW.WriteLine("searchMinDistance > minDistance"); }
+                    if (zeroPoint >= maxDist) { SW.WriteLine("zeroPoint >= maxDistance"); }
+                    if (connexionPort < 0) { SW.WriteLine("connexionPort < 0"); }
+                    if (timerElapsing < 0) { SW.WriteLine("timerElapsing < 0"); }
+                    if (imagesToShow < 1) { SW.WriteLine("imagesToShow < 1"); }
+                    if (takenPoints <= 0) { SW.WriteLine("takenPoints <= 0"); }
+                    if (directionChangeTresholdXY < 0) { SW.WriteLine("directionChangeTresholdXY < 0"); }
+                    if (directionChangeTresholdZ < 0) { SW.WriteLine("directionChangeTresholdZ < 0"); }
+                    SW.Close();
+                    Console.WriteLine("Error File Created SucacessFully");
+                }
+                catch (Exception){}
+
+                return false;
+            }
+            return true;
         }
 
         /*
@@ -834,7 +976,7 @@
         {
             on = _on;
         }
-        public void setQuitMenu(MenuItem quitMenu)
+        /*public void setQuitMenu(MenuItem quitMenu)
         {
             QuitMenu = quitMenu;
         }
@@ -845,7 +987,7 @@
         public void setParamMenu(MenuItem parameters)
         {
             ParamMenu = parameters;
-        }
+        }*/
 
         public float getMinDistHands()
         {
@@ -903,7 +1045,7 @@
         {
             return on;
         }
-        public MenuItem getQuitMenu()
+        /*public MenuItem getQuitMenu()
         {
             return QuitMenu;
         }
@@ -914,7 +1056,7 @@
         public MenuItem getParamMenu()
         {
             return ParamMenu;
-        }
+        }*/
 
         public void onR0(bool b)
         {