src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 186 83615722dbab
parent 182 25b49d4f1635
child 188 e642ad0c366b
equal deleted inserted replaced
185:9b62e08d6167 186:83615722dbab
   402             try
   402             try
   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).Cutting != null)
   408                 if (((UserControlScreen)sender).CuttingVM != null)
   409                 {
   409                 {
   410                     //2-Creation du User Panel
   410                     //2-Creation du User Panel
   411                     CuttingViewModel newCuttingVM = ((UserControlScreen)sender).Cutting;
   411                     CuttingViewModel newCuttingVM = ((UserControlScreen)sender).CuttingVM;
   412 
   412 
   413                     if ((Panel1 != null && Panel1.CuttingVM.Equals(newCuttingVM)) || (Panel2 != null && Panel2.CuttingVM.Equals(newCuttingVM)) || (Panel3 != null && Panel3.CuttingVM.Equals(newCuttingVM)) || (Panel4 != null && Panel4.CuttingVM.Equals(newCuttingVM)))
   413                     // We test if each Panel does not already own the sent cuttingVM
   414                         return;
   414                     if (Panel1 != null)
   415 
   415                         if (Panel1.CuttingVM.Title==newCuttingVM.Title)
       
   416                             return;
       
   417                     if (Panel2 != null)
       
   418                         if (Panel2.CuttingVM.Title == newCuttingVM.Title)
       
   419                             return;
       
   420                     if (Panel3 != null)
       
   421                         if (Panel3.CuttingVM.Title == newCuttingVM.Title)
       
   422                             return;
       
   423                     if (Panel4 != null)
       
   424                         if (Panel4.CuttingVM.Title == newCuttingVM.Title)
       
   425                             return;
       
   426 
       
   427                     // And now we build the new UserPanel
   416                     Random c = new Random();
   428                     Random c = new Random();
   417                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   429                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   418                     switch (((UserControlScreen)sender).id)
   430                     switch (((UserControlScreen)sender).id)
   419                     {
   431                     {
   420                         case 1:
   432                         case 1:
   421                             UserControlPivot.ApplyColor(1, color);
   433                             UserControlPivot.ApplyColor(1, color);
   422                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCuttingVM.Cutting, _mainviewmodel.Project.VideoPath);
   434                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   423                             Panel1.Name = "UserPanel1";
   435                             Panel1.Name = "UserPanel1";
   424                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   436                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   425                             Panel1.idcolor = color;
   437                             Panel1.idcolor = color;
   426                             //3-Rajout sur la Grid Root
   438                             //3-Rajout sur la Grid Root
   427                             root.Children.Add(Panel1);
   439                             root.Children.Add(Panel1);
   428                             break;
   440                             break;
   429                         case 2:
   441                         case 2:
   430                             UserControlPivot.ApplyColor(2, color);
   442                             UserControlPivot.ApplyColor(2, color);
   431                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCuttingVM.Cutting, _mainviewmodel.Project.VideoPath);
   443                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   432                             Panel2.Name = "UserPanel2";
   444                             Panel2.Name = "UserPanel2";
   433                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   445                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   434                             Panel2.idcolor = color;
   446                             Panel2.idcolor = color;
   435                             //3-Rajout sur la Grid Root
   447                             //3-Rajout sur la Grid Root
   436                             root.Children.Add(Panel2);
   448                             root.Children.Add(Panel2);
   437                             break;
   449                             break;
   438                         case 3:
   450                         case 3:
   439                             UserControlPivot.ApplyColor(3, color);
   451                             UserControlPivot.ApplyColor(3, color);
   440                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCuttingVM.Cutting, _mainviewmodel.Project.VideoPath);
   452                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   441                             Panel3.Name = "UserPanel3";
   453                             Panel3.Name = "UserPanel3";
   442                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   454                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   443                             Panel3.idcolor = color;
   455                             Panel3.idcolor = color;
   444                             //3-Rajout sur la Grid Root
   456                             //3-Rajout sur la Grid Root
   445                             root.Children.Add(Panel3);
   457                             root.Children.Add(Panel3);
   446                             break;
   458                             break;
   447                         case 4:
   459                         case 4:
   448                             UserControlPivot.ApplyColor(4, color);
   460                             UserControlPivot.ApplyColor(4, color);
   449                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCuttingVM.Cutting, _mainviewmodel.Project.VideoPath);
   461                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
   450                             Panel4.Name = "UserPanel4";
   462                             Panel4.Name = "UserPanel4";
   451                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   463                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   452                             Panel4.idcolor = color;
   464                             Panel4.idcolor = color;
   453                             //3-Rajout sur la Grid Root
   465                             //3-Rajout sur la Grid Root
   454                             root.Children.Add(Panel4);
   466                             root.Children.Add(Panel4);