middleware/Debug/DebugWindow.xaml.cs
changeset 56 7d0ae2f385e7
parent 54 eb52a12370a3
child 57 d0c393730443
equal deleted inserted replaced
55:afd60399a7b5 56:7d0ae2f385e7
    83             rm = new ResourceManager("Trakers.Debug.Properties.Resources", Assembly.GetExecutingAssembly());
    83             rm = new ResourceManager("Trakers.Debug.Properties.Resources", Assembly.GetExecutingAssembly());
    84 
    84 
    85             //On charge les éléments relatifs au projet.
    85             //On charge les éléments relatifs au projet.
    86             if (projectName.Equals("TraKERS"))
    86             if (projectName.Equals("TraKERS"))
    87             {
    87             {
       
    88                 MiddlewareDebugWindow.Title = "TraKERS - Middleware";
    88                 configPath = ".\\TraKERS - config.txt";
    89                 configPath = ".\\TraKERS - config.txt";
    89                 loadTraKERSMenu();
    90                 loadTraKERSMenu();
    90             }
    91             }
    91             else if (projectName.Equals("BBM"))
    92             else if (projectName.Equals("BBM"))
    92             {
    93             {
       
    94                 MiddlewareDebugWindow.Title = "Browse by Motion - Middleware";
    93                 configPath = ".\\BBM - config.txt";
    95                 configPath = ".\\BBM - config.txt";
    94                 loadBBMMenu();
    96                 loadBBMMenu();
    95             }
    97             }
       
    98 
       
    99             //On initialise les images des mains.
       
   100             Bitmap rightHandBitmap = getImage(imgLocation + "\\right_hand_off.png"), leftHandBitmap = getImage(imgLocation + "\\left_hand_off.png");
       
   101             LeftHand.Source = CreateBitmapSourceFromBitmap(leftHandBitmap);
       
   102             RightHand.Source = CreateBitmapSourceFromBitmap(rightHandBitmap);
       
   103             //On initialise les images de proximité.
       
   104             Bitmap userBitmap = getImage(imgLocation + "\\user.png"), kinectBitmap = getImage(imgLocation + "\\kinect.png");
       
   105             UserImage.Source = CreateBitmapSourceFromBitmap(userBitmap);
       
   106             KinectImage.Source = CreateBitmapSourceFromBitmap(kinectBitmap);
    96 
   107 
    97             //On tente de charger les paramètres du fichier params.ini.
   108             //On tente de charger les paramètres du fichier params.ini.
    98             //Si on n'y arrive pas, on affiche une erreur et on charge les paramètres par défaut.
   109             //Si on n'y arrive pas, on affiche une erreur et on charge les paramètres par défaut.
    99             if (!loadParameters())
   110             if (!loadParameters())
   100             {
   111             {
   197             //On rend visible la partie du menu des exemples Processing et Web de TraKERS.
   208             //On rend visible la partie du menu des exemples Processing et Web de TraKERS.
   198             ExamplesMenu.Visibility = Visibility.Visible;
   209             ExamplesMenu.Visibility = Visibility.Visible;
   199 
   210 
   200             //On cache la partie du menu des readme et doc de BBM.
   211             //On cache la partie du menu des readme et doc de BBM.
   201             DocumentationFrontIDILLMenu.Visibility = Visibility.Collapsed;
   212             DocumentationFrontIDILLMenu.Visibility = Visibility.Collapsed;
       
   213             FrontIDILLMenu.Visibility = Visibility.Collapsed;
   202 
   214 
   203             //Readme et doc de TraKERS.
   215             //Readme et doc de TraKERS.
   204             ReadmeFrontProcessingMenu.Header = rm.GetString("menuReadmeFrontProcessing");
   216             ReadmeFrontProcessingMenu.Header = rm.GetString("menuReadmeFrontProcessing");
   205             DocumentationFrontProcessingMenu.Header = rm.GetString("menuDocFrontP");
   217             DocumentationFrontProcessingMenu.Header = rm.GetString("menuDocFrontP");
   206             ReadmeFrontJSMenu.Header = rm.GetString("menuReadmeFrontJS");
   218             ReadmeFrontJSMenu.Header = rm.GetString("menuReadmeFrontJS");
   346             }
   358             }
   347             else
   359             else
   348             {
   360             {
   349                 //Il affiche ON (pour allumer la kinect).
   361                 //Il affiche ON (pour allumer la kinect).
   350                 Switch.Content = "ON";
   362                 Switch.Content = "ON";
   351                 //On remet à zéro tous les éléments du retour visuel.
   363                 Bitmap rightHandBitmap = getImage(imgLocation + "\\right_hand_off.png"), leftHandBitmap = getImage(imgLocation + "\\left_hand_off.png");
   352                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
   364                 LeftHand.Source = CreateBitmapSourceFromBitmap(leftHandBitmap);
   353                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
   365                 RightHand.Source = CreateBitmapSourceFromBitmap(rightHandBitmap);
   354                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   355                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   356                 DistanceLbl.Content = "Distance :";
       
   357                 LeftHand.Background = System.Windows.Media.Brushes.DarkGray;
       
   358                 LeftHand.Content = "";
       
   359                 RightHand.Background = System.Windows.Media.Brushes.DarkGray;
       
   360                 RightHand.Content = "";
       
   361                 DebugCanvas.Children.RemoveRange(1, DebugCanvas.Children.Count - 1);
   366                 DebugCanvas.Children.RemoveRange(1, DebugCanvas.Children.Count - 1);
   362             }
   367             }
   363         }
   368         }
   364 
   369 
   365         /*
   370         /*
   412         * Affiche la distance de l'utilisateur dans le rendu visuel.
   417         * Affiche la distance de l'utilisateur dans le rendu visuel.
   413         * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
   418         * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
   414         */
   419         */
   415         public void showDistance(float proximity)
   420         public void showDistance(float proximity)
   416         {
   421         {
   417             DistanceLbl.Content = "Proximity : " + proximity + "%";
   422             UserImage.Margin = new System.Windows.Thickness(552, 350 - 350 / 100 * proximity, 0, 0);
   418 
       
   419             if (proximity == 0)
       
   420             {
       
   421                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   422                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   423                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   424                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   425                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   426                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   427                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   428                 R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   429                 R8.Fill = System.Windows.Media.Brushes.DarkGray;
       
   430                 R9.Fill = System.Windows.Media.Brushes.DarkGray;
       
   431                 R10.Fill = System.Windows.Media.Brushes.DarkGray;
       
   432             }
       
   433             else if (proximity > 0 && proximity < 10)
       
   434             {
       
   435                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   436                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   437                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   438                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   439                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   440                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   441                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   442                 R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   443                 R8.Fill = System.Windows.Media.Brushes.DarkGray;
       
   444                 R9.Fill = System.Windows.Media.Brushes.DarkGray;
       
   445                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   446             }
       
   447             else if (proximity > 10 && proximity < 20)
       
   448             {
       
   449                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   450                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   451                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   452                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   453                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   454                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   455                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   456                 R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   457                 R8.Fill = System.Windows.Media.Brushes.DarkGray;
       
   458                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   459                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   460             }
       
   461             else if (proximity > 20 && proximity < 30)
       
   462             {
       
   463                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   464                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   465                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   466                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   467                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   468                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   469                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   470                 R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   471                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   472                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   473                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   474             }
       
   475             else if (proximity > 30 && proximity < 40)
       
   476             {
       
   477                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   478                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   479                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   480                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   481                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   482                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   483                 R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   484                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   485                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   486                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   487                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   488             }
       
   489             else if (proximity > 40 && proximity < 50)
       
   490             {
       
   491                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   492                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   493                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   494                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   495                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   496                 R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   497                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   498                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   499                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   500                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   501                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   502             }
       
   503             else if (proximity > 50 && proximity < 60)
       
   504             {
       
   505                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   506                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   507                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   508                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   509                 R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   510                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   511                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   512                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   513                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   514                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   515                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   516             }
       
   517             else if (proximity > 60 && proximity < 70)
       
   518             {
       
   519                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   520                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   521                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   522                 R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   523                 R4.Fill = System.Windows.Media.Brushes.Yellow;
       
   524                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   525                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   526                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   527                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   528                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   529                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   530             }
       
   531             else if (proximity > 70 && proximity < 80)
       
   532             {
       
   533                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   534                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   535                 R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   536                 R3.Fill = System.Windows.Media.Brushes.Yellow;
       
   537                 R4.Fill = System.Windows.Media.Brushes.Yellow;
       
   538                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   539                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   540                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   541                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   542                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   543                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   544             }
       
   545             else if (proximity > 80 && proximity < 90)
       
   546             {
       
   547                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   548                 R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   549                 R2.Fill = System.Windows.Media.Brushes.Yellow;
       
   550                 R3.Fill = System.Windows.Media.Brushes.Yellow;
       
   551                 R4.Fill = System.Windows.Media.Brushes.Yellow;
       
   552                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   553                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   554                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   555                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   556                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   557                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   558             }
       
   559             else if (proximity > 90 && proximity < 100)
       
   560             {
       
   561                 R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   562                 R1.Fill = System.Windows.Media.Brushes.Yellow;
       
   563                 R2.Fill = System.Windows.Media.Brushes.Yellow;
       
   564                 R3.Fill = System.Windows.Media.Brushes.Yellow;
       
   565                 R4.Fill = System.Windows.Media.Brushes.Yellow;
       
   566                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   567                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   568                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   569                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   570                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   571                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   572             }
       
   573             else if (proximity == 100)
       
   574             {
       
   575                 R0.Fill = System.Windows.Media.Brushes.Green;
       
   576                 R1.Fill = System.Windows.Media.Brushes.Yellow;
       
   577                 R2.Fill = System.Windows.Media.Brushes.Yellow;
       
   578                 R3.Fill = System.Windows.Media.Brushes.Yellow;
       
   579                 R4.Fill = System.Windows.Media.Brushes.Yellow;
       
   580                 R5.Fill = System.Windows.Media.Brushes.Orange;
       
   581                 R6.Fill = System.Windows.Media.Brushes.Orange;
       
   582                 R7.Fill = System.Windows.Media.Brushes.Orange;
       
   583                 R8.Fill = System.Windows.Media.Brushes.Red;
       
   584                 R9.Fill = System.Windows.Media.Brushes.Red;
       
   585                 R10.Fill = System.Windows.Media.Brushes.Red;
       
   586             }
       
   587         }
   423         }
   588 
   424 
   589         /*
   425         /*
   590         * Affiche la détection de la main droite via un label.
   426         * Affiche la détection de la main droite via un label.
   591         */
   427         */
   592         public void showRightHandRect(bool show)
   428         public void showRightHandRect(bool show)
   593         {
   429         {
       
   430             Bitmap bitmap = null;
       
   431 
   594             if (show)
   432             if (show)
   595                 RightHand.Background = System.Windows.Media.Brushes.Blue;
   433                 bitmap = getImage(imgLocation + "\\right_hand_on.png");
   596             else
   434             else
   597                 RightHand.Background = System.Windows.Media.Brushes.DarkGray;
   435                 bitmap = getImage(imgLocation + "\\right_hand_off.png");
       
   436 
       
   437             RightHand.Source = CreateBitmapSourceFromBitmap(bitmap);
   598         }
   438         }
   599 
   439 
   600         /*
   440         /*
   601         * Affiche la détection de la main gauche via un label.
   441         * Affiche la détection de la main gauche via un label.
   602         */
   442         */
   603         public void showLeftHandRect(bool show)
   443         public void showLeftHandRect(bool show)
   604         {
   444         {
       
   445             Bitmap bitmap = null;
       
   446 
   605             if (show)
   447             if (show)
   606                 LeftHand.Background = System.Windows.Media.Brushes.Blue;
   448                 bitmap = getImage(imgLocation + "\\left_hand_on.png");
   607             else
   449             else
   608                 LeftHand.Background = System.Windows.Media.Brushes.DarkGray;
   450                 bitmap = getImage(imgLocation + "\\left_hand_off.png");
       
   451 
       
   452             LeftHand.Source = CreateBitmapSourceFromBitmap(bitmap);
   609         }
   453         }
   610 
   454 
   611         /*
   455         /*
   612         * Dessine les noeuds du squelette dans le rendu visuel.
   456         * Dessine les noeuds du squelette dans le rendu visuel.
   613         */
   457         */
   701         public void hideSkeleton()
   545         public void hideSkeleton()
   702         {
   546         {
   703             //On vide le canvas mais en gardant l'image.
   547             //On vide le canvas mais en gardant l'image.
   704             if(DebugCanvas.Children.Count > 1)
   548             if(DebugCanvas.Children.Count > 1)
   705                 DebugCanvas.Children.RemoveRange(1, DebugCanvas.Children.Count - 1);
   549                 DebugCanvas.Children.RemoveRange(1, DebugCanvas.Children.Count - 1);
   706             //On colore en gris tous les indicateurs.
       
   707             R0.Fill = System.Windows.Media.Brushes.DarkGray;
       
   708             R1.Fill = System.Windows.Media.Brushes.DarkGray;
       
   709             R2.Fill = System.Windows.Media.Brushes.DarkGray;
       
   710             R3.Fill = System.Windows.Media.Brushes.DarkGray;
       
   711             R4.Fill = System.Windows.Media.Brushes.DarkGray;
       
   712             R5.Fill = System.Windows.Media.Brushes.DarkGray;
       
   713             R6.Fill = System.Windows.Media.Brushes.DarkGray;
       
   714             R7.Fill = System.Windows.Media.Brushes.DarkGray;
       
   715             R8.Fill = System.Windows.Media.Brushes.DarkGray;
       
   716             R9.Fill = System.Windows.Media.Brushes.DarkGray;
       
   717             R10.Fill = System.Windows.Media.Brushes.DarkGray;
       
   718         }
   550         }
   719 
   551 
   720         /*
   552         /*
   721         * Affiche la position de la main gauche dans le rendu visuel.
   553         * Affiche la position de la main gauche dans le rendu visuel.
   722         */
   554         */
   723         public void showLeftHandCoord(String coord)
   555         public void showLeftHandCoord(String coord)
   724         {
   556         {
   725             LeftHand.Content = coord;
   557             //LeftHand.Content = coord;
   726         }
   558         }
   727 
   559 
   728         /*
   560         /*
   729         * Affiche la position de la main gauche dans le rendu visuel.
   561         * Affiche la position de la main gauche dans le rendu visuel.
   730         */
   562         */
   731         public void showRightHandCoord(String coord)
   563         public void showRightHandCoord(String coord)
   732         {
   564         {
   733             RightHand.Content = coord;
   565             //RightHand.Content = coord;
   734         }
   566         }
   735 
   567 
   736         /*
   568         /*
   737          * Méthode associée à l'événement : Quitter via le menu.
   569          * Méthode associée à l'événement : Quitter via le menu.
   738          */
   570          */