MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
authorcavaliet
Mon, 09 Nov 2009 12:11:42 +0100
changeset 190 619ca3ae13c7
parent 189 b37888f59cf2
child 191 8a25a85f2656
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance.ViewModel/CuttingViewModel.cs
src/FingersDance/MainSurfaceWindow.xaml.cs
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -20,8 +20,8 @@
         public String contexteGrid;
         public int id = 0;
         public event EventHandler UC_Screen_NewCutting;
-        public MainViewModel MainViewModel;
-        public CuttingViewModel CuttingVM;
+        private MainViewModel _mainViewModel;
+        public Cutting Cutting;
         private List<Project> existingProjects = new List<Project>();
         User User = new User();
 
@@ -32,8 +32,8 @@
                 this.InitializeComponent();
                 this.id = id;
                 User.Name = "User " + id;
-                MainViewModel = mvmodel;
-                if (MainViewModel.Project.VideoPath.Equals(""))
+                _mainViewModel = mvmodel;
+                if (_mainViewModel.Project.VideoPath.Equals(""))
                 {
                     //1-Creation de la ListVideo
                     UserControlListVideo ListVideo = new UserControlListVideo();
@@ -48,7 +48,7 @@
             }
             catch (Exception)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -69,14 +69,14 @@
             try
             {
                 //1 renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo
-                MainViewModel.CreateProject(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path);
+                _mainViewModel.CreateProject(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path);
                 //2-Supression du UC List Video
                 LayoutRoot.Children.Remove((UserControlListVideo)sender);
                 OpenProjectList();
             }
             catch (Exception ex)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -86,7 +86,7 @@
         {
             try
             {
-                existingProjects = LoadProjects(MainViewModel.Project.VideoPath);
+                existingProjects = LoadProjects(_mainViewModel.Project.VideoPath);
                 UserControlListProject listProject = new UserControlListProject(existingProjects);
                 listProject.Name = "ListProject";
                 LayoutRoot.Children.Add(listProject);
@@ -94,7 +94,7 @@
             }
             catch (Exception)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -131,7 +131,7 @@
                     {
                         if (elt.Name.Equals(((UserControlListProject)sender).SelectedItem))
                         {
-                            MainViewModel.Project.Project = elt;
+                            _mainViewModel.Project.Project = elt;
                             OpenProject();
                             return;
                         }
@@ -140,7 +140,7 @@
             }
             catch (Exception)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -152,8 +152,8 @@
             {
                 //MainViewModel.Project.Alias = ((UserControlNewProjectForm)sender).Alias;
                 //MainViewModel.Project.Email = ((UserControlNewProjectForm)sender).Email;
-                MainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description;
-                MainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName;
+                _mainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description;
+                _mainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName;
                 
                 
                 //2-Suppression UCSession Input
@@ -162,7 +162,7 @@
             }
             catch (Exception ex) 
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -172,14 +172,14 @@
         {
             try
             {
-                UserControlListCutting listCuttings = new UserControlListCutting(MainViewModel.Project.CuttingsDict);
+                UserControlListCutting listCuttings = new UserControlListCutting(_mainViewModel.Project.CuttingsDict);
                 listCuttings.Name = "listCuttings";
                 LayoutRoot.Children.Add(listCuttings);
                 listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown);
             }
             catch (Exception) 
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -199,10 +199,10 @@
                 }
                 else
                 {
-                    foreach(KeyValuePair<string, Cutting> elt in MainViewModel.Project.CuttingsDict)
+                    foreach(KeyValuePair<string, Cutting> elt in _mainViewModel.Project.CuttingsDict)
                         if (elt.Key.Equals(((UserControlListCutting)sender).SelectedItem))
                         {
-                            CuttingVM = new CuttingViewModel(elt.Value, 815);
+                            Cutting = elt.Value;
                             if (UC_Screen_NewCutting != null)
                                 UC_Screen_NewCutting(this, new EventArgs());
                             return;
@@ -211,7 +211,7 @@
             }
             catch (Exception)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
@@ -222,14 +222,13 @@
             try
             {
                 LayoutRoot.Children.Remove((UserControlNewCuttingForm)sender);
-                CuttingVM = new CuttingViewModel(((UserControlNewCuttingForm)sender).Cutting, 850);
-                MainViewModel.Project.CuttingsDict.Add(CuttingVM.Title, ((UserControlNewCuttingForm)sender).Cutting);
+                Cutting = ((UserControlNewCuttingForm)sender).Cutting;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
             catch (Exception)
             {
-                CuttingVM = null;
+                Cutting = null;
                 if (UC_Screen_NewCutting != null)
                     UC_Screen_NewCutting(this, new EventArgs());
             }
--- a/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj	Mon Nov 09 12:11:42 2009 +0100
@@ -140,9 +140,9 @@
       <Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
       <Name>FingersDance.Control.TimeLine</Name>
     </ProjectReference>
-    <ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
-      <Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
-      <Name>FingersDance.ViewModels</Name>
+    <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+      <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+      <Name>FingersDance.Data</Name>
     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -8,7 +8,7 @@
 using System.Windows.Media.Animation;
 using System.Windows.Navigation;
 using FingersDance.Control.TimeLine;
-using FingersDance.ViewModels;
+using FingersDance.Data;
 
 namespace FingersDance.Control.SyncSource
 {
@@ -25,11 +25,11 @@
 			// Insert code required on object creation below this point.
 		}
 
-        public void Load(string path, Color col, CuttingViewModel cutVM)
+        public void Load(string path, Color col, Cutting cut)
         {
             this.UserControlPlayer.initPlayer(path);
             //Initialisation du Timer
-            UCTimeLine.initTimer(col, cutVM);
+            UCTimeLine.initTimer(col, cut);
             this.UserControlPlayer.playerPlay();
             this.userControlTimeLine.OnSuccessAnnotation+=new EventHandler(userControlTimeLine_OnSuccessAnnotation);
             this.UserControlPlayer.PlayerStopOrPause +=new EventHandler(UserControlPlayer_PlayerStopOrPause);
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -39,9 +39,8 @@
 
         private double totalmilliseconds;
         
-        private List<Annotation> AnnotList = new List<Annotation>();
         private float AnnotWidth = 850 + 15; // The surfaceListBox adds 15 pixels between each item
-        private CuttingViewModel CuttingVM;
+        private Cutting cut;
         private Boolean AnnotWaiting = false;
         private float AnnotTcBegin;
         private Color CurrentColor;
@@ -136,24 +135,24 @@
         }
 
         #region Timer
-        public void initTimer(Color col, CuttingViewModel cutVMPar)
+        public void initTimer(Color col, Cutting cutPar)
         {
             timer = new DispatcherTimer();
             timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
             timer.Tick += new EventHandler(timer_Tick);
 
             CurrentColor = col;
-            
+
             // DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project)
-            AnnotList = new List<Annotation>();
-            AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor));
-            //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2"));
-            //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3"));
-            //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
-            //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5"));
-            CuttingVM = new CuttingViewModel(new Cutting(cutVMPar.Title, AnnotList), AnnotWidth);
-            cutVMPar = CuttingVM;
-            tv.DataContext = CuttingVM;
+            cut = cutPar;
+            cut.AnnotList = new List<Annotation>();
+            cut.AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor));
+            //cut.AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2"));
+            //cut.AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3"));
+            //cut.AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
+            //cut.AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5"));
+            //cut.AnnotList = AnnotList;
+            tv.DataContext = new CuttingViewModel(cut, AnnotWidth);
 
         }
 
@@ -229,9 +228,9 @@
         {
             Boolean annotOk = true;
             // We check if the annotation's begin and end timecodes allow a new annotation creation
-            if (CuttingVM != null && AnnotWaiting == false)
+            if (cut != null && AnnotWaiting == false)
             {
-                foreach (Annotation a in AnnotList)
+                foreach (Annotation a in cut.AnnotList)
                 {
                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
                     // Check begin TC
@@ -261,9 +260,9 @@
             //Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType);
             Boolean annotOk = true;
             // We check if the annotation's begin and end timecodes allow a new annotation creation
-            if (CuttingVM != null && AnnotWaiting == false)
+            if (cut != null && AnnotWaiting == false)
             {
-                foreach (Annotation a in AnnotList)
+                foreach (Annotation a in cut.AnnotList)
                 {
                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
                     // Check begin TC
@@ -282,10 +281,8 @@
                 // If everything's fine, we create the new one
                 if (annotOk == true)
                 {
-                    AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
-                    tv.DataContext = null;
-                    tv.DataContext = CuttingVM;
+                    cut.AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
+                    tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
                     AnnotWaiting = false;
                 }
 
@@ -300,12 +297,12 @@
         {
             Boolean annotOk = true;
             // We open a new annotation
-            if (CuttingVM != null && AnnotWaiting == false)
+            if (cut != null && AnnotWaiting == false)
             {
                 AnnotTcBegin = (float)slider.Value / 1000;
 
                 // First we check if the new annotation will not cover any
-                foreach (Annotation a in AnnotList)
+                foreach (Annotation a in cut.AnnotList)
                 {
                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
                     if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur))
@@ -316,22 +313,20 @@
                 // if not, we mark the beginning
                 if (annotOk == true)
                 {
-                    AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
-                    tv.DataContext = null;
-                    tv.DataContext = CuttingVM;
+                    cut.AnnotList.Add(new Annotation(AnnotTcBegin, 0, cut.AnnotList.Count.ToString(), CurrentColor));
+                    tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
                     AnnotWaiting = true;
                 }
             }
             // We close the current opened annotation...
-            else if (CuttingVM != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin))
+            else if (cut != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin))
             {
                 // ... by setting setting the good beginning and the good duration
                 float currentTC = (float)slider.Value / 1000;
                 float currentDuration = currentTC - AnnotTcBegin;
 
                 // First we check if the new annotation will not cover any (AnnotTcBegin was already checked)
-                foreach (Annotation a in AnnotList)
+                foreach (Annotation a in cut.AnnotList)
                 {
                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
                     if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC))
@@ -342,12 +337,10 @@
 
                 if (annotOk == true)
                 {
-                    AnnotList.RemoveAt(AnnotList.Count - 1);
-                    AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
-                    //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
-                    tv.DataContext = null;
-                    tv.DataContext = CuttingVM;
+                    cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1);
+                    cut.AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, cut.AnnotList.Count.ToString(), CurrentColor));
+                    //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth)));
+                    tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
                     AnnotWaiting = false;
                 }
                 //Raise Event to display Annotation in all Openned UserPanels
@@ -427,7 +420,7 @@
         private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e)
         {
             // We check if the annotation is well one of the current annotations
-            if (CuttingVM != null)
+            if (cut != null)
             {
                 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
                 canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
@@ -438,20 +431,20 @@
         private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e)
         {
             // We check if the annotation is well one of the current annotations
-            if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true)
+            if (cut != null && canceledAnnotationVM != null && e.Confirmed == true)
             {
-                foreach (Annotation a in AnnotList)
+                foreach (Annotation a in cut.AnnotList)
                 {
                     // Check begin TcBegin, duration and gesture type
                     if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType)
                     {
                         // We found the good annotation so we can remove it
-                        AnnotList.Remove(a);
+                        cut.AnnotList.Remove(a);
                         // We redisplay the timeline
-                        CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
+                        //CuttingVM.setListFromAnnotations(cut.AnnotList, AnnotWidth, tv.ScaleX);
                         tv.DataContext = null;
-                        tv.DataContext = CuttingVM;
-                        // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified
+                        tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
+                        // We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified
                         confirmCancelPopup.Visibility = Visibility.Hidden;
                         canceledAnnotationVM = null;
                         return;
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -26,7 +26,7 @@
         public int id = 0;
         public uint idcolor = 0;    //The color of the Pivot Button
         //Project _Project = new Project();
-        private CuttingViewModel cutVM;
+        private Cutting cut;
 
         //variables for TagSound Control
         double baseOrientation = 0;
@@ -37,10 +37,10 @@
         #endregion
 
         #region Properties
-        public CuttingViewModel CuttingVM
+        public Cutting Cutting
         {
-            get { return cutVM; }
-            set { cutVM = value; }
+            get { return cut; }
+            set { cut = value; }
         }
         #endregion
 
@@ -60,13 +60,13 @@
 			// Insert code required on object creation below this point.
 		}
 
-        public UserControlUserPanel(int idPar, Color col, CuttingViewModel cutVMPar, string path)
+        public UserControlUserPanel(int idPar, Color col, Cutting cutPar, string path)
         {
             this.InitializeComponent();
             id = idPar;
             //_Project = p;
-            cutVM = cutVMPar;
-            this.UserControlSyncSource.Load(path, col, cutVM);
+            cut = cutPar;
+            this.UserControlSyncSource.Load(path, col, cut);
             UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
             //SAR -Initialize Tag Values
             InitializeDefinitions();
--- a/src/FingersDance.ViewModel/CuttingViewModel.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.ViewModel/CuttingViewModel.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -13,6 +13,20 @@
 
         private List<AnnotationViewModel> _annotList = new List<AnnotationViewModel>();
 
+        public CuttingViewModel(Cutting c, float annotWidth, Double scaleX)
+        {
+
+            cut = c;
+            this._annotList = new List<AnnotationViewModel>();
+            int i = 0;
+            foreach (Annotation annot in c.AnnotList)
+            {
+                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1 / scaleX));
+                i++;
+            }
+
+        }
+
         public CuttingViewModel(Cutting c, float annotWidth) {
 
             cut = c;
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
@@ -307,7 +307,7 @@
                         //2-Rajout du screen dans la grid correspondante
                         Grid1.Children.Add(Screen);
 
-                        Screen.UC_Screen_NewCutting += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
+                        Screen.UC_Screen_NewCutting += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); 
                     }
                     else //Affichage du message de confirmation
                     {
@@ -405,25 +405,29 @@
                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
                 root.Children.Remove(((UserControlScreen)sender));
                 
-                if (((UserControlScreen)sender).CuttingVM != null)
+                if (((UserControlScreen)sender).Cutting != null)
                 {
                     //2-Creation du User Panel
-                    CuttingViewModel newCuttingVM = ((UserControlScreen)sender).CuttingVM;
+                    Cutting newCutting = ((UserControlScreen)sender).Cutting;
 
                     // We test if each Panel does not already own the sent cuttingVM
                     if (Panel1 != null)
-                        if (Panel1.CuttingVM.Title==newCuttingVM.Title)
+                        if (Panel1.Cutting.Title==newCutting.Title)
                             return;
                     if (Panel2 != null)
-                        if (Panel2.CuttingVM.Title == newCuttingVM.Title)
+                        if (Panel2.Cutting.Title == newCutting.Title)
                             return;
                     if (Panel3 != null)
-                        if (Panel3.CuttingVM.Title == newCuttingVM.Title)
+                        if (Panel3.Cutting.Title == newCutting.Title)
                             return;
                     if (Panel4 != null)
-                        if (Panel4.CuttingVM.Title == newCuttingVM.Title)
+                        if (Panel4.Cutting.Title == newCutting.Title)
                             return;
 
+                    // We add the new cutting to the _mainviewmodel's datas
+                    _mainviewmodel.Project.Cuttings.Add(newCutting);
+                    _mainviewmodel.Project.CuttingsDict.Add("User " + ((UserControlScreen)sender).id, newCutting);
+
                     // And now we build the new UserPanel
                     Random c = new Random();
                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
@@ -431,7 +435,7 @@
                     {
                         case 1:
                             UserControlPivot.ApplyColor(1, color);
-                            Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
+                            Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
                             Panel1.Name = "UserPanel1";
                             Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
                             Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
@@ -441,7 +445,7 @@
                             break;
                         case 2:
                             UserControlPivot.ApplyColor(2, color);
-                            Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
+                            Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
                             Panel2.Name = "UserPanel2";
                             Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
                             Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
@@ -451,7 +455,7 @@
                             break;
                         case 3:
                             UserControlPivot.ApplyColor(3, color);
-                            Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
+                            Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
                             Panel3.Name = "UserPanel3";
                             Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
                             Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);
@@ -461,7 +465,7 @@
                             break;
                         case 4:
                             UserControlPivot.ApplyColor(4, color);
-                            Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath);
+                            Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCutting, _mainviewmodel.Project.VideoPath);
                             Panel4.Name = "UserPanel4";
                             Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
                             Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation);