--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Sep 25 03:38:22 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Sep 25 18:28:58 2009 +0200
@@ -30,10 +30,11 @@
public event EventHandler DragCompleted;
public event EventHandler TimerTick;
+ private double totalmilliseconds;
+
private List<Annotation> annotList = new List<Annotation>();
- private float annotWidth = 40;
+ private float annotWidth = 40+1;
private CuttingViewModel cutvm;
- private int numAnnot = 1;
#region Properties
@@ -97,32 +98,42 @@
}
- public void initslider(double totalmilliseconds)
+ public void initslider(double totalmillisecondsPar)
{
+ totalmilliseconds = totalmillisecondsPar;
slider.Maximum = totalmilliseconds;
-
+ // When the timeline is resized, we catch the resize event to define TimelineView's good scale
+ this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged);
// TEMP FOR DATA BINDING
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"));
+ //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;
- numAnnot = 6;
slider_ContactTapGesture(this,null);
/*
cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6")));
tv.DataContext = null;
tv.DataContext = cutvm;
- numAnnot = 7;
*/
}
+ 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
+ tv.RenderTransform = new ScaleTransform(futurScale,1);
+ Console.WriteLine("futurScale = " + futurScale);
+
+ }
+
#region Timer
public void initTimer()
{
@@ -193,10 +204,14 @@
public void addAnnotation()
{
- cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 + (numAnnot - 6) * 20 - ((numAnnot - 1) * annotWidth), 10, numAnnot.ToString())));
- tv.DataContext = null;
- tv.DataContext = cutvm;
- numAnnot++;
+ if (cutvm!=null)
+ {
+ 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)));
+ tv.DataContext = null;
+ tv.DataContext = cutvm;
+ }
}
}