src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
changeset 167 206f07a8d887
parent 166 33c2e634df13
child 169 3a407c966e57
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Oct 21 16:28:49 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Thu Oct 22 14:48:43 2009 +0200
@@ -116,8 +116,7 @@
             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);
-
-
+            
             tv.listview.PreviewContactDown += listview_PreviewContactDown;
             SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled);
 
@@ -130,9 +129,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-30) / (totalmilliseconds / 1000);
-            //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS
-            tv.listview.RenderTransform = new ScaleTransform(futurScale,1);
+            tv.ScaleX = (this.ActualWidth-30) / (totalmilliseconds / 1000);
             //tv.Width = this.ActualWidth - 30;
             
         }
@@ -277,7 +274,7 @@
                 if (annotOk == true)
                 {
                     AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
                     tv.DataContext = null;
                     tv.DataContext = CuttingVM;
                     AnnotWaiting = false;
@@ -311,7 +308,7 @@
                 if (annotOk == true)
                 {
                     AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX);
                     tv.DataContext = null;
                     tv.DataContext = CuttingVM;
                     AnnotWaiting = true;
@@ -338,16 +335,16 @@
                 {
                     AnnotList.RemoveAt(AnnotList.Count - 1);
                     AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor));
-                    CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+                    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;
                     AnnotWaiting = false;
                 }
+                //Raise Event to display Annotation in all Openned UserPanels
+                if (annotOk)
+                    OnSuccessAnnotation(this, new EventArgs());
             }
-            //Raise Event to display Annotation in all Openned UserPanels
-            if(annotOk)
-                OnSuccessAnnotation(this, new EventArgs());
         }
 
         private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
@@ -381,7 +378,7 @@
             // We apply the current scale to the dragged annotation
             ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup();
             ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform);
-            // We apply a translate translate transform to place correctly the dragged annotation
+            // We apply a translate transform to place correctly the dragged annotation
             ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(new TranslateTransform((AnnotWidth / 2) * (1 - ((ScaleTransform)tv.listview.RenderTransform).ScaleX), 0));
             
             // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE)
@@ -442,7 +439,7 @@
                         // We found the good annotation so we can remove it
                         AnnotList.Remove(a);
                         // We redisplay the timeline
-                        CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+                        CuttingVM.setListFromAnnotations(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