src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
changeset 130 192da585bee5
parent 129 1f37ef03ebee
child 135 84b3bf5ee3d2
equal deleted inserted replaced
129:1f37ef03ebee 130:192da585bee5
    35         private List<Annotation> AnnotList = new List<Annotation>();
    35         private List<Annotation> AnnotList = new List<Annotation>();
    36         private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item
    36         private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item
    37         private CuttingViewModel CuttingVM;
    37         private CuttingViewModel CuttingVM;
    38         private Boolean AnnotWaiting = false;
    38         private Boolean AnnotWaiting = false;
    39         private float AnnotTcBegin;
    39         private float AnnotTcBegin;
    40         private AnnotationViewModel lastAnnotVM;
       
    41 
    40 
    42         #region Properties
    41         #region Properties
    43 
    42 
    44         public SurfaceSlider Slider
    43         public SurfaceSlider Slider
    45         {
    44         {
   209                 AnnotTcBegin = (float)slider.Value / 1000;
   208                 AnnotTcBegin = (float)slider.Value / 1000;
   210 
   209 
   211                 // First we check if the new annotation will not cover any
   210                 // First we check if the new annotation will not cover any
   212                 foreach (Annotation a in AnnotList)
   211                 foreach (Annotation a in AnnotList)
   213                 {
   212                 {
   214                     Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
   213                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
   215                     if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur))
   214                     if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur))
   216                     {
   215                     {
   217                         annotOk = false;
   216                         annotOk = false;
   218                     }
   217                     }
   219                 }
   218                 }
   220                 // if not, we mark the beginning
   219                 // if not, we mark the beginning
   221                 if (annotOk == true)
   220                 if (annotOk == true)
   222                 {
   221                 {
   223                     AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
   222                     AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
   224                     //AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString()));
       
   225                     //AnnotList.Add(new Annotation(0, 0, AnnotList.Count.ToString()));
       
   226 
       
   227                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
   223                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
   228                     //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
   224                     //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
   229                     tv.DataContext = null;
   225                     tv.DataContext = null;
   230                     tv.DataContext = CuttingVM;
   226                     tv.DataContext = CuttingVM;
   231                     AnnotWaiting = true;
   227                     AnnotWaiting = true;
   232                 }
   228                 }
   233                 
       
   234             }
   229             }
   235             // We close the current opened annotation...
   230             // We close the current opened annotation...
   236             else if (CuttingVM != null && AnnotWaiting == true && ((float)slider.Value>AnnotTcBegin))
   231             else if (CuttingVM != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin))
   237             {
   232             {
   238                 // ... by setting setting the good beginning and the good duration
   233                 // ... by setting setting the good beginning and the good duration
   239                 float currentTC = (float)slider.Value / 1000;
   234                 float currentTC = (float)slider.Value / 1000;
   240                 float currentDuration = currentTC - AnnotTcBegin;
   235                 float currentDuration = currentTC - AnnotTcBegin;
   241 
   236 
   242                 // First we check if the new annotation will not cover any (AnnotTcBegin was already checked)
   237                 // First we check if the new annotation will not cover any (AnnotTcBegin was already checked)
   243                 foreach (Annotation a in AnnotList)
   238                 foreach (Annotation a in AnnotList)
   244                 {
   239                 {
   245                     Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
   240                     //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
   246                     if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC))
   241                     if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC))
   247                     {
   242                     {
   248                         annotOk = false;
   243                         annotOk = false;
   249                     }
   244                     }
   250                 }
   245                 }
   251 
   246 
   252                 if (annotOk == true)
   247                 if (annotOk == true)
   253                 {
   248                 {
   254                     AnnotList.RemoveAt(AnnotList.Count - 1);
   249                     AnnotList.RemoveAt(AnnotList.Count - 1);
   255                     AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString()));
   250                     AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString()));
   256                     //AnnotList.Add(new Annotation(AnnotTcBegin - (AnnotList.Count * AnnotWidth), currentDuration, AnnotList.Count.ToString()));
       
   257                     //AnnotList.Add(new Annotation((AnnotTcBegin / 1000), currentDuration, CuttingVM.AnnotList.Count.ToString()));
       
   258                     //AnnotList.Add(new Annotation(0, currentDuration, CuttingVM.AnnotList.Count.ToString()));
       
   259 
       
   260 
       
   261                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
   251                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
   262                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
   252                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
   263                     tv.DataContext = null;
   253                     tv.DataContext = null;
   264                     tv.DataContext = CuttingVM;
   254                     tv.DataContext = CuttingVM;
   265                     AnnotWaiting = false;
   255                     AnnotWaiting = false;