src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
changeset 160 e940ca798fe3
parent 150 569925b65604
child 162 0b9f989bcb37
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Oct 16 09:02:04 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Oct 16 15:56:09 2009 +0200
@@ -35,13 +35,13 @@
         public event EventHandler TimerTick;
 
         private double totalmilliseconds;
-
+        
         private List<Annotation> AnnotList = new List<Annotation>();
         private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item
         private CuttingViewModel CuttingVM;
         private Boolean AnnotWaiting = false;
         private float AnnotTcBegin;
-        private UInt32 IntColor;
+        private Color CurrentColor;
 
         private AnnotationViewModel canceledAnnotationVM;
 
@@ -114,16 +114,6 @@
             // 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", IntColor));
-            //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"));
-            Cutting cut = new Cutting("titre de cutting", AnnotList);
-            CuttingVM = new CuttingViewModel(cut, AnnotWidth);
-            tv.DataContext = CuttingVM;
 
             tv.listview.PreviewContactDown += listview_PreviewContactDown;
             SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled);
@@ -131,7 +121,6 @@
             UserControlTimeLine_SizeChanged(null, null);
 
             slider_ContactTapGesture(this, null);
-            
 
         }
 
@@ -141,18 +130,30 @@
             Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000);
             //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS
             tv.RenderTransform = new ScaleTransform(futurScale,1);
-            //Console.WriteLine("futurScale = " + futurScale);
+            //tv.Width = this.ActualWidth - 30;
             
         }
 
         #region Timer
-        public void initTimer(UInt32 intColorPar)
+        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);
 
-            IntColor = intColorPar;
+            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"));
+            cutPar = new Cutting("titre de cutting", AnnotList);
+            CuttingVM = new CuttingViewModel(cutPar, AnnotWidth);
+            tv.DataContext = CuttingVM;
+
         }
 
         public void timerStart()
@@ -185,6 +186,7 @@
 
         #endregion
 
+        #region SliderDrag
         private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e)
         {
             isDragging = true;
@@ -212,6 +214,7 @@
         {
             //startOrEndAnnotation();
         }
+        #endregion
 
         public Boolean isAnnotationAccepted(AnnotationViewModel avm)
         {
@@ -301,9 +304,8 @@
                 // if not, we mark the beginning
                 if (annotOk == true)
                 {
-                    AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), IntColor));
+                    AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor));
                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
-                    //Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
                     tv.DataContext = null;
                     tv.DataContext = CuttingVM;
                     AnnotWaiting = true;
@@ -329,7 +331,7 @@
                 if (annotOk == true)
                 {
                     AnnotList.RemoveAt(AnnotList.Count - 1);
-                    AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), IntColor));
+                    AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor));
                     CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth)));
                     tv.DataContext = null;
@@ -339,7 +341,6 @@
             }
         }
 
-
         private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
             FrameworkElement findSource = e.OriginalSource as FrameworkElement;
@@ -407,7 +408,6 @@
 
         private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e)
         {
-            Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content);
             // We check if the annotation is well one of the current annotations
             if (CuttingVM != null)
             {
@@ -419,7 +419,6 @@
 
         private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e)
         {
-            //Consolenfirm = " + e.Confirmed);
             // We check if the annotation is well one of the current annotations
             if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true)
             {