# HG changeset patch # User ARIAS Santiago # Date 1256471707 -3600 # Node ID 3a407c966e577261f7c344fe60e5c408dc30a4dc # Parent d70ee2002f756c6487c51c5f29f4e8a685286558# Parent 206f07a8d887c6ba7ea70c2ab5765b010285039a Merge Timeline actions diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- 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 AnnotList = new List(); - 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 diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.ViewModel/AnnotationViewModel.cs --- a/src/FingersDance.ViewModel/AnnotationViewModel.cs Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs Sun Oct 25 12:55:07 2009 +0100 @@ -16,7 +16,18 @@ private Color _color; private float _marginLeft; + private Double _scaleX = 1; + public AnnotationViewModel(Annotation a, float marginLeft, Double scaleX) + { + this._tcBegin = a.TcBegin; + this._dur = a.Dur; + this._gestureType = a.GestureType; + this._color = a.Color; + this._marginLeft = marginLeft; + this._marginLeft = marginLeft; + this._scaleX = scaleX; + } public AnnotationViewModel(Annotation a, float marginLeft) { this._tcBegin = a.TcBegin; @@ -80,6 +91,17 @@ base.OnPropertyChanged("MarginLeft"); } } + public Double ScaleX + { + get { return _scaleX; } + set + { + if (value == _scaleX || Double.IsNaN(value)) + return; + _scaleX = value; + base.OnPropertyChanged("ScaleX"); + } + } } } diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.ViewModel/CuttingViewModel.cs --- a/src/FingersDance.ViewModel/CuttingViewModel.cs Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.ViewModel/CuttingViewModel.cs Sun Oct 25 12:55:07 2009 +0100 @@ -46,14 +46,14 @@ } } - public void setListFromAnnotations(List annotList, float annotWidth) + public void setListFromAnnotations(List annotList, float annotWidth, Double scaleX) { this._annotList = new List(); int i = 0; foreach (Annotation annot in annotList) { - this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth))); + this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1/scaleX)); i++; } diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.Views/TimelineAnnotationView.xaml --- a/src/FingersDance.Views/TimelineAnnotationView.xaml Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml Sun Oct 25 12:55:07 2009 +0100 @@ -7,8 +7,8 @@ mc:Ignorable="d" x:Class="FingersDance.Views.TimelineAnnotationView" xmlns:vw="clr-namespace:FingersDance.Views" - x:Name="UserControl" - d:DesignWidth="640" d:DesignHeight="480" Width="300" Height="40"> + x:Name="myTAV" + d:DesignWidth="640" d:DesignHeight="480" Width="850" Height="40"> @@ -18,10 +18,29 @@ > - - - - + + + + + + + + + + + + + + + + + + + + diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.Views/TimelineAnnotationView.xaml.cs --- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Sun Oct 25 12:55:07 2009 +0100 @@ -20,10 +20,19 @@ /// public partial class TimelineAnnotationView : UserControl { + + public static readonly DependencyProperty ScaleXProperty = DependencyProperty.Register("ScaleX", typeof(Double), typeof(TimelineAnnotationView)); + public TimelineAnnotationView() { InitializeComponent(); } + + public Double ScaleX + { + get { return (Double)GetValue(ScaleXProperty); } + set { SetValue(ScaleXProperty, value); } + } } public class ThicknessSingleValueConverter : IValueConverter diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.Views/TimelineView.xaml --- a/src/FingersDance.Views/TimelineView.xaml Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.Views/TimelineView.xaml Sun Oct 25 12:55:07 2009 +0100 @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vw="clr-namespace:FingersDance.Views" - xmlns:Custom="http://schemas.microsoft.com/surface/2008"> + xmlns:Custom="http://schemas.microsoft.com/surface/2008" + Width="1700" > diff -r d70ee2002f75 -r 3a407c966e57 src/FingersDance.Views/TimelineView.xaml.cs --- a/src/FingersDance.Views/TimelineView.xaml.cs Sun Oct 25 12:38:45 2009 +0100 +++ b/src/FingersDance.Views/TimelineView.xaml.cs Sun Oct 25 12:55:07 2009 +0100 @@ -28,7 +28,20 @@ InitializeComponent(); } + public Double ScaleX + { + get { return ((ScaleTransform)listview.RenderTransform).ScaleX; } + set{ + // We set the scale to the list view + listview.RenderTransform = new ScaleTransform(value, 1); + // We inform each annotation that scale has been changed + foreach (AnnotationViewModel a in listview.Items) + { + //Console.WriteLine("a = " + a); + a.ScaleX = 1 / value; + } + } + } - } }