diff -r 89cbcb52b674 -r 56041bd3761e src/FingersDance.GestureControl/GestureVector.cs --- a/src/FingersDance.GestureControl/GestureVector.cs Tue Oct 27 10:10:26 2009 +0100 +++ b/src/FingersDance.GestureControl/GestureVector.cs Wed Oct 28 11:57:38 2009 +0100 @@ -126,7 +126,10 @@ private void Generate(List list) { if (list.Count < 2) + { + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 }); return; + } SurfaceGestureVectorDirection lastDirection = SurfaceGestureVectorDirection.NONE; int lastPoint = 0; SurfaceGesturePoint LastChange = list[0]; @@ -213,41 +216,66 @@ } ++lastPoint; } + Analyse(list); + } + private void Analyse(List list) + { // Analyse de la forme - int up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; + double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0; foreach (SurfaceGestureVector elt in this) { switch (elt.Direction) { case SurfaceGestureVectorDirection.DOWN: - down++; + down += elt.Lenght; break; case SurfaceGestureVectorDirection.DOWNLEFT: - downleft++; + downleft += elt.Lenght; break; case SurfaceGestureVectorDirection.DOWNRIGHT: - downright++; + downright += elt.Lenght; break; case SurfaceGestureVectorDirection.LEFT: - left++; + left += elt.Lenght; break; case SurfaceGestureVectorDirection.RIGHT: - right++; + right += elt.Lenght; break; case SurfaceGestureVectorDirection.UP: - up++; + up += elt.Lenght; break; case SurfaceGestureVectorDirection.UPLEFT: - upleft++; + upleft += elt.Lenght; break; case SurfaceGestureVectorDirection.UPRIGHT: - upright++; + upright += elt.Lenght; break; } } + + 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 < 5) + { + this.Clear(); + if (up > down) + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up }); + else + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down }); + } + else if (diffY < 5) + { + this.Clear(); + if (left > right) + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left }); + else + this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right }); + } } + private SurfaceGestureVectorDirection GetHorizontal(SurfaceGesturePoint p1, SurfaceGesturePoint p2) { if (p1.Y < p2.Y)