Gesture
authorPAMPHILE Jonathan <pamphile@efrei.fr>
Thu, 12 Nov 2009 23:50:31 +0100
changeset 193 96374d03e714
parent 192 11083c390ce4
child 194 d96cd2bce653
Gesture
src/FingersDance.Control.Player/UserControlPlayer.xaml
src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.GestureControl/Gesture.cs
src/FingersDance.GestureControl/GestureControl.cs
src/FingersDance.GestureControl/GestureControl.csproj
src/FingersDance.GestureControl/GestureRoutedEventArgs.cs
src/FingersDance.GestureControl/Themes/Generic.xaml
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml	Thu Nov 12 23:50:31 2009 +0100
@@ -177,21 +177,13 @@
     			</Grid.ColumnDefinitions>
     			<FingersDance_Control_Player:UserControlInfoUser Margin="0,-0.498,0,11.298" x:Name="usercontrolInfoUser" Grid.ColumnSpan="1" Grid.Row="2" Height="30"/>
     			<MediaElement x:Name="MediaElementVideo" MediaOpened="MediaElementVideo_MediaOpened" Stretch="Fill" ScrubbingEnabled="False" StretchDirection="Both" Grid.RowSpan="2" />
-    			<Custom:SurfaceButton x:Name="Rewind_area" Content="" ContactDown="ButtonRewind_ContactDown" 
-                                      Click="ButtonRewind_Click" Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" 
-                                      Opacity="0" Style="{DynamicResource FingersDance.Control.PlayerButton}" HorizontalAlignment="Left" Width="72" Grid.RowSpan="1"/>
-    			<Custom:SurfaceButton x:Name="Fast_Forward_area" Content="" ContactDown="ButtonFastForward_ContactDown" Click="ButtonFastForward_Click" 
-                                      Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" Opacity="0" 
-                                      Style="{DynamicResource FingersDance.Control.PlayerButton}" HorizontalAlignment="Right" Width="72" Grid.RowSpan="1"/>
-    			<Custom:SurfaceButton x:Name="Play_Pause_area" ContactDown="ButtonPlayPause_ContactDown" Click="ButtonPlayPause_Click" Foreground="{x:Null}" 
-                                      Background="#FFFFFFFF" BorderBrush="{x:Null}" Style="{DynamicResource FingersDance.Control.PlayerButton}" Opacity="0" Margin="72,0,72,0" Grid.RowSpan="1"/>
     			<StackPanel Opacity="1" Background="{x:Null}" x:Name="StackPanelAnnotation" Height="Auto" d:LayoutOverrides="Height" Margin="-1,77.8,0,0" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2">
     				<Rectangle x:Name="rect1" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
     				<Rectangle x:Name="rect2" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
     				<Rectangle x:Name="rect3" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
     				<Rectangle x:Name="rect4" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000" VerticalAlignment="Bottom"/>
     			</StackPanel>
-    			<GestureControl:GestureControl HorizontalAlignment="Stretch" x:Name="gestureControl" VerticalAlignment="Stretch" Content="" Grid.Row="1" GestureEvent="GestureDetected"/>
+                <GestureControl:GestureControl HorizontalAlignment="Stretch" x:Name="gestureControl" VerticalAlignment="Stretch" Content="" Grid.Row="1" GestureEvent="GestureDetected"/>
     		</Grid>
     	</Viewbox>
     </Grid>
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Thu Nov 12 23:50:31 2009 +0100
@@ -32,6 +32,12 @@
         public event EventHandler PlayerOpened;
         public event EventHandler PlayerStopOrPause;
 
+        public double Time
+        {
+            get { return gestureControl.time; }
+            set { gestureControl.time = value; }
+        }
+
         #region constructors
         public UserControlPlayer()
         {
@@ -118,8 +124,15 @@
 
         public void GestureDetected(object sender, GestureControl.GestureRoutedEventArgs e)
         {
-            Console.WriteLine("gesture detected: " + e.Gesture);
-            switch (e.Gesture)
+
+            /*
+             *  e.Gesture.Name = Nom de la gesture
+             *  e.Gesture.Start = Valeur de la timeline au début de l'annotation
+             *  e.Gesture.End = Valeur de la timeline à la fin de l'annotation
+             * 
+             */
+
+            switch (e.Gesture.Name)
             {
                 case "TRIGGER":
                     
@@ -178,7 +191,6 @@
                     ButtonPlayPause_ContactDown(null, null);
                     break;
                 default:
-                    //this.TxtGesture.Text = e.Gesture;
                     break;
             }
         }
@@ -212,6 +224,8 @@
 
         }
 
+        /*
+        
         private void ButtonPlayPause_Click(object sender, RoutedEventArgs e)
         {
             if (!isPlaying)//Play
@@ -278,6 +292,8 @@
                 MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5));
             }
         }
+        
+        */
 
         #endregion
 
@@ -308,20 +324,20 @@
             {
                 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
                 AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
-                Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
+                //Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red);
             }
             else
             {
-                Play_Pause_area.Background = new SolidColorBrush(Colors.White);
+                //Play_Pause_area.Background = new SolidColorBrush(Colors.White);
             }
-            Play_Pause_area.Opacity = 0.3;
+            //Play_Pause_area.Opacity = 0.3;
 
         }
 
         private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
         {
             //Console.WriteLine("Leave");
-            Play_Pause_area.Opacity = 0;
+            //Play_Pause_area.Opacity = 0;
         }
 
         private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
@@ -332,7 +348,7 @@
         private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
         {
             //Console.WriteLine("Drop");
-            Play_Pause_area.Opacity = 0;
+            //Play_Pause_area.Opacity = 0;
             // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
             AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
             int nbSeconds = (int)annotationDataVM.TcBegin;
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Thu Nov 12 23:50:31 2009 +0100
@@ -112,6 +112,7 @@
 
                 UserControlPlayer.Player.Position = ts;
                 UserControlPlayer.playerPlay();
+                UserControlPlayer.Time = SliderValue;
 
                 UCTimeLine.IsDragging = false;
                 UCTimeLine.FinishedDragging = false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.GestureControl/Gesture.cs	Thu Nov 12 23:50:31 2009 +0100
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace GestureControl
+{
+    public class Gesture
+    {
+        public string Name { get; set; }
+        public double Start { get; set; }
+        public double End { get; set; }
+    }
+}
--- a/src/FingersDance.GestureControl/GestureControl.cs	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.GestureControl/GestureControl.cs	Thu Nov 12 23:50:31 2009 +0100
@@ -27,6 +27,8 @@
 {
     public class GestureControl : ContentControl
     {
+        public double time;
+        double start = -1;
         private double angle = 0;
         public static readonly DependencyProperty GestureProperty;
         Thread inProgess;
@@ -55,9 +57,9 @@
             remove { RemoveHandler(gestureEvent, value); }
         }
 
-        public delegate void RaiseGestureEventCallBack(string gesture);
+        public delegate void RaiseGestureEventCallBack(Gesture gesture);
 
-        public void RaiseGestureEvent(string gesture)
+        public void RaiseGestureEvent(Gesture gesture)
         {
             if (this.Dispatcher.CheckAccess())
             {
@@ -104,6 +106,8 @@
         // get angle from the first contact of the stroke
         protected void AreaDown(object source, RoutedEventArgs e)
         {
+            if (start == -1)
+                start = time;
             ContactEventArgs c = (ContactEventArgs)e;
             this.angle = c.Contact.GetOrientation(this) - 270;
         }
@@ -147,6 +151,7 @@
             catch { }
         }
 
+        
         void RunCapture()
         {
             try
@@ -156,9 +161,10 @@
                 string gesture = GetPattern(_Gestures);
                 if (gesture != "None")
                 {
-                    this.RaiseGestureEvent(gesture);
+                    this.RaiseGestureEvent(new Gesture{Start=start, End=time, Name=gesture});
                 }
                 _Gestures.Clear();
+                start = -1;
                 inProgess = null;
             }
             catch (Exception)
--- a/src/FingersDance.GestureControl/GestureControl.csproj	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.GestureControl/GestureControl.csproj	Thu Nov 12 23:50:31 2009 +0100
@@ -82,6 +82,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="DoubleHalfConverter.cs" />
+    <Compile Include="Gesture.cs" />
     <Compile Include="GestureRoutedEventArgs.cs" />
     <Compile Include="GestureVector.cs" />
     <Compile Include="Properties\AssemblyInfo.cs">
--- a/src/FingersDance.GestureControl/GestureRoutedEventArgs.cs	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.GestureControl/GestureRoutedEventArgs.cs	Thu Nov 12 23:50:31 2009 +0100
@@ -12,13 +12,13 @@
     /// </summary>
     public class GestureRoutedEventArgs : RoutedEventArgs
     {
-        public String Gesture { get; private set; }
+        public Gesture Gesture { get; private set; }
 
         public GestureRoutedEventArgs() : base() { }
-        public GestureRoutedEventArgs(String gesture) : base() { this.Gesture = gesture; }
+        public GestureRoutedEventArgs(Gesture gesture) : base() { this.Gesture = gesture; }
         public GestureRoutedEventArgs(RoutedEvent routedEvent) : base(routedEvent) { }
-        public GestureRoutedEventArgs(RoutedEvent routedEvent, String gesture) : base(routedEvent) { this.Gesture = gesture; }
+        public GestureRoutedEventArgs(RoutedEvent routedEvent, Gesture gesture) : base(routedEvent) { this.Gesture = gesture; }
         public GestureRoutedEventArgs(RoutedEvent routedEvent, Object source) : base(routedEvent, source) { }
-        public GestureRoutedEventArgs(RoutedEvent routedEvent, Object source, String gesture) : base(routedEvent, source) { this.Gesture = gesture; }
+        public GestureRoutedEventArgs(RoutedEvent routedEvent, Object source, Gesture gesture) : base(routedEvent, source) { this.Gesture = gesture; }
     }
 }
--- a/src/FingersDance.GestureControl/Themes/Generic.xaml	Thu Nov 12 16:15:19 2009 +0100
+++ b/src/FingersDance.GestureControl/Themes/Generic.xaml	Thu Nov 12 23:50:31 2009 +0100
@@ -18,8 +18,8 @@
                         <Grid>
                             <ContentControl x:Name="CC" BorderBrush="red" BorderThickness="3" Content="{TemplateBinding Content}"></ContentControl>
                            <s:SurfaceInkCanvas Width="{Binding ElementName=CC,Path=ActualWidth,Converter={StaticResource DoubleHalfConverter}}" Height="{Binding ElementName=CC,Path=ActualHeight,Converter={StaticResource DoubleHalfConverter}}" x:Name="InkArea">
-                                <s:SurfaceInkCanvas.DefaultDrawingAttributes >
-                                    <DrawingAttributes 
+                                <s:SurfaceInkCanvas.DefaultDrawingAttributes>
+                                    <DrawingAttributes
                                     Color = "Blue" Width = "4" />
                                 </s:SurfaceInkCanvas.DefaultDrawingAttributes>
                             </s:SurfaceInkCanvas>