src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 190 619ca3ae13c7
parent 188 e642ad0c366b
child 191 8a25a85f2656
equal deleted inserted replaced
189:b37888f59cf2 190:619ca3ae13c7
   305                         Screen.Name = "Screen1";
   305                         Screen.Name = "Screen1";
   306                         Screen.contexteGrid = Grid1.Name.ToString();
   306                         Screen.contexteGrid = Grid1.Name.ToString();
   307                         //2-Rajout du screen dans la grid correspondante
   307                         //2-Rajout du screen dans la grid correspondante
   308                         Grid1.Children.Add(Screen);
   308                         Grid1.Children.Add(Screen);
   309 
   309 
   310                         Screen.UC_Screen_NewCutting += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
   310                         Screen.UC_Screen_NewCutting += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); 
   311                     }
   311                     }
   312                     else //Affichage du message de confirmation
   312                     else //Affichage du message de confirmation
   313                     {
   313                     {
   314                         if (Panel1 != null && Grid1.Children.Count == 2)
   314                         if (Panel1 != null && Grid1.Children.Count == 2)
   315                         {
   315                         {
   403             {
   403             {
   404                 //1-Suppression du UC Screen
   404                 //1-Suppression du UC Screen
   405                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   405                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   406                 root.Children.Remove(((UserControlScreen)sender));
   406                 root.Children.Remove(((UserControlScreen)sender));
   407                 
   407                 
   408                 if (((UserControlScreen)sender).CuttingVM != null)
   408                 if (((UserControlScreen)sender).Cutting != null)
   409                 {
   409                 {
   410                     //2-Creation du User Panel
   410                     //2-Creation du User Panel
   411                     CuttingViewModel newCuttingVM = ((UserControlScreen)sender).CuttingVM;
   411                     Cutting newCutting = ((UserControlScreen)sender).Cutting;
   412 
   412 
   413                     // We test if each Panel does not already own the sent cuttingVM
   413                     // We test if each Panel does not already own the sent cuttingVM
   414                     if (Panel1 != null)
   414                     if (Panel1 != null)
   415                         if (Panel1.CuttingVM.Title==newCuttingVM.Title)
   415                         if (Panel1.Cutting.Title==newCutting.Title)
   416                             return;
   416                             return;
   417                     if (Panel2 != null)
   417                     if (Panel2 != null)
   418                         if (Panel2.CuttingVM.Title == newCuttingVM.Title)
   418                         if (Panel2.Cutting.Title == newCutting.Title)
   419                             return;
   419                             return;
   420                     if (Panel3 != null)
   420                     if (Panel3 != null)
   421                         if (Panel3.CuttingVM.Title == newCuttingVM.Title)
   421                         if (Panel3.Cutting.Title == newCutting.Title)
   422                             return;
   422                             return;
   423                     if (Panel4 != null)
   423                     if (Panel4 != null)
   424                         if (Panel4.CuttingVM.Title == newCuttingVM.Title)
   424                         if (Panel4.Cutting.Title == newCutting.Title)
   425                             return;
   425                             return;
       
   426 
       
   427                     // We add the new cutting to the _mainviewmodel's datas
       
   428                     _mainviewmodel.Project.Cuttings.Add(newCutting);
       
   429                     _mainviewmodel.Project.CuttingsDict.Add("User " + ((UserControlScreen)sender).id, newCutting);
   426 
   430 
   427                     // And now we build the new UserPanel
   431                     // And now we build the new UserPanel
   428                     Random c = new Random();
   432                     Random c = new Random();
   429                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   433                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   430                     switch (((UserControlScreen)sender).id)
   434                     switch (((UserControlScreen)sender).id)
   431                     {
   435                     {
   432                         case 1:
   436                         case 1:
   433                             UserControlPivot.ApplyColor(1, color);
   437                             UserControlPivot.ApplyColor(1, color);
   434                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   438                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   435                             Panel1.Name = "UserPanel1";
   439                             Panel1.Name = "UserPanel1";
   436                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   440                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   437                             Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   441                             Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   438                             Panel1.idcolor = color;
   442                             Panel1.idcolor = color;
   439                             //3-Rajout sur la Grid Root
   443                             //3-Rajout sur la Grid Root
   440                             root.Children.Add(Panel1);
   444                             root.Children.Add(Panel1);
   441                             break;
   445                             break;
   442                         case 2:
   446                         case 2:
   443                             UserControlPivot.ApplyColor(2, color);
   447                             UserControlPivot.ApplyColor(2, color);
   444                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   448                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   445                             Panel2.Name = "UserPanel2";
   449                             Panel2.Name = "UserPanel2";
   446                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   450                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   447                             Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   451                             Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   448                             Panel2.idcolor = color;
   452                             Panel2.idcolor = color;
   449                             //3-Rajout sur la Grid Root
   453                             //3-Rajout sur la Grid Root
   450                             root.Children.Add(Panel2);
   454                             root.Children.Add(Panel2);
   451                             break;
   455                             break;
   452                         case 3:
   456                         case 3:
   453                             UserControlPivot.ApplyColor(3, color);
   457                             UserControlPivot.ApplyColor(3, color);
   454                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   458                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   455                             Panel3.Name = "UserPanel3";
   459                             Panel3.Name = "UserPanel3";
   456                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   460                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   457                             Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   461                             Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   458                             Panel3.idcolor = color;
   462                             Panel3.idcolor = color;
   459                             //3-Rajout sur la Grid Root
   463                             //3-Rajout sur la Grid Root
   460                             root.Children.Add(Panel3);
   464                             root.Children.Add(Panel3);
   461                             break;
   465                             break;
   462                         case 4:
   466                         case 4:
   463                             UserControlPivot.ApplyColor(4, color);
   467                             UserControlPivot.ApplyColor(4, color);
   464                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   468                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   465                             Panel4.Name = "UserPanel4";
   469                             Panel4.Name = "UserPanel4";
   466                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   470                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   467                             Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   471                             Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   468                             Panel4.idcolor = color;
   472                             Panel4.idcolor = color;
   469                             //3-Rajout sur la Grid Root
   473                             //3-Rajout sur la Grid Root