# HG changeset patch # User cavaliet # Date 1256215723 -7200 # Node ID 206f07a8d887c6ba7ea70c2ab5765b010285039a # Parent 33c2e634df130d606af7b1d5d57321d581efbe95 Annotation's scale is now still visually at one, whatever the timeline's scale. diff -r 33c2e634df13 -r 206f07a8d887 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- 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 diff -r 33c2e634df13 -r 206f07a8d887 src/FingersDance.ViewModel/AnnotationViewModel.cs --- a/src/FingersDance.ViewModel/AnnotationViewModel.cs Wed Oct 21 16:28:49 2009 +0200 +++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs Thu Oct 22 14:48:43 2009 +0200 @@ -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 33c2e634df13 -r 206f07a8d887 src/FingersDance.ViewModel/CuttingViewModel.cs --- a/src/FingersDance.ViewModel/CuttingViewModel.cs Wed Oct 21 16:28:49 2009 +0200 +++ b/src/FingersDance.ViewModel/CuttingViewModel.cs Thu Oct 22 14:48:43 2009 +0200 @@ -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 33c2e634df13 -r 206f07a8d887 src/FingersDance.Views/TimelineAnnotationView.xaml --- a/src/FingersDance.Views/TimelineAnnotationView.xaml Wed Oct 21 16:28:49 2009 +0200 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml Thu Oct 22 14:48:43 2009 +0200 @@ -7,7 +7,7 @@ mc:Ignorable="d" x:Class="FingersDance.Views.TimelineAnnotationView" xmlns:vw="clr-namespace:FingersDance.Views" - x:Name="UserControl" + x:Name="myTAV" d:DesignWidth="640" d:DesignHeight="480" Width="850" Height="40"> @@ -18,10 +18,29 @@ > - - - - + + + + + + + + + + + + + + + + + + + + diff -r 33c2e634df13 -r 206f07a8d887 src/FingersDance.Views/TimelineAnnotationView.xaml.cs --- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Wed Oct 21 16:28:49 2009 +0200 +++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Thu Oct 22 14:48:43 2009 +0200 @@ -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 33c2e634df13 -r 206f07a8d887 src/FingersDance.Views/TimelineView.xaml.cs --- a/src/FingersDance.Views/TimelineView.xaml.cs Wed Oct 21 16:28:49 2009 +0200 +++ b/src/FingersDance.Views/TimelineView.xaml.cs Thu Oct 22 14:48:43 2009 +0200 @@ -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; + } + } + } - } }