diff -r f5108a598aa7 -r 84b3bf5ee3d2 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Tue Oct 06 14:02:09 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Wed Oct 07 17:16:46 2009 +0200 @@ -14,6 +14,7 @@ using FingersDance.Data; using FingersDance.ViewModels; +using FingersDance.Views; namespace FingersDance.Control.TimeLine { @@ -118,7 +119,10 @@ CuttingVM = new CuttingViewModel(cut, AnnotWidth); tv.DataContext = CuttingVM; - slider_ContactTapGesture(this,null); + UserControlTimeLine_SizeChanged(null, null); + + slider_ContactTapGesture(this, null); + } @@ -182,8 +186,7 @@ DragStarted(this, new EventArgs()); } - private void sliderPosition_DragCompleted( - object sender, DragCompletedEventArgs e) + private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e) { finishedDragging = true; OnDragCompleted(); @@ -196,10 +199,47 @@ private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { - //addAnnotation(); + //startOrEndAnnotation(); } - public void addAnnotation() + public void addAnnotation(AnnotationViewModel avm) + { + 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) + { + foreach (Annotation a in AnnotList) + { + //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); + // Check begin TC + if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) + { + annotOk = false; + } + // Check end tc and if the new annotation will not cover any other + float endTC = avm.TcBegin + avm.Dur; + //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); + if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) + { + annotOk = false; + } + } + // If everything's fine, we create the new one + if (annotOk == true) + { + AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType)); + CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); + tv.DataContext = null; + tv.DataContext = CuttingVM; + AnnotWaiting = false; + } + + } + + } + + public void startOrEndAnnotation() { Boolean annotOk = true; // We open a new annotation