# HG changeset patch # User PAMPHILE Jonathan # Date 1258650352 -3600 # Node ID d13dbcf861d74021ce0d139ae774c1d15a9feecb # Parent beebae32b1edf9be2d80afba8d1f04768b7e2027 BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.Player/UserControlPlayer.xaml --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml Thu Nov 19 18:05:52 2009 +0100 @@ -8,7 +8,7 @@ xmlns:FingersDance_Control_Player="clr-namespace:FingersDance.Control.Player" x:Class="FingersDance.Control.Player.UserControlPlayer" x:Name="UserControl" AllowDrop="True" Custom:SurfaceDragDrop.DragOver="Play_Pause_area_DragOver" Custom:SurfaceDragDrop.DragEnter="Play_Pause_area_DragEnter" Custom:SurfaceDragDrop.DragLeave="Play_Pause_area_DragLeave" Custom:SurfaceDragDrop.Drop="Play_Pause_area_Drop" - Width="560" Height="400" + Width="560" Height="423" xmlns:GestureControl="clr-namespace:GestureControl;assembly=GestureControl"> @@ -150,6 +150,334 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -159,26 +487,28 @@ - - - + + + - - + + - - + + - - - + + + - + + + diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Thu Nov 19 18:05:52 2009 +0100 @@ -33,10 +33,18 @@ public event EventHandler PlayerStopOrPause; public event EventHandler NewGestureRegognized; + double _Time = 0; + double _StartAnnotation = -1; + List _Gestures = new List(); + public double Time { get { return gestureControl.time; } - set { gestureControl.time = value; } + set + { + gestureControl.time = value; + _Time = value; + } } #region constructors @@ -49,6 +57,7 @@ //Control User Info usercontrolInfoUser.LabelSession.Content = "Seance Test"; usercontrolInfoUser.LabelUser.Content = "User Test"; + MediaElementVideo.Volume = 0; } #endregion @@ -195,8 +204,7 @@ return; } if (!e.Gesture.Name.Equals("PLAY-PAUSE")) - if (NewGestureRegognized != null) - NewGestureRegognized(this, e); + _Gestures.Add(e.Gesture); } catch { } } @@ -435,5 +443,27 @@ default: break; } } + + private void AnnotationButton_ContactLeave(object sender, ContactEventArgs e) + { + try + { + if (_StartAnnotation == -1) + { + _StartAnnotation = _Time; + AnnotationLabel.Content = "Annotation en cours"; + } + else + { + if (NewGestureRegognized != null) + NewGestureRegognized(null, new GestureEventArg(_Gestures, _StartAnnotation, _Time)); + _Gestures.Clear(); + _StartAnnotation = -1; + AnnotationLabel.Content = ""; + AnnotationButton.IsChecked = false; + } + } + catch { } + } } } \ No newline at end of file diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.Screen/FingersDance.Control.Screen.csproj --- a/src/FingersDance.Control.Screen/FingersDance.Control.Screen.csproj Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.Screen/FingersDance.Control.Screen.csproj Thu Nov 19 18:05:52 2009 +0100 @@ -119,6 +119,10 @@ + + {C7B905EA-0678-4DA0-8EF8-7F9CBD22818E} + FingersDance.Factory + {072436EC-FCD5-4A55-96AA-0047BF25BD37} FingersDance.Control.ListVideo diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.Screen/UserControlScreen.xaml.cs --- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Thu Nov 19 18:05:52 2009 +0100 @@ -13,6 +13,7 @@ using FingersDance.Control.SessionInput; using FingersDance.ViewModels; using FingersDance.Data; +using FingersDance.Factory; namespace FingersDance.Control.Screen { @@ -160,6 +161,7 @@ loadedProject.Description = loadedLdt.Root.Element("project").Attribute("abstract").Value; loadedProject.Cuttings = new List(); XElement cuttingsParentNode = loadedLdt.Root.Element("annotations").Element("content"); + DataDictionary Data = (new DataFactory()).Data; foreach (XElement cuttingNode in cuttingsParentNode.Elements()) { List la = new List(); @@ -174,7 +176,9 @@ Byte g = Convert.ToByte(colorString.Substring(4, 2), 16); Byte b = Convert.ToByte(colorString.Substring(6, 2), 16); Color c = Color.FromRgb(r, g, b); - la.Add(new Annotation(aId, begin, dur, gt, c)); + Annotation Annotation = new Annotation(aId, begin, dur, gt, c); + la.Add(Annotation); + Data.AddAnnotation(Annotation); } loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la)); } diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Thu Nov 19 18:05:52 2009 +0100 @@ -361,15 +361,20 @@ } } - + public void UserControlPlayer_NewGestureRegognized(object sender, EventArgs e) { - GestureRoutedEventArgs grea = (GestureRoutedEventArgs)e; - Console.WriteLine("Timeline NewGestureRegognized " + grea.Gesture.Name + ", " + grea.Gesture.Start + ", " + grea.Gesture.End); - // 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.Gesture.End - grea.Gesture.Start); - if (dur == 0) dur = (float)0.5; - addAnnotation(new AnnotationViewModel(new Annotation("temp",(float)grea.Gesture.Start, (float)(grea.Gesture.End-grea.Gesture.Start), grea.Gesture.Name, CurrentColor), 0)); + try + { + GestureEventArg grea = (GestureEventArg)e; + //Console.WriteLine("Timeline NewGestureRegognized " + grea.Gesture.Name + ", " + grea.Gesture.Start + ", " + grea.Gesture.End); + // 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) + addAnnotation(new AnnotationViewModel(new Annotation("temp", (float)grea.Start, (float)(grea.End - grea.Start), elt.Name, CurrentColor), 0)); + } + catch { } } private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml --- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml Thu Nov 19 18:05:52 2009 +0100 @@ -23,8 +23,8 @@ - - + + \ No newline at end of file diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs --- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Thu Nov 19 18:05:52 2009 +0100 @@ -35,6 +35,8 @@ double lastdeltaOrientation = 0; int lastSoundlevel = 0; bool rise = true; //rise is true if the curse of the volume is positive + int LastElipseNB = 0; + #endregion #region Properties @@ -73,7 +75,7 @@ private void InitializeDefinitions() { - for (byte k = 1; k <= 5; k++) + for (byte k = 1; k <= 25; k++) { ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); // The tag value that this definition will respond to. @@ -107,17 +109,20 @@ TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; deltaOrientation = (tagsoundcontrol.Orientation - baseOrientation) % 360; + if (deltaOrientation < 0) deltaOrientation = 360 + deltaOrientation; int niveau = (int)(deltaOrientation / 36); + + //if (((niveau == 9) || (niveau == 8) || (niveau == 7)) && lastSoundlevel == 0) if (((niveau == 9) || (niveau == 8)) && lastSoundlevel == 0) rise = false; //else if (((niveau == 1) || (niveau == 2) || (niveau == 3)) && lastSoundlevel == 0) else if (((niveau == 1) || (niveau == 2)) && lastSoundlevel == 0) rise = true; - + if (!rise) { niveau = (niveau - 10) % 10; @@ -125,21 +130,30 @@ //--Elipse visibility int elipseNB = tagsoundcontrol.TagVisuSoundLevelUpdate(niveau); //Set the Sound of the Player. - if(elipseNB != -1) + if ((LastElipseNB <1 && deltaOrientation - lastdeltaOrientation < 0) || (LastElipseNB > 9 && deltaOrientation - lastdeltaOrientation > 0)) + baseOrientation += deltaOrientation - lastdeltaOrientation; + else { - UserControlSyncSource.setUserPlayerVolume(elipseNB/10.0); + if (elipseNB != -1) + { + UserControlSyncSource.setUserPlayerVolume(elipseNB / 10.0); + lastSoundlevel = niveau; + LastElipseNB = elipseNB; + tagsoundcontrol.volumeModel.Content = (elipseNB / 10.0).ToString(); + lastdeltaOrientation = deltaOrientation; + } } - lastSoundlevel = niveau; - tagsoundcontrol.volumeModel.Content = elipseNB;//deltaOrientation.ToString(); + } - } private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) { TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; - + LastElipseNB = 5; + lastdeltaOrientation = 0; + switch (tagsoundcontrol.VisualizedTag.Byte.Value) { - case 1: + case 24: try { /* diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.GestureControl/GestureControl.csproj --- a/src/FingersDance.GestureControl/GestureControl.csproj Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.GestureControl/GestureControl.csproj Thu Nov 19 18:05:52 2009 +0100 @@ -83,6 +83,7 @@ + diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.GestureControl/GestureEventArg.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/FingersDance.GestureControl/GestureEventArg.cs Thu Nov 19 18:05:52 2009 +0100 @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GestureControl; +using System.Windows.Input; +using System.Windows; + +namespace GestureControl +{ + public class GestureEventArg : RoutedEventArgs + { + public List Gestures { get; private set; } + public double Start, End; + + public GestureEventArg() : base() { } + public GestureEventArg(List gestures, double start, double end) : base() { this.Gestures = gestures; this.Start = start; this.End = end; } + } +} diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.GestureControl/GestureVector.cs --- a/src/FingersDance.GestureControl/GestureVector.cs Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.GestureControl/GestureVector.cs Thu Nov 19 18:05:52 2009 +0100 @@ -37,7 +37,7 @@ /// public SurfaceGesture(List list, int precision) { - this.Precision = 20; + this.Precision = precision; this.Generate(list); } #endregion @@ -124,590 +124,62 @@ /// /// private void Generate(List list) - { - SurfaceGestureVectorDirection lastDirection = SurfaceGestureVectorDirection.NONE; - int lastPoint = 0; - SurfaceGesturePoint LastChange = list[0]; - - /////// TEST/////////// - if (this.GenerateCourb(list, 5) == true) - return; + { this.Clear(); - /////////////////////// - - for (int i = 0; i < list.Count - 1; i++) + if (list.Count < 2) { - if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UP && lastDirection != SurfaceGestureVectorDirection.UP) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UP; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWN && lastDirection != SurfaceGestureVectorDirection.DOWN) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWN; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPLEFT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPRIGHT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNLEFT; - } - else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.LEFT && lastDirection != SurfaceGestureVectorDirection.LEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.LEFT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.RIGHT && lastDirection != SurfaceGestureVectorDirection.RIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.RIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPLEFT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.UPRIGHT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNLEFT; - } - else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT) - { - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] }); - LastChange = list[i + 1]; - lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT; - } - ++lastPoint; + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }); + return; } - // Analyse des extrémités de la gesture - /* + List Points = new List(); + List Vectors = new List(); + for (int index = 1; index <= list.Count; index++) + { + if (index == list.Count / 2 || index == list.Count) + { + SurfaceGestureVector verctorTemp = AnalysePoints(Points); + if (Vectors.Count == 0 || !Vectors[Vectors.Count - 1].Direction.Equals(verctorTemp.Direction)) + Vectors.Add(verctorTemp); + Points.Clear(); + } + else + Points.Add(list[index]); + } + foreach (SurfaceGestureVector elt in Vectors) + this.Add(elt); + } + + SurfaceGestureVector AnalysePoints(List list) + { double diffX = Math.Abs(list[0].X - list[list.Count - 1].X); double diffY = Math.Abs(list[0].Y - list[list.Count - 1].Y); if (diffX < 10 && diffY > 10) { - this.Clear(); - if (up > down) - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up }); + if (list[0].Y > list[list.Count - 1].Y) + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = 0, Origin = list[0] }); else - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down }); + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = 0, Origin = list[0] }); } else if (diffY < 10 && diffX > 10) { - this.Clear(); - if (left > right) - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left }); + if (list[list.Count - 1].X > list[0].X) + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = 0, Origin = list[0] }); else - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right }); - } - - */ - - // Analyse détaillée de la gesture - - List ThisTemp = new List(); - List temp = new List(); - List Tempo = new List(); - - if ((this.Count / 10) >= 1) - { - /* - for (int i = 1; i < this.Count + 1; i++) - { - temp.Add(this[i-1]); - if (i % 7 == 0) - { - SurfaceGestureVector result = Analyse(temp); - if (ThisTemp.Count == 0 || !ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction)) - ThisTemp.Add(result); - else - ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght; - temp.Clear(); - } - } - if (temp.Count > 0) - { - SurfaceGestureVector result = Analyse(temp); - if (ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction)) - ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght; - else - ThisTemp.Add(result); - temp.Clear(); - } - this.Clear(); - foreach(SurfaceGestureVector elt in ThisTemp) - this.Add(elt); - */ - switch (this.Count / 10) - { - case 1: - ThisTemp.Add(Analyse(this)); - this.Clear(); - if (ThisTemp.Count > 1) - { - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in ThisTemp) - { - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - default: - break; - } - } - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null }); - } - else - this.Add(ThisTemp[0]); - break; - case 2: - for (int index = 1; index <= this.Count; index++) - { - if (index == this.Count / 2 || index == this.Count) - { - ThisTemp.Add(Analyse(temp)); - if (ThisTemp.Count > 1) - { - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in ThisTemp) - { - - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null }); - } - else - Tempo.Add(ThisTemp[0]); - } - else - ThisTemp.Add(this[index]); - } - this.Clear(); - if (Tempo[0].Direction.Equals(Tempo[1].Direction)) - this.Add(Tempo[0]); - else - foreach (SurfaceGestureVector elt in Tempo) - this.Add(elt); - break; - case 3: - for (int index = 1; index <= this.Count; index++) - { - if (index == this.Count / 3 || index == this.Count) - { - ThisTemp.Add(Analyse(temp)); - if (ThisTemp.Count > 1) - { - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in ThisTemp) - { - - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null }); - } - else - Tempo.Add(ThisTemp[0]); - } - else - ThisTemp.Add(this[index]); - } - this.Clear(); - if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction)) - this.Add(Tempo[0]); - else - foreach (SurfaceGestureVector elt in Tempo) - this.Add(elt); - break; - default: - for (int index = 1; index <= this.Count; index++) - { - if (index == this.Count / 4 || index == this.Count) - { - ThisTemp.Add(Analyse(temp)); - if (ThisTemp.Count > 1) - { - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in ThisTemp) - { - - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null }); - } - else - Tempo.Add(ThisTemp[0]); - } - else - ThisTemp.Add(this[index]); - } - this.Clear(); - if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction) && Tempo[0].Direction.Equals(Tempo[3].Direction)) - this.Add(Tempo[0]); - else - foreach (SurfaceGestureVector elt in Tempo) - this.Add(elt); - break; - } - } - else - { - ThisTemp.Add(Analyse(this)); - this.Clear(); - if (ThisTemp.Count > 1) - { - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in ThisTemp) - { - - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null }); - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null }); - } - else - this.Add(ThisTemp[0]); - } - } - - private SurfaceGestureVector Analyse(List list) - { - // Analyse de la forme - - double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; - foreach (SurfaceGestureVector elt in list) - { - - switch (elt.Direction) - { - case SurfaceGestureVectorDirection.DOWN: - down += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNLEFT: - downleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.DOWNRIGHT: - downright += elt.Lenght; - break; - case SurfaceGestureVectorDirection.LEFT: - left += elt.Lenght; - break; - case SurfaceGestureVectorDirection.RIGHT: - right += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UP: - up += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPLEFT: - upleft += elt.Lenght; - break; - case SurfaceGestureVectorDirection.UPRIGHT: - upright += elt.Lenght; - break; - } - } - /* - //double cupleft = 0, cupright = 0, cdownleft = 0, cdownright = 0; - - - if (list.Count > 2) - { - double min = 180; - for (int i = 1; i < list.Count - 2; i++) - { - double a = GetDistancePoints(list[list.Count - 1].Origin, list[0].Origin); - double b = GetDistancePoints(list[i].Origin, list[0].Origin); - double c = GetDistancePoints(list[i].Origin, list[list.Count - 1].Origin); - double angle = 180 * (Math.Acos((b * b + c * c - a * a) / (2 * b * c))) / Math.PI ; - min = Math.Min(angle > 0 ? angle : 180, min); - } - if(min<130) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = up, Origin = list[0].Origin }; - } - - if (up < 4 && upleft < 4 && upright < 4 && down < 4 && downleft < 4 && downright < 4 && right < 4 && left < 4) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }; - if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin }; - else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right)) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin }; - else - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = 0, Origin = list[0].Origin }); - */ - - double diffX = Math.Abs(list[0].Origin.X - list[list.Count - 1].Origin.X); - double diffY = Math.Abs(list[0].Origin.Y - list[list.Count - 1].Origin.Y); - - if (diffX < 10 && diffY > 10) - { - if (list[0].Origin.Y > list[list.Count - 1].Origin.Y) - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin }); - else - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin }); - } - else if (diffY < 10 && diffX > 10) - { - if (list[list.Count - 1].Origin.X > list[0].Origin.X) - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin }); - else - return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin }); + return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = 0, Origin = list[0] }); } else if (diffX > 10 && diffY > 10) { - if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin }; - else if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X < list[0].Origin.X) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin }; - else if (list[0].Origin.Y < list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X) - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin }; + if (list[0].Y > list[list.Count - 1].Y && list[list.Count - 1].X > list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = 0, Origin = list[0] }; + else if (list[0].Y > list[list.Count - 1].Y && list[list.Count - 1].X < list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = 0, Origin = list[0] }; + else if (list[0].Y < list[list.Count - 1].Y && list[list.Count - 1].X > list[0].X) + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = 0, Origin = list[0] }; else - return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin }; + return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = 0, Origin = list[0] }; } else return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }; @@ -718,41 +190,21 @@ if (p1.Y < p2.Y) { // go up - if (Math.Abs(p2.Y - p1.Y) > this.Precision) + if (Math.Abs(p2.X - p1.X) < Math.Abs(p2.Y - p1.Y)) + return SurfaceGestureVectorDirection.DOWN; + else { - if (Math.Abs(p2.X - p1.X) < Math.Abs(p2.Y - p1.Y)) - return SurfaceGestureVectorDirection.DOWN; + if (p1.X < p2.X) + return SurfaceGestureVectorDirection.DOWNRIGHT; else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.DOWNLEFT; - } + return SurfaceGestureVectorDirection.DOWNLEFT; } - else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.DOWNLEFT; - } } else { // go down - if (Math.Abs(p1.Y - p2.Y) > this.Precision) - { - if (Math.Abs(p1.X - p2.X) < Math.Abs(p1.Y - p2.Y)) - return SurfaceGestureVectorDirection.UP; - else - { - if (p1.X < p2.X) - return SurfaceGestureVectorDirection.UPRIGHT; - else - return SurfaceGestureVectorDirection.UPLEFT; - } - } + if (Math.Abs(p1.X - p2.X) < Math.Abs(p1.Y - p2.Y)) + return SurfaceGestureVectorDirection.UP; else { if (p1.X < p2.X) @@ -768,18 +220,8 @@ if (p1.X < p2.X) { // go left - if (Math.Abs(p2.X - p1.X) > this.Precision) - { - if (Math.Abs(p2.Y - p1.Y) < Math.Abs(p2.X - p1.X)) - return SurfaceGestureVectorDirection.RIGHT; - else - { - if (p1.Y < p2.Y) - return SurfaceGestureVectorDirection.DOWNRIGHT; - else - return SurfaceGestureVectorDirection.UPRIGHT; - } - } + if (Math.Abs(p2.Y - p1.Y) < Math.Abs(p2.X - p1.X)) + return SurfaceGestureVectorDirection.RIGHT; else { if (p1.Y < p2.Y) @@ -790,19 +232,9 @@ } else { - // go right - if (Math.Abs(p1.X - p2.X) > this.Precision) - { - if (Math.Abs(p1.Y - p2.Y) < Math.Abs(p1.X - p2.X)) - return SurfaceGestureVectorDirection.LEFT; - else - { - if (p1.Y < p2.Y) - return SurfaceGestureVectorDirection.DOWNLEFT; - else - return SurfaceGestureVectorDirection.UPLEFT; - } - } + // go right= + if (Math.Abs(p1.Y - p2.Y) < Math.Abs(p1.X - p2.X)) + return SurfaceGestureVectorDirection.LEFT; else { if (p1.Y < p2.Y) @@ -829,4 +261,4 @@ } #endregion } -} +} \ No newline at end of file diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance.GestureControl/Resources/Patterns.xml --- a/src/FingersDance.GestureControl/Resources/Patterns.xml Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance.GestureControl/Resources/Patterns.xml Thu Nov 19 18:05:52 2009 +0100 @@ -1,37 +1,78 @@  + - UP + TRIGGER - UP + RIGHT - Up + Right + + + + TAP + + TAP + - LEFT + CONTRE POINTS - Up + TAP - Up + TAP - Up + TAP - Up + TAP + - RIGHT + CONTRE PESANTEUR + + + UPRIGHT-DOWNRIGHT + + Upright + Downright + + + + + + + AVEC PESANTEUR + DOWNRIGHT-UPRIGHT + + Downright + Upright + + + + + + + ALIGNEMENT + + + RIGHT + + Right + + + RIGHT Right @@ -39,8 +80,61 @@ + - PAUSE + CONTACT VISUEL + + + DOWNRIGHT-DOWNLEFT + + Downright + Downleft + + + + DOWNLEFT-DOWNRIGHT + + Downleft + Downright + + + + + + + MOUVEMENT CONTRAINTE + + + DOWNLEFT-DOWNRIGHT + + Downleft + Downright + + + + DOWNRIGHT-DOWNLEFT + + Downright + Downleft + + + + + + + UN DANSEUR + + + DOWN + + Down + + + + + + + DEUX DANSEURS DOWN @@ -56,42 +150,134 @@ + - PAUSE + TROIS DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + QUATRE DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + TOUS LES DANSEURS + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + DOWN + + Down + + + + + + + CONTACT TABLE/DANSEUR DOWNRIGHT - DownRight + Downright - DOWNRIGHT + DOWNLEFT - DownRight + Downleft - PAUSE + CONTACT TABLE-DANSEUR DOWNLEFT - DownLeft + Downleft - DOWNLEFT + DOWNRIGHT - DownLeft + Downright + - PLAY + PLAY-PAUSE TAP @@ -101,4 +287,5 @@ + \ No newline at end of file diff -r beebae32b1ed -r d13dbcf861d7 src/FingersDance/FingersDance.csproj --- a/src/FingersDance/FingersDance.csproj Thu Nov 19 18:37:26 2009 +0100 +++ b/src/FingersDance/FingersDance.csproj Thu Nov 19 18:05:52 2009 +0100 @@ -143,9 +143,9 @@ Always - + Always - +