src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
changeset 169 3a407c966e57
parent 168 d70ee2002f75
parent 167 206f07a8d887
child 186 83615722dbab
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Sun Oct 25 12:38:45 2009 +0100
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Sun Oct 25 12:55:07 2009 +0100
@@ -40,7 +40,7 @@
         private double totalmilliseconds;
         
         private List<Annotation> AnnotList = new List<Annotation>();
-        private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item
+        private float AnnotWidth = 850 + 15; // The surfaceListBox adds 15 pixels between each item
         private CuttingViewModel CuttingVM;
         private Boolean AnnotWaiting = false;
         private float AnnotTcBegin;
@@ -117,8 +117,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);
 
@@ -131,9 +130,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.RenderTransform = new ScaleTransform(futurScale,1);
+            tv.ScaleX = (this.ActualWidth-30) / (totalmilliseconds / 1000);
             //tv.Width = this.ActualWidth - 30;
             
         }
@@ -286,7 +283,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;
@@ -320,7 +317,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;
@@ -347,16 +344,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)
@@ -388,8 +385,11 @@
             };
 
             // We apply the current scale to the dragged annotation
-            ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform;
-
+            ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup();
+            ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform);
+            // 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)
             //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged);
 
@@ -448,7 +448,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