src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
changeset 195 48b3139bb182
parent 194 d96cd2bce653
child 196 e738cd9c1b99
equal deleted inserted replaced
194:d96cd2bce653 195:48b3139bb182
    31         #endregion
    31         #endregion
    32         
    32         
    33         public event EventHandler DragStarted;
    33         public event EventHandler DragStarted;
    34         public event EventHandler DragCompleted;
    34         public event EventHandler DragCompleted;
    35         public event EventHandler TimerTick;
    35         public event EventHandler TimerTick;
       
    36         public event EventHandler AnnotationAdded;
       
    37         public event EventHandler AnnotationRemoved;
    36         //SAR
    38         //SAR
    37         public event EventHandler OnSuccessAnnotation;
    39         public event EventHandler OnSuccessAnnotation;
    38         //ENDSAR
    40         //ENDSAR
    39 
    41 
    40         private double totalmilliseconds;
    42         private double totalmilliseconds;
   279                     }
   281                     }
   280                 }
   282                 }
   281                 // If everything's fine, we create the new one
   283                 // If everything's fine, we create the new one
   282                 if (annotOk == true)
   284                 if (annotOk == true)
   283                 {
   285                 {
   284                     cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
   286                     Annotation annotation = new Annotation("s_" + System.Guid.NewGuid(), avm.TcBegin, avm.Dur, avm.GestureType, avm.Color);
       
   287                     cut.AnnotList.Add(annotation);
   285                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   288                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
       
   289                     if (AnnotationAdded != null)
       
   290                         AnnotationAdded(annotation, null);
   286                     AnnotWaiting = false;
   291                     AnnotWaiting = false;
   287                 }
   292                 }
   288 
   293 
   289             }
   294             }
   290             //Raise Event to display Annotation in all Openned UserPanels
   295             //Raise Event to display Annotation in all Openned UserPanels
   311                     }
   316                     }
   312                 }
   317                 }
   313                 // if not, we mark the beginning
   318                 // if not, we mark the beginning
   314                 if (annotOk == true)
   319                 if (annotOk == true)
   315                 {
   320                 {
   316                     cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, 0, gestureType, CurrentColor));
   321                     cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, 0, cut.AnnotList.Count.ToString(), CurrentColor));
       
   322                     cut.AnnotList.Add(annotation);
   317                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   323                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   318                     AnnotWaiting = true;
   324                     AnnotWaiting = true;
   319                 }
   325                 }
   320             }
   326             }
   321             // We close the current opened annotation...
   327             // We close the current opened annotation...
   336                 }
   342                 }
   337 
   343 
   338                 if (annotOk == true)
   344                 if (annotOk == true)
   339                 {
   345                 {
   340                     cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1);
   346                     cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1);
   341                     cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, currentDuration, gestureType, CurrentColor));
   347                     Annotation annotation = new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, currentDuration, gestureType, CurrentColor);
       
   348                     cut.AnnotList.Add(annotation);
   342                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth)));
   349                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth)));
   343                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   350                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   344                     AnnotWaiting = false;
   351                     AnnotWaiting = false;
       
   352                     if (AnnotationAdded != null)
       
   353                         AnnotationAdded(annotation, null);
   345                 }
   354                 }
   346                 //Raise Event to display Annotation in all Openned UserPanels
   355                 //Raise Event to display Annotation in all Openned UserPanels
   347                 if (annotOk)
   356                 if (annotOk)
   348                     OnSuccessAnnotation(this, new EventArgs());
   357                     OnSuccessAnnotation(this, new EventArgs());
   349             }
   358             }
   445                         tv.DataContext = null;
   454                         tv.DataContext = null;
   446                         tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   455                         tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
   447                         // We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified
   456                         // We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified
   448                         confirmCancelPopup.Visibility = Visibility.Hidden;
   457                         confirmCancelPopup.Visibility = Visibility.Hidden;
   449                         canceledAnnotationVM = null;
   458                         canceledAnnotationVM = null;
       
   459                         if (AnnotationRemoved != null)
       
   460                             AnnotationRemoved(a, null);
   450                         return;
   461                         return;
   451                     }
   462                     }
   452                 }
   463                 }
   453             }
   464             }
   454             confirmCancelPopup.Visibility = Visibility.Hidden;
   465             confirmCancelPopup.Visibility = Visibility.Hidden;