--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Nov 06 17:50:40 2009 +0100
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Mon Nov 09 12:11:42 2009 +0100
@@ -39,9 +39,8 @@
private double totalmilliseconds;
- private List<Annotation> AnnotList = new List<Annotation>();
private float AnnotWidth = 850 + 15; // The surfaceListBox adds 15 pixels between each item
- private CuttingViewModel CuttingVM;
+ private Cutting cut;
private Boolean AnnotWaiting = false;
private float AnnotTcBegin;
private Color CurrentColor;
@@ -136,24 +135,24 @@
}
#region Timer
- public void initTimer(Color col, CuttingViewModel cutVMPar)
+ public void initTimer(Color col, Cutting cutPar)
{
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
timer.Tick += new EventHandler(timer_Tick);
CurrentColor = col;
-
+
// DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project)
- AnnotList = new List<Annotation>();
- AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor));
- //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2"));
- //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3"));
- //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
- //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5"));
- CuttingVM = new CuttingViewModel(new Cutting(cutVMPar.Title, AnnotList), AnnotWidth);
- cutVMPar = CuttingVM;
- tv.DataContext = CuttingVM;
+ cut = cutPar;
+ cut.AnnotList = new List<Annotation>();
+ cut.AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor));
+ //cut.AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2"));
+ //cut.AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3"));
+ //cut.AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4"));
+ //cut.AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5"));
+ //cut.AnnotList = AnnotList;
+ tv.DataContext = new CuttingViewModel(cut, AnnotWidth);
}
@@ -229,9 +228,9 @@
{
Boolean annotOk = true;
// We check if the annotation's begin and end timecodes allow a new annotation creation
- if (CuttingVM != null && AnnotWaiting == false)
+ if (cut != null && AnnotWaiting == false)
{
- foreach (Annotation a in AnnotList)
+ foreach (Annotation a in cut.AnnotList)
{
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
// Check begin TC
@@ -261,9 +260,9 @@
//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)
+ if (cut != null && AnnotWaiting == false)
{
- foreach (Annotation a in AnnotList)
+ foreach (Annotation a in cut.AnnotList)
{
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
// Check begin TC
@@ -282,10 +281,8 @@
// If everything's fine, we create the new one
if (annotOk == true)
{
- AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
- CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
- tv.DataContext = null;
- tv.DataContext = CuttingVM;
+ cut.AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
+ tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
AnnotWaiting = false;
}
@@ -300,12 +297,12 @@
{
Boolean annotOk = true;
// We open a new annotation
- if (CuttingVM != null && AnnotWaiting == false)
+ if (cut != null && AnnotWaiting == false)
{
AnnotTcBegin = (float)slider.Value / 1000;
// First we check if the new annotation will not cover any
- foreach (Annotation a in AnnotList)
+ foreach (Annotation a in cut.AnnotList)
{
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur));
if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur))
@@ -316,22 +313,20 @@
// if not, we mark the beginning
if (annotOk == true)
{
- AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor));
- CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
- tv.DataContext = null;
- tv.DataContext = CuttingVM;
+ cut.AnnotList.Add(new Annotation(AnnotTcBegin, 0, cut.AnnotList.Count.ToString(), CurrentColor));
+ tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
AnnotWaiting = true;
}
}
// We close the current opened annotation...
- else if (CuttingVM != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin))
+ else if (cut != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin))
{
// ... by setting setting the good beginning and the good duration
float currentTC = (float)slider.Value / 1000;
float currentDuration = currentTC - AnnotTcBegin;
// First we check if the new annotation will not cover any (AnnotTcBegin was already checked)
- foreach (Annotation a in AnnotList)
+ foreach (Annotation a in cut.AnnotList)
{
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC))
@@ -342,12 +337,10 @@
if (annotOk == true)
{
- AnnotList.RemoveAt(AnnotList.Count - 1);
- AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor));
- CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
- //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
- tv.DataContext = null;
- tv.DataContext = CuttingVM;
+ cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1);
+ cut.AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, cut.AnnotList.Count.ToString(), CurrentColor));
+ //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth)));
+ tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
AnnotWaiting = false;
}
//Raise Event to display Annotation in all Openned UserPanels
@@ -427,7 +420,7 @@
private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e)
{
// We check if the annotation is well one of the current annotations
- if (CuttingVM != null)
+ if (cut != null)
{
// e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
@@ -438,20 +431,20 @@
private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e)
{
// We check if the annotation is well one of the current annotations
- if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true)
+ if (cut != null && canceledAnnotationVM != null && e.Confirmed == true)
{
- foreach (Annotation a in AnnotList)
+ foreach (Annotation a in cut.AnnotList)
{
// Check begin TcBegin, duration and gesture type
if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType)
{
// We found the good annotation so we can remove it
- AnnotList.Remove(a);
+ cut.AnnotList.Remove(a);
// We redisplay the timeline
- CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
+ //CuttingVM.setListFromAnnotations(cut.AnnotList, AnnotWidth, tv.ScaleX);
tv.DataContext = null;
- tv.DataContext = CuttingVM;
- // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified
+ tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
+ // We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified
confirmCancelPopup.Visibility = Visibility.Hidden;
canceledAnnotationVM = null;
return;