Now to define an annotation we define its begin then its end.
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Fri Sep 25 18:28:58 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Tue Sep 29 11:08:37 2009 +0200
@@ -780,6 +780,6 @@
<Grid x:Name="LayoutRoot" Width="Auto" Height="Auto" Background="{x:Null}">
<Custom:SurfaceSlider Height="Auto" x:Name="slider" Value="0.5" Width="Auto"
Thumb.DragStarted="sliderPosition_DragStarted" Thumb.DragCompleted="sliderPosition_DragCompleted" ContactTapGesture="slider_ContactTapGesture" Background="#19FFFFFF" Style="{DynamicResource FingersDance.Control.Slider}" />
- <vw:TimelineView x:Name="tv" Margin="0,30,0,0" Width="{Binding Path=ActualWidth, ElementName=slider, Mode=Default}" Background="{x:Null}"/>
+ <vw:TimelineView x:Name="tv" Margin="0,30,0,0" Background="{x:Null}"/>
</Grid>
</UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Sep 25 18:28:58 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Tue Sep 29 11:08:37 2009 +0200
@@ -32,9 +32,12 @@
private double totalmilliseconds;
- private List<Annotation> annotList = new List<Annotation>();
- private float annotWidth = 40+1;
- private CuttingViewModel cutvm;
+ private List<Annotation> AnnotList = new List<Annotation>();
+ private float AnnotWidth = 40+1;
+ private CuttingViewModel CuttingVM;
+ private Boolean AnnotWaiting = false;
+ private float AnnotTcBegin;
+ private AnnotationViewModel lastAnnotVM;
#region Properties
@@ -106,31 +109,27 @@
this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged);
// TEMP FOR DATA BINDING
- annotList = new List<Annotation>();
- annotList.Add(new Annotation(0, 10, "Axe Cam 1"));
+ AnnotList = new List<Annotation>();
+ AnnotList.Add(new Annotation(0, 10, "Axe Cam 1"));
//annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2"));
//annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3"));
//annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4"));
//annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5"));
- Cutting cut = new Cutting("titre de cutting", annotList);
- cutvm = new CuttingViewModel(cut);
- tv.DataContext = cutvm;
+ Cutting cut = new Cutting("titre de cutting", AnnotList);
+ CuttingVM = new CuttingViewModel(cut);
+ tv.DataContext = CuttingVM;
slider_ContactTapGesture(this,null);
- /*
- cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6")));
- tv.DataContext = null;
- tv.DataContext = cutvm;
- */
+
}
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 / (totalmilliseconds / 1000);
- //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP
+ //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS
tv.RenderTransform = new ScaleTransform(futurScale,1);
- Console.WriteLine("futurScale = " + futurScale);
+ //Console.WriteLine("futurScale = " + futurScale);
}
@@ -204,13 +203,28 @@
public void addAnnotation()
{
- if (cutvm!=null)
+ // We open a new annotation
+ if (CuttingVM != null && AnnotWaiting == false)
{
- float currentTimecode = (float)slider.Value / 1000;
- cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(currentTimecode - (cutvm.AnnotList.Count * annotWidth), 10, cutvm.AnnotList.Count.ToString())));
- Console.WriteLine("currentTimecode = " + currentTimecode + ", nb = " + cutvm.AnnotList.Count + ", res = " + (currentTimecode - (cutvm.AnnotList.Count * annotWidth)));
+ AnnotTcBegin = (float)slider.Value;
+ lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), 0, CuttingVM.AnnotList.Count.ToString()));
+ CuttingVM.AnnotList.Add(lastAnnotVM);
+ Console.WriteLine("BEGIN currentTimecode = " + (AnnotTcBegin / 1000) + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth)));
tv.DataContext = null;
- tv.DataContext = cutvm;
+ tv.DataContext = CuttingVM;
+ AnnotWaiting = true;
+ }
+ // We close the current opened annotation...
+ else if (CuttingVM != null && AnnotWaiting == true && ((float)slider.Value>AnnotTcBegin))
+ {
+ // ... by setting setting the good beginning and the good duration
+ float currentDuration = ((float)slider.Value - AnnotTcBegin) / 1000;
+ CuttingVM.AnnotList.RemoveAt(CuttingVM.AnnotList.Count - 1);
+ CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), currentDuration, CuttingVM.AnnotList.Count.ToString())));
+ Console.WriteLine("currentTimecode = " + (AnnotTcBegin / 1000) + ", curDur = " + currentDuration + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth)));
+ tv.DataContext = null;
+ tv.DataContext = CuttingVM;
+ AnnotWaiting = false;
}
}
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml Fri Sep 25 18:28:58 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml Tue Sep 29 11:08:37 2009 +0200
@@ -8,14 +8,18 @@
x:Class="FingersDance.Views.TimelineAnnotationView"
xmlns:vw="clr-namespace:FingersDance.Views"
x:Name="UserControl"
- d:DesignWidth="640" d:DesignHeight="480" Width="40">
+ d:DesignWidth="640" d:DesignHeight="480" Width="40" Loaded="UserControl_Loaded">
<UserControl.Resources>
- <vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"></vw:ThicknessSingleValueConverter>
+ <vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"/>
+ <vw:VisibilityConverter x:Name="myVisibilityConverter" x:Key="myVisibilityConverter"/>
</UserControl.Resources>
- <Grid x:Name="LayoutRoot" Margin="{Binding Path=TcBegin, Converter={StaticResource myThicknessSingleValueConverter}}">
- <Ellipse Fill="Green" Margin="-2,-3,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left" Width="6" />
- <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="20"/>
- <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="2" Margin="0,18,0,0"/>
- <TextBox HorizontalAlignment="Left" Text="{Binding Path=GestureType}" Width="40" Margin="0,20,0,0"/>
- </Grid>
+ <Custom:SurfaceUserControl x:Name="LayoutRoot" Margin="{Binding Path=TcBegin, Converter={StaticResource myThicknessSingleValueConverter}}">
+ <Grid>
+ <Ellipse Stroke="Green" Fill="{x:Null}" Margin="-3,-4,0,0" Height="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="8"/>
+ <Ellipse Fill="Green" Margin="-2,-3,0,0" Height="6" VerticalAlignment="Top" HorizontalAlignment="Left" Width="6" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}" />
+ <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="2" Height="17" Margin="0,3,0,0"/>
+ <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Path=Dur}" Height="2" Margin="0,18,0,0"/>
+ <TextBox HorizontalAlignment="Left" Text="{Binding Path=GestureType}" Width="40" Margin="0,20,0,0" Visibility="{Binding Path=Dur, Converter={StaticResource myVisibilityConverter}}"/>
+ </Grid>
+ </Custom:SurfaceUserControl>
</UserControl>
\ No newline at end of file
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Fri Sep 25 18:28:58 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs Tue Sep 29 11:08:37 2009 +0200
@@ -23,6 +23,11 @@
{
InitializeComponent();
}
+
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+
+ }
}
public class ThicknessSingleValueConverter : IValueConverter
@@ -41,4 +46,17 @@
return thickness.Left;
}
}
+
+ public class VisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ Visibility v = ((float)value>0) ? Visibility.Visible : Visibility.Hidden;
+ return v;
+ }
+ public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return 1.0;
+ }
+ }
}