Annotation's scale is now still visually at one, whatever the timeline's scale.
--- 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
--- 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");
+ }
+ }
}
}
--- 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<Annotation> annotList, float annotWidth)
+ public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
{
this._annotList = new List<AnnotationViewModel>();
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++;
}
--- 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">
<UserControl.Resources>
<vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"/>
@@ -18,10 +18,29 @@
>
<Grid>
<Rectangle Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="40" Opacity="0.0"/>
- <TextBox HorizontalAlignment="Left" Text="{Binding Path=GestureType}" Width="40" Margin="0,20,0,0" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}"/>
- <Ellipse Stroke="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Fill="{x:Null}" Margin="-3,16,0,0" Height="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="8"/>
- <Ellipse Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Margin="-2,17,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left" Width="6" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}" />
- <Rectangle Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="17"/>
+ <TextBox HorizontalAlignment="Left" Text="{Binding Path=GestureType}" Width="40" Margin="0,20,0,0" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}">
+ <TextBox.RenderTransform>
+ <ScaleTransform ScaleX="{Binding Path=ScaleX}"/>
+ </TextBox.RenderTransform>
+ </TextBox>
+ <Ellipse Stroke="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Fill="{x:Null}" Margin="-3,16,0,0" Height="8" VerticalAlignment="Top"
+ HorizontalAlignment="Left" Width="8" RenderTransformOrigin="0.5,0.5">
+ <Ellipse.RenderTransform>
+ <ScaleTransform ScaleX="{Binding Path=ScaleX}"/>
+ </Ellipse.RenderTransform>
+ </Ellipse>
+ <Ellipse Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" Margin="-2,17,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left"
+ Width="6" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}" RenderTransformOrigin="0.5,0.5" >
+ <Ellipse.RenderTransform>
+ <ScaleTransform ScaleX="{Binding Path=ScaleX}"/>
+ </Ellipse.RenderTransform>
+ </Ellipse>
+ <Rectangle Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="17"
+ RenderTransformOrigin="0.5,0.5">
+ <Rectangle.RenderTransform>
+ <ScaleTransform ScaleX="{Binding Path=ScaleX}"/>
+ </Rectangle.RenderTransform>
+ </Rectangle>
<Rectangle Fill="{Binding Path=Color, Converter={StaticResource myColorConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="2"/>
</Grid>
</Custom:SurfaceUserControl>
--- 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 @@
/// </summary>
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
--- 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;
+ }
+ }
+ }
-
}
}