src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 213 110067a19ec8
parent 211 50e6fe2c2ea2
child 214 beebae32b1ed
equal deleted inserted replaced
212:bbac5d25dbb2 213:110067a19ec8
   405             {
   405             {
   406                 // We get UserControlScreen's instance and content
   406                 // We get UserControlScreen's instance and content
   407                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   407                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   408                 // We remove the UserControlScreen's instance
   408                 // We remove the UserControlScreen's instance
   409                 root.Children.Remove(((UserControlScreen)sender));
   409                 root.Children.Remove(((UserControlScreen)sender));
   410                 
   410 
   411                 if (((UserControlScreen)sender).Cutting != null)
   411                 if ((((UserControlScreen)sender).Cutting != null && ((UserControlScreen)sender).AnnotationOrSearchMode == "Annotation") || (((UserControlScreen)sender).AnnotationOrSearchMode == "Search"))
   412                 {
   412                 {
   413                     //2-Creation du User Panel
   413                     //2-Creation du User Panel
   414                     Cutting newCutting = ((UserControlScreen)sender).Cutting;
   414                     Cutting newCutting = ((UserControlScreen)sender).Cutting;
   415 
   415 
   416                     // We test if each Panel does not already own the sent cuttingVM
   416                     // We test if each Panel does not already own the sent cuttingVM
   417                     if (Panel1 != null)
   417                     if (((UserControlScreen)sender).Cutting != null && ((UserControlScreen)sender).AnnotationOrSearchMode == "Annotation")
   418                         if (Panel1.Cutting.Title==newCutting.Title)
   418                     {
   419                             return;
   419                         if (Panel1 != null)
   420                     if (Panel2 != null)
   420                             if (Panel1.Cutting.Title==newCutting.Title)
   421                         if (Panel2.Cutting.Title == newCutting.Title)
   421                                 return;
   422                             return;
   422                         if (Panel2 != null)
   423                     if (Panel3 != null)
   423                             if (Panel2.Cutting.Title == newCutting.Title)
   424                         if (Panel3.Cutting.Title == newCutting.Title)
   424                                 return;
   425                             return;
   425                         if (Panel3 != null)
   426                     if (Panel4 != null)
   426                             if (Panel3.Cutting.Title == newCutting.Title)
   427                         if (Panel4.Cutting.Title == newCutting.Title)
   427                                 return;
   428                             return;
   428                         if (Panel4 != null)
   429 
   429                             if (Panel4.Cutting.Title == newCutting.Title)
   430                     // We add the new cutting to the _mainviewmodel's datas IF THE CUTTING IS NEW (if not it means that it is from a loaded project)
   430                                 return;
   431                     if (!_mainviewmodel.Project.CuttingsDict.ContainsKey(newCutting.Title))
   431 
   432                     {
   432                         // We add the new cutting to the _mainviewmodel's datas IF THE CUTTING IS NEW (if not it means that it is from a loaded project)
   433                         _mainviewmodel.Project.Cuttings.Add(newCutting);
   433                         if (!_mainviewmodel.Project.CuttingsDict.ContainsKey(newCutting.Title))
   434                         _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting);
   434                         {
       
   435                             _mainviewmodel.Project.Cuttings.Add(newCutting);
       
   436                             _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting);
       
   437                         }
   435                     }
   438                     }
   436 
   439 
   437                     // And now we build the new UserPanel
   440                     // And now we build the new UserPanel
   438                     Random c = new Random();
   441                     Random c = new Random();
   439                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   442                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   440                     switch (((UserControlScreen)sender).id)
   443                     switch (((UserControlScreen)sender).id)
   441                     {
   444                     {
   442                         case 1:
   445                         case 1:
   443                             UserControlPivot.ApplyColor(1, color);
   446                             UserControlPivot.ApplyColor(1, color);
   444                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   447                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode);
   445                             Panel1.Name = "UserPanel1";
   448                             Panel1.Name = "UserPanel1";
   446                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   449                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   447                             Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   450                             Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   448                             Panel1.idcolor = color;
   451                             Panel1.idcolor = color;
   449                             //3-Rajout sur la Grid Root
   452                             //3-Rajout sur la Grid Root
   450                             root.Children.Add(Panel1);
   453                             root.Children.Add(Panel1);
   451                             break;
   454                             break;
   452                         case 2:
   455                         case 2:
   453                             UserControlPivot.ApplyColor(2, color);
   456                             UserControlPivot.ApplyColor(2, color);
   454                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   457                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode);
   455                             Panel2.Name = "UserPanel2";
   458                             Panel2.Name = "UserPanel2";
   456                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   459                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   457                             Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   460                             Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   458                             Panel2.idcolor = color;
   461                             Panel2.idcolor = color;
   459                             //3-Rajout sur la Grid Root
   462                             //3-Rajout sur la Grid Root
   460                             root.Children.Add(Panel2);
   463                             root.Children.Add(Panel2);
   461                             break;
   464                             break;
   462                         case 3:
   465                         case 3:
   463                             UserControlPivot.ApplyColor(3, color);
   466                             UserControlPivot.ApplyColor(3, color);
   464                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   467                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode);
   465                             Panel3.Name = "UserPanel3";
   468                             Panel3.Name = "UserPanel3";
   466                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   469                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   467                             Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   470                             Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   468                             Panel3.idcolor = color;
   471                             Panel3.idcolor = color;
   469                             //3-Rajout sur la Grid Root
   472                             //3-Rajout sur la Grid Root
   470                             root.Children.Add(Panel3);
   473                             root.Children.Add(Panel3);
   471                             break;
   474                             break;
   472                         case 4:
   475                         case 4:
   473                             UserControlPivot.ApplyColor(4, color);
   476                             UserControlPivot.ApplyColor(4, color);
   474                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
   477                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath, ((UserControlScreen)sender).AnnotationOrSearchMode);
   475                             Panel4.Name = "UserPanel4";
   478                             Panel4.Name = "UserPanel4";
   476                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   479                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
   477                             Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   480                             Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
   478                             Panel4.idcolor = color;
   481                             Panel4.idcolor = color;
   479                             //3-Rajout sur la Grid Root
   482                             //3-Rajout sur la Grid Root
   519             if (Panel1 == null && Panel2 == null && Panel3 == null && Panel4 == null)
   522             if (Panel1 == null && Panel2 == null && Panel3 == null && Panel4 == null)
   520                 _mainviewmodel.CloseProject();
   523                 _mainviewmodel.CloseProject();
   521         }
   524         }
   522 
   525 
   523 
   526 
   524         //On success annotation Display annotations in the different Panels
   527         //On success annotation we save the update datas
   525         private void Panel_OnSuccessAnnotation(object sender, EventArgs e)
   528         private void Panel_OnSuccessAnnotation(object sender, EventArgs e)
   526         {
   529         {
   527             // We save datas
   530             // We save datas
   528             saveDatas();
   531             saveDatas();
   529         }
   532         }