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 |