First step of data binding where we can add an annotation by clicking on the timeline
authorcavaliet
Thu, 17 Sep 2009 13:06:22 +0200
changeset 74 7ce946833eae
parent 71 31900a35e162
child 75 99d003723474
First step of data binding where we can add an annotation by clicking on the timeline
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Views/TimelineAnnotationView.xaml
src/FingersDance.Views/TimelineAnnotationView.xaml.cs
src/FingersDance.Views/TimelineView.xaml
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml	Thu Sep 17 13:06:22 2009 +0200
@@ -11,7 +11,7 @@
 
     <Grid x:Name="LayoutRoot" Height="{Binding Path=ActualHeight, ElementName=UserControl, Mode=Default}" Width="{Binding Path=ActualWidth, ElementName=UserControl, Mode=Default}">
         <Grid VerticalAlignment="Top" Height="100" x:Name="GridTimeLine">
-        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,-50" x:Name="UserControlTimeLine" DragStarted="UserControlTimeLine_DragStarted" DragCompleted="UserControlTimeLine_DragCompleted" TimerTick="UserControlTimeLine_TimerTick" d:LayoutOverrides="Height" Background="{x:Null}" />
+        	<FingersDance_Control_TimeLine:UserControlTimeLine Margin="40,0,8,0" x:Name="UserControlTimeLine" DragStarted="UserControlTimeLine_DragStarted" DragCompleted="UserControlTimeLine_DragCompleted" TimerTick="UserControlTimeLine_TimerTick" d:LayoutOverrides="Height" Background="{x:Null}" />
         </Grid>
         <Grid HorizontalAlignment="Stretch" Width="Auto" Height="Auto" VerticalAlignment="Stretch" x:Name="GridPlayer" Margin="0,54,0,0">
         	<FingersDance_Control_Player:UserControlPlayer PlayerOpened="UserControlPlayer_PlayerOpened" x:Name="UserControlPlayer" VerticalAlignment="Stretch" d:LayoutOverrides="GridBox" Width="{Binding Path=ActualWidth, ElementName=GridPlayer, Mode=Default}" Margin="0,0,0,0" Height="{Binding Path=ActualHeight, ElementName=GridPlayer, Mode=Default}" />
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml	Thu Sep 17 13:06:22 2009 +0200
@@ -7,10 +7,12 @@
 	x:Class="FingersDance.Control.TimeLine.UserControlTimeLine"
     xmlns:vw="clr-namespace:FingersDance.Views;assembly=FingersDance.Views"
 	x:Name="UserControl"
-	d:DesignWidth="383" xmlns:Custom="http://schemas.microsoft.com/surface/2008" Height="Auto" Background="{x:Null}" d:DesignHeight="33">
+	d:DesignWidth="383" xmlns:Custom="http://schemas.microsoft.com/surface/2008" Background="{x:Null}" d:DesignHeight="33">
 
 	<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" Margin="0,0,30,0" Background="#19FFFFFF" />
-        <vw:TimelineView x:Name="tv" Height="130"/>
+		<Custom:SurfaceSlider  Height="Auto" x:Name="slider" Value="0.5" Width="Auto" 
+                               Thumb.DragStarted="sliderPosition_DragStarted" Thumb.DragCompleted="sliderPosition_DragCompleted" ContactTapGesture="slider_ContactTapGesture"
+                               Margin="0,0,30,0" Background="#19FFFFFF" />
+        <vw:TimelineView x:Name="tv" Margin="0,30,0,0"/>
     </Grid>
 </UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
@@ -30,6 +30,11 @@
         public event EventHandler DragCompleted;
         public event EventHandler TimerTick;
 
+        private List<Annotation> annotList = new List<Annotation>();
+        private float annotWidth = 40;
+        private CuttingViewModel cutvm;
+        private int numAnnot = 1;
+
         #region Properties
 
         public SurfaceSlider Slider
@@ -85,7 +90,7 @@
 
         
 		public UserControlTimeLine()
-		{
+		{   
 			this.InitializeComponent();
 
 			// Insert code required on object creation below this point.
@@ -98,15 +103,24 @@
 
 
             // TEMP FOR DATA BINDING
-            List<Annotation> annotList = new List<Annotation>();
+            annotList = new List<Annotation>();
             annotList.Add(new Annotation(0, 10, "Axe Cam 1"));
-            annotList.Add(new Annotation(10, 20, "Mvt Cam 2"));
-            annotList.Add(new Annotation(30, 40, "Saut 3"));
+            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);
-            CuttingViewModel cutvm = new CuttingViewModel(cut);
-            tv.DataContext = cut;
+            cutvm = new CuttingViewModel(cut);
+            tv.DataContext = cutvm;
 
-
+            numAnnot = 6;
+            slider_ContactTapGesture(this,null);
+            /*
+            cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6")));
+            tv.DataContext = null;
+            tv.DataContext = cutvm;
+            numAnnot = 7;
+            */
         }
 
         #region Timer
@@ -172,5 +186,15 @@
                 DragCompleted(this, new EventArgs());
         }
 
+        private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
+        {
+
+            cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180+(numAnnot-6)*20 - ((numAnnot-1) * annotWidth), 10, numAnnot.ToString())));
+            tv.DataContext = null;
+            tv.DataContext = cutvm;
+            numAnnot++;
+        }
+        
+
 	}
 }
\ No newline at end of file
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml	Thu Sep 17 13:06:22 2009 +0200
@@ -8,12 +8,14 @@
 	x:Class="FingersDance.Views.TimelineAnnotationView"
     xmlns:vw="clr-namespace:FingersDance.Views"
 	x:Name="UserControl"
-	d:DesignWidth="640" d:DesignHeight="480">
+	d:DesignWidth="640" d:DesignHeight="480" Width="40">
     <UserControl.Resources>
         <vw:ThicknessSingleValueConverter x:Name="myThicknessSingleValueConverter" x:Key="myThicknessSingleValueConverter"></vw:ThicknessSingleValueConverter>
     </UserControl.Resources>
     <Grid x:Name="LayoutRoot" Margin="{Binding Path=TcBegin, Converter={StaticResource myThicknessSingleValueConverter}}">
-        <Rectangle Fill="Green" HorizontalAlignment="Left" VerticalAlignment="Top" Width="4" Height="20"/>
-        <TextBox Text="{Binding Path=GestureType}" Width="100" Margin="5,0,0,0"/>
+        <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>
 </UserControl>
\ No newline at end of file
--- a/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Views/TimelineAnnotationView.xaml.cs	Thu Sep 17 13:06:22 2009 +0200
@@ -31,7 +31,8 @@
         {
             ThicknessConverter myThicknessConverter = new ThicknessConverter();
             Thickness th1 = (Thickness)myThicknessConverter.ConvertFrom(value);
-            th1.Top = th1.Top;
+            th1.Top = 0;
+            th1.Bottom = th1.Right = 0;
             return th1;
         }
         public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
--- a/src/FingersDance.Views/TimelineView.xaml	Wed Sep 16 19:32:26 2009 +0200
+++ b/src/FingersDance.Views/TimelineView.xaml	Thu Sep 17 13:06:22 2009 +0200
@@ -2,13 +2,10 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:vw="clr-namespace:FingersDance.Views"
-    Height="300" Width="300">
+    >
     <Grid>
-        <TextBlock Text="{Binding Path=Title}" Height="27" VerticalAlignment="Top" Margin="0,0,132,0" />
-        
-        <ListView Margin="0,25,0,0" 
-                  DataContext="{Binding Path=AnnotList}"
-                  ItemsSource="{Binding}" >
+        <ListView DataContext="{Binding Path=AnnotList}"
+                  ItemsSource="{Binding}" Background="Black" BorderThickness="0" >
 
             <ListView.ItemTemplate>
                 <DataTemplate>
@@ -36,5 +33,6 @@
                 </GridView>
             </ListView.View-->
         </ListView>
+        <!--TextBlock Text="{Binding Path=Title}" Height="27" VerticalAlignment="Top" Margin="0,0,0,0" /-->
     </Grid>
 </UserControl>