middleware/Debug/DebugWindow.xaml.cs
changeset 41 d2f735d7763f
parent 37 37ebedd84755
child 49 1c2834888adc
equal deleted inserted replaced
40:0f31ebcc62b7 41:d2f735d7763f
    30 using System.Resources;
    30 using System.Resources;
    31 using System.Reflection;
    31 using System.Reflection;
    32 using System.Timers;
    32 using System.Timers;
    33 using System.Configuration;
    33 using System.Configuration;
    34 using System.IO;
    34 using System.IO;
       
    35 using System.Collections.Specialized;
    35 
    36 
    36 namespace Trakers.Debug
    37 namespace Trakers.Debug
    37 {
    38 {
    38     public partial class DebugWindow : Window
    39     public partial class DebugWindow : Window
    39     {
    40     {
    40         //Gestionnaire de ressources.
    41         //Gestionnaire de ressources.
    41         private ResourceManager rm;
    42         private ResourceManager rm;
    42 
    43 
    43         //Paramètres du serveur TUIO.
    44         //Paramètres du serveur TUIO.
    44         private string connexionHost;
    45         private OrderedDictionary config;
    45         private int connexionPort;
    46 
    46         //Temps de rafraichissement pour le timer (Détection de gesture dans le serveur TUIO).
       
    47         private int timerElapsing;
       
    48         //Distances min/max délimitant le champ de recherche.
       
    49         private float minDistHands;
       
    50         private float maxDistHands;
       
    51         private float minDist;
       
    52         private float maxDist;
       
    53         private float zeroPoint;
       
    54         //Paramètres de la mosaïque.
       
    55         private int imagesToShow;
       
    56         //Paramètres de la recherche par courbes.
       
    57         private int takenPoints;
       
    58         private int directionChangeTresholdXY;
       
    59         private float directionChangeTresholdZ;
       
    60         //Images
    47         //Images
    61         private String imgLocation;
    48         private String imgLocation;
    62 
    49 
    63         //Timer.
    50         //Timer.
    64         private System.Timers.Timer _timer;
    51         private System.Timers.Timer _timer;
    70         private bool on;
    57         private bool on;
    71         //Indique si la fenêtre de debug est actuellement en cours de fermeture.
    58         //Indique si la fenêtre de debug est actuellement en cours de fermeture.
    72         private bool closing;
    59         private bool closing;
    73         //Indique si l'image doit être raffraichie.
    60         //Indique si l'image doit être raffraichie.
    74         private Boolean refreshImage;
    61         private Boolean refreshImage;
    75         //Fenêtre de paramètres
       
    76         private DebugParameters param;
       
    77 
    62 
    78         /*
    63         /*
    79         * Constructeur : Affiche la fenêtre de debug en lui passant en paramètre une instanciation de la
    64         * Constructeur : Affiche la fenêtre de debug en lui passant en paramètre une instanciation de la
    80         * classe KinectMain.
    65         * classe KinectMain.
    81         * Au départ, la kinect est éteinte.
    66         * Au départ, la kinect est éteinte.
    83         public DebugWindow()//KinectMain main)
    68         public DebugWindow()//KinectMain main)
    84         {
    69         {
    85             InitializeComponent();
    70             InitializeComponent();
    86 
    71 
    87             imgLocation = "Imgs";
    72             imgLocation = "Imgs";
       
    73 
       
    74             config = new OrderedDictionary();
    88 
    75 
    89             //On fait appel au gestionnaire de ressources.
    76             //On fait appel au gestionnaire de ressources.
    90             rm = new ResourceManager("Trakers.Debug.Properties.Resources", Assembly.GetExecutingAssembly());
    77             rm = new ResourceManager("Trakers.Debug.Properties.Resources", Assembly.GetExecutingAssembly());
    91             //On tente de charger les paramètres du fichier params.ini.
    78             //On tente de charger les paramètres du fichier params.ini.
    92             //Si on n'y arrive pas, on affiche une erreur et on charge les paramètres par défaut.
    79             //Si on n'y arrive pas, on affiche une erreur et on charge les paramètres par défaut.
    93             if (!loadParameters())
    80             if (!loadParameters())
    94             {
    81             {
    95                 ExceptionLbl.Content = rm.GetString("loadParametersFail");
    82                 ExceptionLbl.Content = rm.GetString("loadParametersFail");
       
    83                 config.Clear();
    96                 //Distances de détection des mains par défaut pour la recherche (ici de 1m à 2m de la Kinect).
    84                 //Distances de détection des mains par défaut pour la recherche (ici de 1m à 2m de la Kinect).
    97                 minDistHands = 1.0f;
    85                 config.Add("minDistHands", 1.0f);
    98                 maxDistHands = 1.5f;
    86                 config.Add("maxDistHands", 1.5f);
    99                 minDist = 1.0f;
    87                 config.Add("minDist", 1.0f);
   100                 maxDist = 4.0f;
    88                 config.Add("maxDist", 4.0f);
   101                 zeroPoint = 1.7f;
    89                 config.Add("zeroPoint", 1.7f);
   102                 connexionHost = "127.0.0.1";
    90                 config.Add("tuioConnexionHost", "127.0.0.1");
   103                 connexionPort = 80;
    91                 config.Add("tuioConnexionPort", 80);
   104                 timerElapsing = 1000;
    92                 config.Add("wsConnexionHost", "127.0.0.1");
   105                 imagesToShow = 20;
    93                 config.Add("wsConnexionPort", 81);
   106                 takenPoints = 10;
    94                 config.Add("tuioTimerElapsing", 1000);
   107                 directionChangeTresholdXY = 10;
    95                 config.Add("wsTimerElapsing", 1000);
   108                 directionChangeTresholdZ = 0.01f;
    96                 config.Add("imagesToShow", 20);
   109                 /*minDistHands = 1.0f;
    97                 config.Add("takenPoints", 10);
   110                 maxDistHands = 5.5f;
    98                 config.Add("directionChangeTresholdXY", 10);
   111                 minDist = 1.0f;
    99                 config.Add("directionChangeTresholdZ", 0.01f);
   112                 maxDist = 6.0f;
   100             }
   113                 zeroPoint = 1.7f;
       
   114                 connexionHost = "127.0.0.1";
       
   115                 connexionPort = 80;
       
   116                 timerElapsing = 1000;
       
   117                 imagesToShow = 25;
       
   118                 takenPoints = 10;
       
   119                 directionChangeTresholdXY = 10;
       
   120                 directionChangeTresholdZ = 0.01f;*/
       
   121             }
       
   122 
       
   123             //On charge la fenêtre de paramètres.
       
   124             param = new DebugParameters(this);
       
   125 
   101 
   126             //kinectMain = main;
   102             //kinectMain = main;
   127             on = true;
   103             on = true;
   128             closing = false;
   104             closing = false;
   129             refreshImage = true;
   105             refreshImage = true;
   130             try
   106             try
   131             {
   107             {
   132                 //On instancie le timer à N ms.
   108                 //On instancie les timers à N ms.
   133                 _timer = new System.Timers.Timer(timerElapsing);
   109                 _timer = new System.Timers.Timer((int)config["tuioTimerElapsing"]);
   134                 //Dès que le timer est expiré, on appelle _timer_Elapsed.
   110                 //Dès que le timer est expiré, on appelle _timer_Elapsed.
   135                 _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
   111                 _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
   136             }
   112             }
   137             catch (Exception){}
   113             catch (Exception){}
   138         }
   114         }
   161             DebugImage.Source = null;
   137             DebugImage.Source = null;
   162             ExceptionLbl.Content = "";
   138             ExceptionLbl.Content = "";
   163         }
   139         }
   164 
   140 
   165         /*
   141         /*
   166          * Méthode appelée à l'expiration du timer pour les gestures et modes.
   142          * Méthode appelée à l'expiration du timer ws pour les gestures et modes.
   167          */
   143          */
   168         public void _timer_Elapsed(object sender, ElapsedEventArgs e)
   144         public void _timer_Elapsed(object sender, ElapsedEventArgs e)
   169         {
   145         {
   170             //On débloque le raffraichissement de l'image.
   146             //On débloque le raffraichissement de l'image.
   171             refreshImage = true;
   147             refreshImage = true;
   266                     Gestures.Source = null;
   242                     Gestures.Source = null;
   267                 }
   243                 }
   268             }
   244             }
   269         }
   245         }
   270 
   246 
   271         /*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)
       
   272         {
       
   273             if(C1)
       
   274                 R0.Fill = System.Windows.Media.Brushes.Blue;
       
   275             else
       
   276                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   277 
       
   278             if (C2)
       
   279                 R1.Fill = System.Windows.Media.Brushes.Blue;
       
   280             else
       
   281                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   282 
       
   283             if (C3)
       
   284                 R2.Fill = System.Windows.Media.Brushes.Blue;
       
   285             else
       
   286                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   287 
       
   288             if (C4)
       
   289                 R3.Fill = System.Windows.Media.Brushes.Blue;
       
   290             else
       
   291                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   292 
       
   293             if (C5)
       
   294                 R4.Fill = System.Windows.Media.Brushes.Blue;
       
   295             else
       
   296                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   297 
       
   298             if (C6)
       
   299                 R5.Fill = System.Windows.Media.Brushes.Blue;
       
   300             else
       
   301                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   302 
       
   303             if (C7)
       
   304                 R6.Fill = System.Windows.Media.Brushes.Blue;
       
   305             else
       
   306                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   307 
       
   308             if (C8)
       
   309                 R7.Fill = System.Windows.Media.Brushes.Blue;
       
   310             else
       
   311                 R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   312 
       
   313             if (C9)
       
   314                 R8.Fill = System.Windows.Media.Brushes.Blue;
       
   315             else
       
   316                 R8.Fill = System.Windows.Media.Brushes.DarkGray;
       
   317 
       
   318             if (C10)
       
   319                 R9.Fill = System.Windows.Media.Brushes.Blue;
       
   320             else
       
   321                 R9.Fill = System.Windows.Media.Brushes.DarkGray;
       
   322 
       
   323             if (C11)
       
   324                 R10.Fill = System.Windows.Media.Brushes.Blue;
       
   325             else
       
   326                 R10.Fill = System.Windows.Media.Brushes.DarkGray;
       
   327         }*/
       
   328 
       
   329         /*
   247         /*
   330         * Affiche la distance de l'utilisateur dans le rendu visuel.
   248         * Affiche la distance de l'utilisateur dans le rendu visuel.
   331         * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
   249         * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
   332         */
   250         */
   333         public void showDistance(float proximity)
   251         public void showDistance(float proximity)
   650         {
   568         {
   651             RightHand.Content = coord;
   569             RightHand.Content = coord;
   652         }
   570         }
   653 
   571 
   654         /*
   572         /*
   655          * Méthode associée à l'événement : Ouvrir la fenêtre de paramétrage via le menu.
       
   656          */
       
   657         private void Parameters_Click(object sender, RoutedEventArgs e)
       
   658         {
       
   659             try
       
   660             {
       
   661                 param.ShowDialog();
       
   662             }
       
   663             catch (Exception)
       
   664             {
       
   665                 ExceptionLbl.Content = rm.GetString("loadParamFail");
       
   666             }
       
   667         }
       
   668 
       
   669         /*
       
   670          * Méthode associée à l'événement : Quitter via le menu.
   573          * Méthode associée à l'événement : Quitter via le menu.
   671          */
   574          */
   672         public void Quit_Click(object sender, RoutedEventArgs e)
   575         public void Quit_Click(object sender, RoutedEventArgs e)
   673         {
   576         {
   674             closing = true;
   577             closing = true;
   771                 Int32Rect.Empty,
   674                 Int32Rect.Empty,
   772                 BitmapSizeOptions.FromEmptyOptions());
   675                 BitmapSizeOptions.FromEmptyOptions());
   773         }
   676         }
   774 
   677 
   775         /*
   678         /*
   776         *  Méthode de chargement des paramètres (position du champ de recherche...).
   679          * Méthode de chargement des paramètres via le fichier de configuration.
   777         */
   680          */
   778         /*public bool loadParameters()
   681         public bool loadParameters()
   779         {
   682         {
   780             try
   683             try
   781             {
   684             {
   782                 minDistHands = Properties.Settings.Default.searchMinDistance;
   685                 //On lit le fichier de config.
   783                 maxDistHands = Properties.Settings.Default.searchMaxDistance;
       
   784                 minDist = Properties.Settings.Default.minDistance;
       
   785                 maxDist = Properties.Settings.Default.maxDistance;
       
   786                 zeroPoint = Properties.Settings.Default.zeroPoint;
       
   787                 connexionHost = Properties.Settings.Default.connexionHost;
       
   788                 connexionPort = Properties.Settings.Default.connexionPort;
       
   789                 timerElapsing = Properties.Settings.Default.timerElapsing;
       
   790                 imagesToShow = Properties.Settings.Default.imagesToShow;
       
   791                 takenPoints = Properties.Settings.Default.takenPoints;
       
   792                 directionChangeTresholdXY = Properties.Settings.Default.directionChangeTresholdXY;
       
   793                 directionChangeTresholdZ = Properties.Settings.Default.directionChangeTresholdZ;
       
   794             }
       
   795             catch (Exception)
       
   796             {
       
   797                 return false;
       
   798             }
       
   799 
       
   800             if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist ||
       
   801                 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist ||
       
   802                 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 ||
       
   803                 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0)
       
   804             {
       
   805                 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
       
   806                 return false;
       
   807             }
       
   808             return true;
       
   809         }*/
       
   810 
       
   811         public bool loadParameters()
       
   812         {
       
   813             try
       
   814             {
       
   815                 String[] lines = System.IO.File.ReadAllLines("config.txt");
   686                 String[] lines = System.IO.File.ReadAllLines("config.txt");
   816 
   687 
   817                 minDistHands = float.Parse(lines[0].Split(':')[1]);
   688                 //On repère les paramètres supposés être des int ou float de manière à les parser.
   818                 minDist = float.Parse(lines[1].Split(':')[1]);
   689                 String[] ints = { "tuioConnexionPort", "wsConnexionPort", "takenPoints", "tuioTimerElapsing", "wsTimerElapsing", "directionChangeTresholdXY", "imagesToShow" };
   819                 connexionHost = lines[2].Split(':')[1];
   690                 String[] floats = { "minDistHands", "minDist", "maxDistHands", "maxDist", "zeroPoint", "directionChangeTresholdZ" };
   820                 timerElapsing = int.Parse(lines[3].Split(':')[1]);
   691 
   821                 takenPoints = int.Parse(lines[4].Split(':')[1]);
   692                 //Indique si on a affecté le paramètre actuel.
   822                 directionChangeTresholdXY = int.Parse(lines[5].Split(':')[1]);
   693                 bool goToNextParam = false;
   823                 connexionPort = int.Parse(lines[6].Split(':')[1]);
   694 
   824                 imagesToShow = int.Parse(lines[7].Split(':')[1]);
   695                 //Pour chaque ligne du fichier de config.
   825                 maxDistHands = float.Parse(lines[8].Split(':')[1]);
   696                 for (int i = 0 ; i < lines.Length ; i++)
   826                 maxDist = float.Parse(lines[9].Split(':')[1]);
   697                 {
   827                 zeroPoint = float.Parse(lines[10].Split(':')[1]);
   698                     //On récupère la clé et la valeur.
   828                 directionChangeTresholdZ = float.Parse(lines[11].Split(':')[1]);
   699                     String key = lines[i].Split(':')[0];
   829             }
   700                     String value = lines[i].Split(':')[1];
       
   701 
       
   702                     //Si c'est un int on le parse.
       
   703                     for (int j = 0 ; j < ints.Length ; j++)
       
   704                     {
       
   705                         if (ints[j] == key)
       
   706                         {
       
   707                             config.Add(key, int.Parse(value));
       
   708                             goToNextParam = true;
       
   709                         }
       
   710                     }
       
   711 
       
   712                     //Si il n'était pas un int.
       
   713                     if (!goToNextParam)
       
   714                     {
       
   715                         //Si c'est un float on le parse.
       
   716                         for (int j = 0; j < floats.Length; j++)
       
   717                         {
       
   718                             if (floats[j] == key)
       
   719                             {
       
   720                                 config.Add(key, float.Parse(value));
       
   721                                 goToNextParam = true;
       
   722                             }
       
   723                         }
       
   724 
       
   725                         //Si c'était en fait un string.
       
   726                         if (!goToNextParam)
       
   727                         {
       
   728                             config.Add(key, value);
       
   729                         }
       
   730                     }
       
   731                     goToNextParam = false;
       
   732                 }
       
   733             }
       
   734             //S'il s'est passé un problème durant la lecture du fichier de config.
   830             catch (Exception e)
   735             catch (Exception e)
   831             {
   736             {
       
   737                 //On génère un fichier qui va afficher l'erreur.
   832                 StreamWriter SW;
   738                 StreamWriter SW;
   833                 try
   739                 try
   834                 {
   740                 {
   835                     SW = File.CreateText("ErrorFile.txt");
   741                     SW = File.CreateText("ErrorFile.txt");
   836                     SW.WriteLine(e.Message);
   742                     SW.WriteLine(e.Message);
   839                 catch { }
   745                 catch { }
   840 
   746 
   841                 return false;
   747                 return false;
   842             }
   748             }
   843 
   749 
   844             if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist ||
   750             //Si l'extraction s'est bien passé mais que les paramètres sont incohérents.
   845                 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist ||
   751             if ((float)config["maxDistHands"] <= 0f || (float)config["minDistHands"] <= 0f || (float)config["maxDistHands"] > (float)config["maxDist"] || (float)config["minDistHands"] > (float)config["maxDist"] ||
   846                 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 ||
   752                 (float)config["minDistHands"] >= (float)config["maxDistHands"] || (float)config["zeroPoint"] < (float)config["maxDistHands"] || (float)config["minDistHands"] > (float)config["minDist"] ||
   847                 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0)
   753                 (float)config["zeroPoint"] >= (float)config["maxDist"] || (int)config["tuioConnexionPort"] < 0 || (int)config["wsConnexionPort"] < 0 || (int)config["tuioTimerElapsing"] < 0 || (int)config["wsTimerElapsing"] < 0 || (int)config["imagesToShow"] < 1 ||
       
   754                 (int)config["takenPoints"] <= 0 || (int)config["directionChangeTresholdXY"] < 0 || (float)config["directionChangeTresholdZ"] < 0)
   848             {
   755             {
   849                 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
   756                 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
   850 
   757 
   851                 StreamWriter SW;
   758                 StreamWriter SW;
   852                 try
   759                 try
   853                 {
   760                 {
       
   761                     //On indique les incohérences trouvées dans le fichier.
   854                     SW = File.CreateText("ErrorFile.txt");
   762                     SW = File.CreateText("ErrorFile.txt");
   855                     if (maxDistHands <= 0f) { SW.WriteLine("searchMaxDistance <= 0"); }
   763                     if ((float)config["maxDistHands"] <= 0f) { SW.WriteLine("searchMaxDistance <= 0"); }
   856                     if (minDistHands <= 0f) { SW.WriteLine("minDistance <= 0"); }
   764                     if ((float)config["minDistHands"] <= 0f) { SW.WriteLine("minDistance <= 0"); }
   857                     if (maxDistHands > maxDist) { SW.WriteLine("searchMaxDistance > maxDistance"); }
   765                     if ((float)config["maxDistHands"] > (float)config["maxDist"]) { SW.WriteLine("searchMaxDistance > maxDistance"); }
   858                     if (minDistHands > maxDist) { SW.WriteLine("searchMinDistance > maxDistance"); }
   766                     if ((float)config["minDistHands"] > (float)config["maxDist"]) { SW.WriteLine("searchMinDistance > maxDistance"); }
   859                     if (minDistHands >= maxDistHands) { SW.WriteLine("searchMinDistance >= searchMaxDistance"); }
   767                     if ((float)config["minDistHands"] >= (float)config["maxDistHands"]) { SW.WriteLine("searchMinDistance >= searchMaxDistance"); }
   860                     if (zeroPoint < maxDistHands) { SW.WriteLine("zeroPoint < searchMaxDistance"); }
   768                     if ((float)config["zeroPoint"] < (float)config["maxDistHands"]) { SW.WriteLine("zeroPoint < searchMaxDistance"); }
   861                     if (minDistHands > minDist) { SW.WriteLine("searchMinDistance > minDistance"); }
   769                     if ((float)config["minDistHands"] > (float)config["minDist"]) { SW.WriteLine("searchMinDistance > minDistance"); }
   862                     if (zeroPoint >= maxDist) { SW.WriteLine("zeroPoint >= maxDistance"); }
   770                     if ((float)config["zeroPoint"] >= (float)config["maxDist"]) { SW.WriteLine("zeroPoint >= maxDistance"); }
   863                     if (connexionPort < 0) { SW.WriteLine("connexionPort < 0"); }
   771                     if ((int)config["tuioConnexionPort"] < 0) { SW.WriteLine("tuioConnexionPort < 0"); }
   864                     if (timerElapsing < 0) { SW.WriteLine("timerElapsing < 0"); }
   772                     if ((int)config["wsConnexionPort"] < 0) { SW.WriteLine("wsConnexionPort < 0"); }
   865                     if (imagesToShow < 1) { SW.WriteLine("imagesToShow < 1"); }
   773                     if ((int)config["tuioTimerElapsing"] < 0) { SW.WriteLine("tuioTimerElapsing < 0"); }
   866                     if (takenPoints <= 0) { SW.WriteLine("takenPoints <= 0"); }
   774                     if ((int)config["wsTimerElapsing"] < 0) { SW.WriteLine("wsTimerElapsing < 0"); }
   867                     if (directionChangeTresholdXY < 0) { SW.WriteLine("directionChangeTresholdXY < 0"); }
   775                     if ((int)config["imagesToShow"] < 1) { SW.WriteLine("imagesToShow < 1"); }
   868                     if (directionChangeTresholdZ < 0) { SW.WriteLine("directionChangeTresholdZ < 0"); }
   776                     if ((int)config["takenPoints"] <= 0) { SW.WriteLine("takenPoints <= 0"); }
       
   777                     if ((int)config["directionChangeTresholdXY"] < 0) { SW.WriteLine("directionChangeTresholdXY < 0"); }
       
   778                     if ((float)config["directionChangeTresholdZ"] < 0) { SW.WriteLine("directionChangeTresholdZ < 0"); }
   869                     SW.Close();
   779                     SW.Close();
   870                     Console.WriteLine("Error File Created SucacessFully");
   780                     Console.WriteLine("Error File Created SucacessFully");
   871                 }
   781                 }
   872                 catch (Exception){}
   782                 catch (Exception){}
   873 
   783 
   875             }
   785             }
   876             return true;
   786             return true;
   877         }
   787         }
   878 
   788 
   879         /*
   789         /*
   880          * Met à jour les nouveaux paramètres dans la configuration.
       
   881          */
       
   882         public void updateParameters()
       
   883         {
       
   884             //userPositionDetector.setParams(minDist, maxDist, minDistHands, maxDistHands, zeroPoint);
       
   885             //segmenter.setParams(takenPoints, directionChangeTresholdXY, directionChangeTresholdZ);
       
   886 
       
   887             //On récupère la config.
       
   888             Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
       
   889             //On met à jour.
       
   890             Properties.Settings.Default.Context.Remove("searchMinDistance");
       
   891             Properties.Settings.Default.Context.Add("searchMinDistance", minDistHands.ToString());
       
   892             Properties.Settings.Default.Context.Remove("searchMaxDistance");
       
   893             Properties.Settings.Default.Context.Add("searchMaxDistance", maxDistHands.ToString());
       
   894             Properties.Settings.Default.Context.Remove("minDistance");
       
   895             Properties.Settings.Default.Context.Add("minDistance", minDist.ToString());
       
   896             Properties.Settings.Default.Context.Remove("maxDistance");
       
   897             Properties.Settings.Default.Context.Add("maxDistance", maxDist.ToString());
       
   898             Properties.Settings.Default.Context.Remove("zeroPoint");
       
   899             Properties.Settings.Default.Context.Add("zeroPoint", zeroPoint.ToString());
       
   900             Properties.Settings.Default.Context.Remove("connexionHost");
       
   901             Properties.Settings.Default.Context.Add("connexionHost", connexionHost);
       
   902             Properties.Settings.Default.Context.Remove("connexionPort");
       
   903             Properties.Settings.Default.Context.Add("connexionPort", connexionPort.ToString());
       
   904             Properties.Settings.Default.Context.Remove("timerElapsing");
       
   905             Properties.Settings.Default.Context.Add("timerElapsing", timerElapsing.ToString());
       
   906             Properties.Settings.Default.Context.Remove("imagesToShow");
       
   907             Properties.Settings.Default.Context.Add("imagesToShow", imagesToShow.ToString());
       
   908             Properties.Settings.Default.Context.Remove("takenPoints");
       
   909             Properties.Settings.Default.Context.Add("takenPoints", takenPoints.ToString());
       
   910             Properties.Settings.Default.Context.Remove("directionChangeTresholdXY");
       
   911             Properties.Settings.Default.Context.Add("directionChangeTresholdXY", directionChangeTresholdXY.ToString());
       
   912             Properties.Settings.Default.Context.Remove("directionChangeTresholdZ");
       
   913             Properties.Settings.Default.Context.Add("directionChangeTresholdZ", directionChangeTresholdZ.ToString());
       
   914 
       
   915             //Sauvegarde la configuration.
       
   916             Properties.Settings.Default.Save();
       
   917             Properties.Settings.Default.Reload();
       
   918         }
       
   919 
       
   920         /*
       
   921          * Getters et setters des paramètres du Middleware.
   790          * Getters et setters des paramètres du Middleware.
   922          */
   791          */
   923         public void setMinDistHands(float min)
   792         public void setMinDistHands(float min)
   924         {
   793         {
   925             minDistHands = min;
   794             config["minDistHands"] = min;
   926         }
   795         }
   927         public void setMaxDistHands(float max)
   796         public void setMaxDistHands(float max)
   928         {
   797         {
   929             maxDistHands = max;
   798             config["maxDistHands"] = max;
   930         }
   799         }
   931         public void setMinDist(float min)
   800         public void setMinDist(float min)
   932         {
   801         {
   933             minDist = min;
   802             config["minDist"] = min;
   934         }
   803         }
   935         public void setMaxDist(float max)
   804         public void setMaxDist(float max)
   936         {
   805         {
   937             maxDist = max;
   806             config["maxDist"] = max;
   938         }
   807         }
   939         public void setZeroPoint(float zero)
   808         public void setZeroPoint(float zero)
   940         {
   809         {
   941             zeroPoint = zero;
   810             config["zeroPoint"] = zero;
   942         }
   811         }
   943         public void setConnexionHost(String host)
   812         public void setTuioConnexionHost(String host)
   944         {
   813         {
   945             connexionHost = host;
   814             config["tuioConnexionHost"] = host;
   946         }
   815         }
   947         public void setConnexionPort(int port)
   816         public void setTuioConnexionPort(int port)
   948         {
   817         {
   949             connexionPort = port;
   818             config["tuioConnexionPort"] = port;
   950         }
   819         }
   951         public void setTimerElapsing(int time)
   820         public void setWsConnexionHost(String host)
   952         {
   821         {
   953             timerElapsing = time;
   822             config["wsConnexionHost"] = host;
       
   823         }
       
   824         public void setWsConnexionPort(int port)
       
   825         {
       
   826             config["wsConnexionPort"] = port;
       
   827         }
       
   828         public void setTuioTimerElapsing(int time)
       
   829         {
       
   830             config["tuioTimerElapsing"] = time;
       
   831         }
       
   832         public void setWsTimerElapsing(int time)
       
   833         {
       
   834             config["wsTimerElapsing"] = time;
   954         }
   835         }
   955         public void setImagesToShow(int _imagesToShow)
   836         public void setImagesToShow(int _imagesToShow)
   956         {
   837         {
   957             imagesToShow = _imagesToShow;
   838             config["imagesToShow"] = _imagesToShow;
   958         }
   839         }
   959         public void setTakenPoints(int _takenPoints)
   840         public void setTakenPoints(int _takenPoints)
   960         {
   841         {
   961             takenPoints = _takenPoints;
   842             config["takenPoints"] = _takenPoints;
   962         }
   843         }
   963         public void setDirectionChangeTresholdXY(int _directionChangeTresholdXY)
   844         public void setDirectionChangeTresholdXY(int _directionChangeTresholdXY)
   964         {
   845         {
   965             directionChangeTresholdXY = _directionChangeTresholdXY;
   846             config["directionChangeTresholdXY"] = _directionChangeTresholdXY;
   966         }
   847         }
   967         public void setDirectionChangeTresholdZ(float _directionChangeTresholdZ)
   848         public void setDirectionChangeTresholdZ(float _directionChangeTresholdZ)
   968         {
   849         {
   969             directionChangeTresholdZ = _directionChangeTresholdZ;
   850             config["directionChangeTresholdZ"] = _directionChangeTresholdZ;
   970         }
   851         }
   971         public void setSwitch(Button _switch)
   852         public void setSwitch(Button _switch)
   972         {
   853         {
   973             Switch = _switch;
   854             Switch = _switch;
   974         }
   855         }
   975         public void setOn(bool _on)
   856         public void setOn(bool _on)
   976         {
   857         {
   977             on = _on;
   858             on = _on;
   978         }
   859         }
   979         /*public void setQuitMenu(MenuItem quitMenu)
   860         
   980         {
       
   981             QuitMenu = quitMenu;
       
   982         }
       
   983         public void setParametersWindow(DebugParameters parameters)
       
   984         {
       
   985             param = parameters;
       
   986         }
       
   987         public void setParamMenu(MenuItem parameters)
       
   988         {
       
   989             ParamMenu = parameters;
       
   990         }*/
       
   991 
       
   992         public float getMinDistHands()
   861         public float getMinDistHands()
   993         {
   862         {
   994             return minDistHands;
   863             return (float)config["minDistHands"];
   995         }
   864         }
   996         public float getMaxDistHands()
   865         public float getMaxDistHands()
   997         {
   866         {
   998             return maxDistHands;
   867             return (float)config["maxDistHands"];
   999         }
   868         }
  1000         public float getMinDist()
   869         public float getMinDist()
  1001         {
   870         {
  1002             return minDist;
   871             return (float)config["minDist"];
  1003         }
   872         }
  1004         public float getMaxDist()
   873         public float getMaxDist()
  1005         {
   874         {
  1006             return maxDist;
   875             return (float)config["maxDist"];
  1007         }
   876         }
  1008         public float getZeroPoint()
   877         public float getZeroPoint()
  1009         {
   878         {
  1010             return zeroPoint;
   879             return (float)config["zeroPoint"];
  1011         }
   880         }
  1012         public String getConnexionHost()
   881         public String getTuioConnexionHost()
  1013         {
   882         {
  1014             return connexionHost;
   883             return (String)config["tuioConnexionHost"];
  1015         }
   884         }
  1016         public int getConnexionPort()
   885         public int getTuioConnexionPort()
  1017         {
   886         {
  1018             return connexionPort;
   887             return (int)config["tuioConnexionPort"];
  1019         }
   888         }
  1020         public int getTimerElapsing()
   889         public int getTuioTimerElapsing()
  1021         {
   890         {
  1022             return timerElapsing;
   891             return (int)config["tuioTimerElapsing"];
       
   892         }
       
   893         public String getWsConnexionHost()
       
   894         {
       
   895             return (String)config["wsConnexionHost"];
       
   896         }
       
   897         public int getWsConnexionPort()
       
   898         {
       
   899             return (int)config["wsConnexionPort"];
       
   900         }
       
   901         public int getWsTimerElapsing()
       
   902         {
       
   903             return (int)config["wsTimerElapsing"];
  1023         }
   904         }
  1024         public int getImagesToShow()
   905         public int getImagesToShow()
  1025         {
   906         {
  1026             return imagesToShow;
   907             return (int)config["imagesToShow"];
  1027         }
   908         }
  1028         public int getTakenPoints()
   909         public int getTakenPoints()
  1029         {
   910         {
  1030             return takenPoints;
   911             return (int)config["takenPoints"];
  1031         }
   912         }
  1032         public int getDirectionChangeTresholdXY()
   913         public int getDirectionChangeTresholdXY()
  1033         {
   914         {
  1034             return directionChangeTresholdXY;
   915             return (int)config["directionChangeTresholdXY"];
  1035         }
   916         }
  1036         public float getDirectionChangeTresholdZ()
   917         public float getDirectionChangeTresholdZ()
  1037         {
   918         {
  1038             return directionChangeTresholdZ;
   919             return (float)config["directionChangeTresholdZ"];
  1039         }
   920         }
  1040         public Button getSwitch()
   921         public Button getSwitch()
  1041         {
   922         {
  1042             return Switch;
   923             return Switch;
  1043         }
   924         }
  1044         public bool getOn()
   925         public bool getOn()
  1045         {
   926         {
  1046             return on;
   927             return on;
  1047         }
   928         }
  1048         /*public MenuItem getQuitMenu()
       
  1049         {
       
  1050             return QuitMenu;
       
  1051         }
       
  1052         public DebugParameters getParametersWindow()
       
  1053         {
       
  1054             return param;
       
  1055         }
       
  1056         public MenuItem getParamMenu()
       
  1057         {
       
  1058             return ParamMenu;
       
  1059         }*/
       
  1060 
   929 
  1061         public void onR0(bool b)
   930         public void onR0(bool b)
  1062         {
   931         {
  1063             if(b)
   932             if(b)
  1064                 R0.Fill = System.Windows.Media.Brushes.Blue;
   933                 R0.Fill = System.Windows.Media.Brushes.Blue;