# HG changeset patch # User cavaliet # Date 1254215317 -7200 # Node ID fab494cd9da74153d86e999b92134faaf3e4237a # Parent 14b058fc64fc11db1f7dd1fbaa2f532350854fec Now to define an annotation we define its begin then its end. diff -r 14b058fc64fc -r fab494cd9da7 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Fri Sep 25 18:28:58 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Tue Sep 29 11:08:37 2009 +0200 @@ -780,6 +780,6 @@ - + \ No newline at end of file diff -r 14b058fc64fc -r fab494cd9da7 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Sep 25 18:28:58 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Tue Sep 29 11:08:37 2009 +0200 @@ -32,9 +32,12 @@ private double totalmilliseconds; - private List annotList = new List(); - private float annotWidth = 40+1; - private CuttingViewModel cutvm; + private List AnnotList = new List(); + private float AnnotWidth = 40+1; + private CuttingViewModel CuttingVM; + private Boolean AnnotWaiting = false; + private float AnnotTcBegin; + private AnnotationViewModel lastAnnotVM; #region Properties @@ -106,31 +109,27 @@ this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); // TEMP FOR DATA BINDING - annotList = new List(); - annotList.Add(new Annotation(0, 10, "Axe Cam 1")); + AnnotList = new List(); + AnnotList.Add(new Annotation(0, 10, "Axe Cam 1")); //annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2")); //annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3")); //annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4")); //annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5")); - Cutting cut = new Cutting("titre de cutting", annotList); - cutvm = new CuttingViewModel(cut); - tv.DataContext = cutvm; + Cutting cut = new Cutting("titre de cutting", AnnotList); + CuttingVM = new CuttingViewModel(cut); + tv.DataContext = CuttingVM; slider_ContactTapGesture(this,null); - /* - cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6"))); - tv.DataContext = null; - tv.DataContext = cutvm; - */ + } void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) { // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. Double futurScale = this.ActualWidth / (totalmilliseconds / 1000); - //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP + //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS tv.RenderTransform = new ScaleTransform(futurScale,1); - Console.WriteLine("futurScale = " + futurScale); + //Console.WriteLine("futurScale = " + futurScale); } @@ -204,13 +203,28 @@ public void addAnnotation() { - if (cutvm!=null) + // We open a new annotation + if (CuttingVM != null && AnnotWaiting == false) { - float currentTimecode = (float)slider.Value / 1000; - cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(currentTimecode - (cutvm.AnnotList.Count * annotWidth), 10, cutvm.AnnotList.Count.ToString()))); - Console.WriteLine("currentTimecode = " + currentTimecode + ", nb = " + cutvm.AnnotList.Count + ", res = " + (currentTimecode - (cutvm.AnnotList.Count * annotWidth))); + AnnotTcBegin = (float)slider.Value; + lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), 0, CuttingVM.AnnotList.Count.ToString())); + CuttingVM.AnnotList.Add(lastAnnotVM); + Console.WriteLine("BEGIN currentTimecode = " + (AnnotTcBegin / 1000) + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth))); tv.DataContext = null; - tv.DataContext = cutvm; + tv.DataContext = CuttingVM; + AnnotWaiting = true; + } + // We close the current opened annotation... + else if (CuttingVM != null && AnnotWaiting == true && ((float)slider.Value>AnnotTcBegin)) + { + // ... by setting setting the good beginning and the good duration + float currentDuration = ((float)slider.Value - AnnotTcBegin) / 1000; + CuttingVM.AnnotList.RemoveAt(CuttingVM.AnnotList.Count - 1); + CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), currentDuration, CuttingVM.AnnotList.Count.ToString()))); + Console.WriteLine("currentTimecode = " + (AnnotTcBegin / 1000) + ", curDur = " + currentDuration + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth))); + tv.DataContext = null; + tv.DataContext = CuttingVM; + AnnotWaiting = false; } } diff -r 14b058fc64fc -r fab494cd9da7 src/FingersDance.Views/TimelineAnnotationView.xaml --- a/src/FingersDance.Views/TimelineAnnotationView.xaml Fri Sep 25 18:28:58 2009 +0200 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml Tue Sep 29 11:08:37 2009 +0200 @@ -8,14 +8,18 @@ x:Class="FingersDance.Views.TimelineAnnotationView" xmlns:vw="clr-namespace:FingersDance.Views" x:Name="UserControl" - d:DesignWidth="640" d:DesignHeight="480" Width="40"> + d:DesignWidth="640" d:DesignHeight="480" Width="40" Loaded="UserControl_Loaded"> - + + - - - - - - + + + + + + + + + \ No newline at end of file diff -r 14b058fc64fc -r fab494cd9da7 src/FingersDance.Views/TimelineAnnotationView.xaml.cs --- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Fri Sep 25 18:28:58 2009 +0200 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Tue Sep 29 11:08:37 2009 +0200 @@ -23,6 +23,11 @@ { InitializeComponent(); } + + private void UserControl_Loaded(object sender, RoutedEventArgs e) + { + + } } public class ThicknessSingleValueConverter : IValueConverter @@ -41,4 +46,17 @@ return thickness.Left; } } + + public class VisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + Visibility v = ((float)value>0) ? Visibility.Visible : Visibility.Hidden; + return v; + } + public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture) + { + return 1.0; + } + } }