src/FingersDance.GestureControl/GestureVector.cs
author PAMPHILE Jonathan <pamphile@efrei.fr>
Thu, 19 Nov 2009 09:28:15 +0100
changeset 209 09c4d30fe8d1
parent 189 b37888f59cf2
child 215 d13dbcf861d7
permissions -rw-r--r--
Indentations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     1
using System;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     2
using System.Collections.Generic;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     3
using System.Linq;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     4
using System.Text;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     5
using System.Windows.Input;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     6
using System.Windows;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     7
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     8
namespace GestureControl
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
     9
{
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    10
    /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    11
    /// Take a list of points and try to recognize a pattern
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    12
    /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    13
    public class SurfaceGesture : List<SurfaceGestureVector>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    14
    {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    15
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    16
        #region Prop
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    17
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    18
        /// Allow some variation without log a direction
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    19
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    20
        public int Precision { get; set; }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    21
        #endregion
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
    22
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    23
        #region Constructor
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    24
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    25
        /// load know patterns and generate the vector list from a list of points with a default 20 precision factor
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    26
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    27
        /// <param name="list"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    28
        public SurfaceGesture(List<SurfaceGesturePoint> list)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    29
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    30
            this.Precision = 20;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    31
            this.Generate(list);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    32
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    33
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    34
        /// load know patterns and generate the vector list from a list of points with a precision factor
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    35
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    36
        /// <param name="list"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    37
        /// <param name="precision"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    38
        public SurfaceGesture(List<SurfaceGesturePoint> list, int precision)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    39
        {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
    40
            this.Precision = 20;
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    41
            this.Generate(list);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    42
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    43
        #endregion
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
    44
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    45
        #region GenerateVector
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    46
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    47
        /// Generate list of vector from courbe mouvements, filter with the pas value
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    48
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    49
        /// <param name="list"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    50
        /// <param name="pas"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    51
        /// <returns></returns>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    52
        private bool GenerateCourb(List<SurfaceGesturePoint> list, int pas)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    53
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    54
            int sep = list.Count / pas;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    55
            double count = 0; ;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    56
            SurfaceGesturePoint past = new SurfaceGesturePoint() { X = 0, Y = 0 };
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    57
            double y = 0;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    58
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    59
            for (int i = 0; i < list.Count - 1; i++)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    60
            {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    61
                if (i % pas != 0)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    62
                {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    63
                    count += Math.Atan(list[i + 1].Y / list[i + 1].X) - Math.Atan(list[i].Y / list[i].X);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    64
                }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    65
                else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    66
                {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    67
                    count /= pas;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    68
                    if (count == 0 || this.GetDistancePoints(past, list[i + 1]) < 5)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    69
                    {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    70
                        y = list[i + 1].Y;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    71
                        past.X = count;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    72
                        continue;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    73
                    }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    74
                    if (y > list[i + 1].Y)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    75
                    {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    76
                        if (past.X > count)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    77
                            this.AddDirection(SurfaceGestureVectorDirection.UPRIGHT);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    78
                        else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    79
                            this.AddDirection(SurfaceGestureVectorDirection.UPLEFT);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    80
                    }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    81
                    else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    82
                    {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    83
                        if (past.X > count)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    84
                            this.AddDirection(SurfaceGestureVectorDirection.DOWNRIGHT);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    85
                        else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    86
                            this.AddDirection(SurfaceGestureVectorDirection.DOWNLEFT);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    87
                    }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    88
                    y = list[i + 1].Y;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    89
                    past.X = count;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    90
                }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    91
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    92
            Console.Write(this);
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
    93
            /*if (this.GetPattern() != "None")
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    94
                return true;
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
    95
            else*/
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
    96
                return false;
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    97
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    98
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
    99
        /// Get distance between two points
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   100
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   101
        /// <param name="p1"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   102
        /// <param name="p2"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   103
        /// <returns></returns>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   104
        private int GetDistancePoints(SurfaceGesturePoint p1, SurfaceGesturePoint p2)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   105
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   106
            return (int)Math.Sqrt(Math.Pow((p2.X - p1.X), 2) + Math.Pow((p1.Y - p2.Y), 2));
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   107
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   108
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   109
        /// add a direction in the vector list if past who not the same
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   110
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   111
        /// <param name="type"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   112
        private void AddDirection(SurfaceGestureVectorDirection type)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   113
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   114
            if (this.Count == 0)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   115
            {
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
   116
                this.Add(new SurfaceGestureVector { Direction = type, Lenght = 42 });
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
   117
                return;
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   118
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   119
            if (this[this.Count - 1].Direction != type)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   120
                this.Add(new SurfaceGestureVector { Direction = type, Lenght = 42 });
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   121
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   122
        /// <summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   123
        /// generate list of vector
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   124
        /// </summary>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   125
        /// <param name="list"></param>
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   126
        private void Generate(List<SurfaceGesturePoint> list)
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   127
        {            
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   128
            SurfaceGestureVectorDirection lastDirection = SurfaceGestureVectorDirection.NONE;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   129
            int lastPoint = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   130
            SurfaceGesturePoint LastChange = list[0];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   131
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   132
            /////// TEST///////////
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   133
            if (this.GenerateCourb(list, 5) == true)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   134
                return;
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   135
            this.Clear();
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   136
            ///////////////////////
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   137
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   138
            for (int i = 0; i < list.Count - 1; i++)
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   139
            {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   140
                if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UP && lastDirection != SurfaceGestureVectorDirection.UP)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   141
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   142
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   143
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   144
                    lastDirection = SurfaceGestureVectorDirection.UP;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   145
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   146
                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWN && lastDirection != SurfaceGestureVectorDirection.DOWN)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   147
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   148
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   149
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   150
                    lastDirection = SurfaceGestureVectorDirection.DOWN;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   151
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   152
                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   153
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   154
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   155
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   156
                    lastDirection = SurfaceGestureVectorDirection.UPLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   157
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   158
                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   159
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   160
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   161
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   162
                    lastDirection = SurfaceGestureVectorDirection.UPRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   163
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   164
                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   165
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   166
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   167
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   168
                    lastDirection = SurfaceGestureVectorDirection.DOWNLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   169
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   170
                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   171
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   172
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   173
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   174
                    lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   175
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   176
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.LEFT && lastDirection != SurfaceGestureVectorDirection.LEFT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   177
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   178
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   179
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   180
                    lastDirection = SurfaceGestureVectorDirection.LEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   181
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   182
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.RIGHT && lastDirection != SurfaceGestureVectorDirection.RIGHT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   183
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   184
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   185
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   186
                    lastDirection = SurfaceGestureVectorDirection.RIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   187
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   188
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   189
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   190
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   191
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   192
                    lastDirection = SurfaceGestureVectorDirection.UPLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   193
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   194
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   195
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   196
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   197
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   198
                    lastDirection = SurfaceGestureVectorDirection.UPRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   199
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   200
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   201
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   202
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   203
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   204
                    lastDirection = SurfaceGestureVectorDirection.DOWNLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   205
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   206
                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   207
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   208
                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   209
                    LastChange = list[i + 1];
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   210
                    lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   211
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   212
                ++lastPoint;
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   213
            }
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   214
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   215
            //  Analyse des extrémités de la gesture
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   216
            /*
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   217
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   218
            double diffX = Math.Abs(list[0].X - list[list.Count - 1].X);
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   219
            double diffY = Math.Abs(list[0].Y - list[list.Count - 1].Y);
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   220
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   221
            if (diffX < 10 && diffY > 10)
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   222
            {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   223
                this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   224
                if (up > down)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   225
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up });
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   226
                else
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   227
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down });
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   228
            }
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   229
            else if (diffY < 10 && diffX > 10)
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   230
            {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   231
                this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   232
                if (left > right)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   233
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left });
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   234
                else
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   235
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   236
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   237
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   238
            */
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   239
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   240
            //  Analyse détaillée de la gesture
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   241
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   242
            List<SurfaceGestureVector> ThisTemp = new List<SurfaceGestureVector>();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   243
            List<SurfaceGestureVector> temp = new List<SurfaceGestureVector>();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   244
            List<SurfaceGestureVector> Tempo = new List<SurfaceGestureVector>();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   245
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   246
            if ((this.Count / 10) >= 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   247
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   248
                /*
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   249
                for (int i = 1; i < this.Count + 1; i++)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   250
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   251
                    temp.Add(this[i-1]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   252
                    if (i % 7 == 0)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   253
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   254
                        SurfaceGestureVector result = Analyse(temp);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   255
                        if (ThisTemp.Count == 0 || !ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   256
                            ThisTemp.Add(result);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   257
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   258
                            ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   259
                        temp.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   260
                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   261
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   262
                if (temp.Count > 0)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   263
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   264
                    SurfaceGestureVector result = Analyse(temp);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   265
                    if (ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   266
                        ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   267
                    else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   268
                        ThisTemp.Add(result);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   269
                    temp.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   270
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   271
                this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   272
                foreach(SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   273
                    this.Add(elt);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   274
                 */
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   275
                switch (this.Count / 10)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   276
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   277
                    case 1:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   278
                        ThisTemp.Add(Analyse(this));
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   279
                        this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   280
                        if (ThisTemp.Count > 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   281
                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   282
                            double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   283
                            foreach (SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   284
                            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   285
                                switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   286
                                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   287
                                    case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   288
                                        down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   289
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   290
                                    case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   291
                                        downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   292
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   293
                                    case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   294
                                        downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   295
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   296
                                    case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   297
                                        left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   298
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   299
                                    case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   300
                                        right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   301
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   302
                                    case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   303
                                        up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   304
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   305
                                    case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   306
                                        upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   307
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   308
                                    case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   309
                                        upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   310
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   311
                                    default:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   312
                                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   313
                                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   314
                            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   315
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   316
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   317
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   318
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   319
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   320
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   321
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   322
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   323
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   324
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   325
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   326
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   327
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   328
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   329
                            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   330
                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   331
                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   332
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   333
                            this.Add(ThisTemp[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   334
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   335
                    case 2:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   336
                        for (int index = 1; index <= this.Count; index++)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   337
                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   338
                            if (index == this.Count / 2 || index == this.Count)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   339
                            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   340
                                ThisTemp.Add(Analyse(temp));
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   341
                                if (ThisTemp.Count > 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   342
                                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   343
                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   344
                                    foreach (SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   345
                                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   346
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   347
                                        switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   348
                                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   349
                                            case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   350
                                                down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   351
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   352
                                            case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   353
                                                downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   354
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   355
                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   356
                                                downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   357
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   358
                                            case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   359
                                                left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   360
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   361
                                            case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   362
                                                right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   363
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   364
                                            case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   365
                                                up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   366
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   367
                                            case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   368
                                                upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   369
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   370
                                            case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   371
                                                upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   372
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   373
                                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   374
                                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   375
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   376
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   377
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   378
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   379
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   380
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   381
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   382
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   383
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   384
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   385
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   386
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   387
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   388
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   389
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   390
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   391
                                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   392
                                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   393
                                    Tempo.Add(ThisTemp[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   394
                            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   395
                            else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   396
                                ThisTemp.Add(this[index]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   397
                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   398
                        this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   399
                        if (Tempo[0].Direction.Equals(Tempo[1].Direction))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   400
                            this.Add(Tempo[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   401
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   402
                            foreach (SurfaceGestureVector elt in Tempo)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   403
                                this.Add(elt);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   404
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   405
                    case 3:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   406
                        for (int index = 1; index <= this.Count; index++)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   407
                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   408
                            if (index == this.Count / 3 || index == this.Count)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   409
                            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   410
                                ThisTemp.Add(Analyse(temp));
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   411
                                if (ThisTemp.Count > 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   412
                                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   413
                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   414
                                    foreach (SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   415
                                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   416
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   417
                                        switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   418
                                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   419
                                            case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   420
                                                down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   421
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   422
                                            case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   423
                                                downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   424
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   425
                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   426
                                                downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   427
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   428
                                            case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   429
                                                left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   430
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   431
                                            case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   432
                                                right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   433
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   434
                                            case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   435
                                                up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   436
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   437
                                            case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   438
                                                upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   439
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   440
                                            case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   441
                                                upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   442
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   443
                                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   444
                                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   445
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   446
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   447
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   448
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   449
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   450
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   451
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   452
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   453
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   454
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   455
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   456
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   457
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   458
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   459
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   460
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   461
                                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   462
                                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   463
                                    Tempo.Add(ThisTemp[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   464
                            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   465
                            else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   466
                                ThisTemp.Add(this[index]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   467
                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   468
                        this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   469
                        if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   470
                            this.Add(Tempo[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   471
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   472
                            foreach (SurfaceGestureVector elt in Tempo)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   473
                                this.Add(elt);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   474
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   475
                    default:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   476
                        for (int index = 1; index <= this.Count; index++)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   477
                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   478
                            if (index == this.Count / 4 || index == this.Count)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   479
                            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   480
                                ThisTemp.Add(Analyse(temp));
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   481
                                if (ThisTemp.Count > 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   482
                                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   483
                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   484
                                    foreach (SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   485
                                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   486
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   487
                                        switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   488
                                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   489
                                            case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   490
                                                down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   491
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   492
                                            case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   493
                                                downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   494
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   495
                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   496
                                                downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   497
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   498
                                            case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   499
                                                left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   500
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   501
                                            case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   502
                                                right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   503
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   504
                                            case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   505
                                                up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   506
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   507
                                            case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   508
                                                upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   509
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   510
                                            case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   511
                                                upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   512
                                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   513
                                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   514
                                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   515
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   516
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   517
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   518
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   519
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   520
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   521
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   522
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   523
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   524
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   525
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   526
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   527
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   528
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   529
                                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   530
                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   531
                                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   532
                                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   533
                                    Tempo.Add(ThisTemp[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   534
                            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   535
                            else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   536
                                ThisTemp.Add(this[index]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   537
                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   538
                        this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   539
                        if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction) && Tempo[0].Direction.Equals(Tempo[3].Direction))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   540
                            this.Add(Tempo[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   541
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   542
                            foreach (SurfaceGestureVector elt in Tempo)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   543
                                this.Add(elt);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   544
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   545
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   546
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   547
            else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   548
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   549
                ThisTemp.Add(Analyse(this));
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   550
                this.Clear();
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   551
                if (ThisTemp.Count > 1)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   552
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   553
                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   554
                    foreach (SurfaceGestureVector elt in ThisTemp)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   555
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   556
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   557
                        switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   558
                        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   559
                            case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   560
                                down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   561
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   562
                            case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   563
                                downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   564
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   565
                            case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   566
                                downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   567
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   568
                            case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   569
                                left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   570
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   571
                            case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   572
                                right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   573
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   574
                            case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   575
                                up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   576
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   577
                            case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   578
                                upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   579
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   580
                            case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   581
                                upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   582
                                break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   583
                        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   584
                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   585
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   586
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   587
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   588
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   589
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   590
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   591
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   592
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   593
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   594
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   595
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   596
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   597
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   598
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   599
                    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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   600
                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   601
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   602
                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   603
                    this.Add(ThisTemp[0]);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   604
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   605
        }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   606
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   607
        private SurfaceGestureVector Analyse(List<SurfaceGestureVector> list)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   608
        {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   609
            //  Analyse de la forme
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   610
            
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   611
            double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   612
            foreach (SurfaceGestureVector elt in list)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   613
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   614
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   615
                switch (elt.Direction)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   616
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   617
                    case SurfaceGestureVectorDirection.DOWN:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   618
                        down += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   619
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   620
                    case SurfaceGestureVectorDirection.DOWNLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   621
                        downleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   622
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   623
                    case SurfaceGestureVectorDirection.DOWNRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   624
                        downright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   625
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   626
                    case SurfaceGestureVectorDirection.LEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   627
                        left += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   628
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   629
                    case SurfaceGestureVectorDirection.RIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   630
                        right += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   631
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   632
                    case SurfaceGestureVectorDirection.UP:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   633
                        up += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   634
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   635
                    case SurfaceGestureVectorDirection.UPLEFT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   636
                        upleft += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   637
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   638
                    case SurfaceGestureVectorDirection.UPRIGHT:
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   639
                        upright += elt.Lenght;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   640
                        break;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   641
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   642
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   643
            /*
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   644
            //double cupleft = 0, cupright = 0, cdownleft = 0, cdownright = 0;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   645
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   646
            
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   647
            if (list.Count > 2)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   648
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   649
                double min = 180;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   650
                for (int i = 1; i < list.Count - 2; i++)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   651
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   652
                    double a = GetDistancePoints(list[list.Count - 1].Origin, list[0].Origin);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   653
                    double b = GetDistancePoints(list[i].Origin, list[0].Origin);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   654
                    double c = GetDistancePoints(list[i].Origin, list[list.Count - 1].Origin);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   655
                    double angle = 180 * (Math.Acos((b * b + c * c - a * a) / (2 * b * c))) / Math.PI ;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   656
                    min = Math.Min(angle > 0 ? angle : 180, min);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   657
                }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   658
                if(min<130)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   659
                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = up, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   660
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   661
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   662
            if (up < 4 && upleft < 4 && upright < 4 && down < 4 && downleft < 4 && downright < 4 && right < 4 && left < 4)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   663
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   664
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   665
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   666
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   667
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   668
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   669
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   670
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   671
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   672
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   673
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   674
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   675
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   676
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   677
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   678
            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))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   679
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   680
            else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   681
                return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = 0, Origin = list[0].Origin });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   682
             */
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   683
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   684
            double diffX = Math.Abs(list[0].Origin.X - list[list.Count - 1].Origin.X);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   685
            double diffY = Math.Abs(list[0].Origin.Y - list[list.Count - 1].Origin.Y);
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   686
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   687
            if (diffX < 10 && diffY > 10)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   688
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   689
                if (list[0].Origin.Y > list[list.Count - 1].Origin.Y)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   690
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   691
                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   692
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   693
            }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   694
            else if (diffY < 10 && diffX > 10)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   695
            {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   696
                if (list[list.Count - 1].Origin.X > list[0].Origin.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   697
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin });
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   698
                else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   699
                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin });
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   700
            }
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   701
            else if (diffX > 10 && diffY > 10)
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   702
            {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   703
                if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   704
                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   705
                else if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X < list[0].Origin.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   706
                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   707
                else if (list[0].Origin.Y < list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   708
                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin };
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   709
                else
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   710
                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   711
            }
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   712
            else
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   713
                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 };
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   714
        }
178
56041bd3761e Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 177
diff changeset
   715
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   716
        private SurfaceGestureVectorDirection GetHorizontal(SurfaceGesturePoint p1, SurfaceGesturePoint p2)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   717
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   718
            if (p1.Y < p2.Y)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   719
            {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   720
                // go up
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   721
                if (Math.Abs(p2.Y - p1.Y) > this.Precision)
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   722
                {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   723
                    if (Math.Abs(p2.X - p1.X) < Math.Abs(p2.Y - p1.Y))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   724
                        return SurfaceGestureVectorDirection.DOWN;
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   725
                    else
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   726
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   727
                        if (p1.X < p2.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   728
                            return SurfaceGestureVectorDirection.DOWNRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   729
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   730
                            return SurfaceGestureVectorDirection.DOWNLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   731
                    }
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   732
                }
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   733
                    else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   734
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   735
                        if (p1.X < p2.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   736
                            return SurfaceGestureVectorDirection.DOWNRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   737
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   738
                            return SurfaceGestureVectorDirection.DOWNLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   739
                    }
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   740
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   741
            else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   742
            {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   743
                // go down
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   744
                if (Math.Abs(p1.Y - p2.Y) > this.Precision)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   745
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   746
                    if (Math.Abs(p1.X - p2.X) < Math.Abs(p1.Y - p2.Y))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   747
                        return SurfaceGestureVectorDirection.UP;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   748
                    else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   749
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   750
                        if (p1.X < p2.X)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   751
                            return SurfaceGestureVectorDirection.UPRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   752
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   753
                            return SurfaceGestureVectorDirection.UPLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   754
                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   755
                }
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   756
                else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   757
                {
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   758
                    if (p1.X < p2.X)
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   759
                        return SurfaceGestureVectorDirection.UPRIGHT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   760
                    else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   761
                        return SurfaceGestureVectorDirection.UPLEFT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   762
                }
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   763
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   764
        }
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   765
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   766
        private SurfaceGestureVectorDirection GetVertical(SurfaceGesturePoint p1, SurfaceGesturePoint p2)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   767
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   768
            if (p1.X < p2.X)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   769
            {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   770
                // go left
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   771
                if (Math.Abs(p2.X - p1.X) > this.Precision)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   772
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   773
                    if (Math.Abs(p2.Y - p1.Y) < Math.Abs(p2.X - p1.X))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   774
                        return SurfaceGestureVectorDirection.RIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   775
                    else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   776
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   777
                        if (p1.Y < p2.Y)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   778
                            return SurfaceGestureVectorDirection.DOWNRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   779
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   780
                            return SurfaceGestureVectorDirection.UPRIGHT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   781
                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   782
                }
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   783
                else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   784
                {
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   785
                    if (p1.Y < p2.Y)
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   786
                        return SurfaceGestureVectorDirection.DOWNRIGHT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   787
                    else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   788
                        return SurfaceGestureVectorDirection.UPRIGHT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   789
                }
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   790
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   791
            else
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   792
            {
209
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   793
                // go right
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   794
                if (Math.Abs(p1.X - p2.X) > this.Precision)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   795
                {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   796
                    if (Math.Abs(p1.Y - p2.Y) < Math.Abs(p1.X - p2.X))
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   797
                        return SurfaceGestureVectorDirection.LEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   798
                    else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   799
                    {
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   800
                        if (p1.Y < p2.Y)
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   801
                            return SurfaceGestureVectorDirection.DOWNLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   802
                        else
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   803
                            return SurfaceGestureVectorDirection.UPLEFT;
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   804
                    }
09c4d30fe8d1 Indentations
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 189
diff changeset
   805
                }
177
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   806
                else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   807
                {
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   808
                    if (p1.Y < p2.Y)
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   809
                        return SurfaceGestureVectorDirection.DOWNLEFT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   810
                    else
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   811
                        return SurfaceGestureVectorDirection.UPLEFT;
89cbcb52b674 Mise en place de la reconnaissance de formes
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 176
diff changeset
   812
                }
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   813
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   814
        }
189
b37888f59cf2 Gesture
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 178
diff changeset
   815
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   816
        #endregion
176
0896f36b9d57 Multi Touch
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 174
diff changeset
   817
174
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   818
        #region Override
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   819
        public override String ToString()
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   820
        {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   821
            String ret = "";
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   822
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   823
            foreach (SurfaceGestureVector v in this)
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   824
            {
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   825
                ret += (v.Direction + ", lenght:" + v.Lenght + ", precision:" + this.Precision + "\n");
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   826
                //Console.WriteLine(v.Direction + ", lenght:" + v.Lenght + ", precision:" + this.Precision);
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   827
            }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   828
            return ret;
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   829
        }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   830
        #endregion
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   831
    }
45c9e55fcf23 Gesture Control
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
diff changeset
   832
}