--- 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<Annotation> annotList = new List<Annotation>();
- private float annotWidth = 40+1;
- private CuttingViewModel cutvm;
+ private List<Annotation> AnnotList = new List<Annotation>();
+ 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<Annotation>();
- annotList.Add(new Annotation(0, 10, "Axe Cam 1"));
+ AnnotList = new List<Annotation>();
+ 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;
}
}