--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Thu Nov 19 18:05:52 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Fri Nov 20 17:14:52 2009 +0100
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Windows;
@@ -7,8 +8,10 @@
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
+
using FingersDance.Control.TimeLine;
using FingersDance.Data;
+using FingersDance.ViewModels;
using FingersDance.Factory;
using GestureControl;
@@ -17,7 +20,10 @@
public partial class UserControlSyncSource
{
#region Variables
- public event EventHandler OnSuccessAnnotation;
+ public event EventHandler OnSuccessAnnotation;
+
+ private String AnnotationOrSearchMode;
+ private Project searchedProject;
#endregion
public UserControlSyncSource()
@@ -27,17 +33,20 @@
// Insert code required on object creation below this point.
}
- public void Load(string path, Color col, Cutting cut)
+ public void Load(string path, Color col, Cutting cut, String AnnotOrSearchMode, Project searchedProj)
{
this.UserControlPlayer.initPlayer(path);
+ AnnotationOrSearchMode = AnnotOrSearchMode;
+ searchedProject = searchedProj;
//Initialisation du Timer
UCTimeLine.initTimer(col, cut);
- this.UserControlPlayer.playerPlay();
- this.userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
- this.userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
- this.userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved);
- this.UserControlPlayer.PlayerStopOrPause += new EventHandler(UserControlPlayer_PlayerStopOrPause);
- UserControlPlayer.NewGestureRegognized += new EventHandler(UCTimeLine.UserControlPlayer_NewGestureRegognized);
+ UserControlPlayer.playerPlay();
+ userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
+ userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
+ userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved);
+ UserControlPlayer.PlayerStopOrPause += new EventHandler(UserControlPlayer_PlayerStopOrPause);
+ UserControlPlayer.NewGestureRegognized += new EventHandler(UserControlPlayer_NewGestureRegognized);
+ UCTimeLine.NewGestureRecognized += new EventHandler<NewGestureRecognizedEventArg>(UCTimeLine_NewGestureRecognized);
}
void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e)
@@ -151,5 +160,68 @@
{
UserControlPlayer.playerPause();
}
+
+
+ public void UserControlPlayer_NewGestureRegognized(object sender, EventArgs e)
+ {
+ try
+ {
+ GestureEventArg grea = (GestureEventArg)e;
+ //Console.WriteLine("Timeline NewGestureRegognized " + grea.Gesture.Name + ", " + grea.Gesture.Start + ", " + grea.Gesture.End);
+ if (AnnotationOrSearchMode == "Annotation")
+ {
+ // If the stroke has been drawed very fast, end and start can be the same, so we add a little length.
+ float dur = (float)(grea.End - grea.Start);
+ if (dur == 0) dur = (float)0.5;
+ foreach (Gesture elt in grea.Gestures)
+ UCTimeLine.addAnnotation((float)grea.Start, dur, elt.Name);
+ }
+ else
+ {
+ // We are in search mode. So we have to get all the searchedProject's annotation which have the wanted gesture
+ List<Annotation> searchedAnnot = new List<Annotation>();
+ foreach(Cutting cut in searchedProject.Cuttings)
+ {
+ foreach (Annotation annot in cut.AnnotList)
+ {
+ foreach(Gesture gest in grea.Gestures)
+ if (annot.GestureType == gest.Name)
+ {
+ // One of the gesture is enough for the annotation to be added
+ searchedAnnot.Add(annot);
+ break;
+ }
+ }
+ }
+ // The list was built. If the number of found annotations is >0, we send the list to the timeline
+ UCTimeLine.updateAnnotationList(searchedAnnot);
+ }
+ }
+ catch { }
+ }
+
+ public void searchAnnotations(String gestureName)
+ {
+ // We are in search mode. So we have to get all the searchedProject's annotation which have the wanted gesture
+ List<Annotation> searchedAnnot = new List<Annotation>();
+ foreach (Cutting cut in searchedProject.Cuttings)
+ {
+ foreach (Annotation annot in cut.AnnotList)
+ {
+ if (annot.GestureType == gestureName)
+ {
+ // One of the gesture is enough for the annotation to be added
+ searchedAnnot.Add(annot);
+ }
+ }
+ }
+ // The list was built. If the number of found annotations is >0, we send the list to the timeline
+ UCTimeLine.updateAnnotationList(searchedAnnot);
+ }
+
+ void UCTimeLine_NewGestureRecognized(object sender, NewGestureRecognizedEventArg e)
+ {
+ searchAnnotations(e.GestureName);
+ }
}
}
\ No newline at end of file