Dictionnaire de données
authorPAMPHILE Jonathan <pamphile@efrei.fr>
Fri, 13 Nov 2009 20:10:00 +0100
changeset 195 48b3139bb182
parent 194 d96cd2bce653
child 196 e738cd9c1b99
Dictionnaire de données
src/FingersDance.ActionFactory/DataFactory.cs
src/FingersDance.ActionFactory/FingersDance.Factory.csproj
src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance.Data/DataDictionary.cs
src/FingersDance.Data/FingersDance.Data.csproj
src/FingersDance.GestureControl/Nouveau document texte.txt
src/FingersDance/MainSurfaceWindow.xaml.cs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.ActionFactory/DataFactory.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FingersDance.Data;
+
+namespace FingersDance.Factory
+{
+    public class DataFactory
+    {
+        static DataDictionary _Data = new DataDictionary();
+
+        public DataDictionary Data
+        {
+            get { return _Data; }
+        }
+
+        public DataFactory()
+        {
+            if (_Data == null)
+                _Data = new DataDictionary();
+        }
+    }
+}
--- a/src/FingersDance.ActionFactory/FingersDance.Factory.csproj	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.ActionFactory/FingersDance.Factory.csproj	Fri Nov 13 20:10:00 2009 +0100
@@ -3,7 +3,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{C7B905EA-0678-4DA0-8EF8-7F9CBD22818E}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -74,6 +74,7 @@
     <Compile Include="ActionFactory.cs" />
     <Compile Include="ActionGenerator.cs" />
     <Compile Include="ColorFactory.cs" />
+    <Compile Include="DataFactory.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -81,6 +82,10 @@
       <Project>{1E80D5A1-C45C-443B-8992-4A4D78D280FC}</Project>
       <Name>FingersDance.Actions</Name>
     </ProjectReference>
+    <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+      <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+      <Name>FingersDance.Data</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -31,6 +31,7 @@
 
         public event EventHandler PlayerOpened;
         public event EventHandler PlayerStopOrPause;
+        public event EventHandler NewGestureRegognized;
 
         public double Time
         {
@@ -124,75 +125,80 @@
 
         public void GestureDetected(object sender, GestureControl.GestureRoutedEventArgs e)
         {
-
-            /*
-             *  e.Gesture.Name = Nom de la gesture
-             *  e.Gesture.Start = Valeur de la timeline au début de l'annotation
-             *  e.Gesture.End = Valeur de la timeline à la fin de l'annotation
-             * 
-             */
+            try
+            {
+                /*
+                 *  e.Gesture.Name = Nom de la gesture
+                 *  e.Gesture.Start = Valeur de la timeline au début de l'annotation
+                 *  e.Gesture.End = Valeur de la timeline à la fin de l'annotation
+                 * 
+                 */
+                switch (e.Gesture.Name)
+                {
+                    case "TRIGGER":
 
-            switch (e.Gesture.Name)
-            {
-                case "TRIGGER":
-                    
-                    usercontrolInfoUser.LabelSession.Content = "TRIGGER!";
-                    break;
-                case "CONTRE POINTS":
+                        usercontrolInfoUser.LabelSession.Content = "TRIGGER!";
+                        break;
+                    case "CONTRE POINTS":
 
-                    usercontrolInfoUser.LabelSession.Content = "CONTRE POINTS!";
-                    break;
-                case "CONTRE PESANTEUR":
+                        usercontrolInfoUser.LabelSession.Content = "CONTRE POINTS!";
+                        break;
+                    case "CONTRE PESANTEUR":
 
-                    usercontrolInfoUser.LabelSession.Content = "CONTRE PESANTEUR!";
-                    break;
-                case "AVEC PESANTEUR":
+                        usercontrolInfoUser.LabelSession.Content = "CONTRE PESANTEUR!";
+                        break;
+                    case "AVEC PESANTEUR":
 
-                    usercontrolInfoUser.LabelSession.Content = "AVEC PESANTEUR!";
-                    break;
-                case "ALIGNEMENT":
+                        usercontrolInfoUser.LabelSession.Content = "AVEC PESANTEUR!";
+                        break;
+                    case "ALIGNEMENT":
 
-                    usercontrolInfoUser.LabelSession.Content = "ALIGNEMENT!";
-                    break;
-                case "CONTACT VISUEL":
+                        usercontrolInfoUser.LabelSession.Content = "ALIGNEMENT!";
+                        break;
+                    case "CONTACT VISUEL":
+
+                        usercontrolInfoUser.LabelSession.Content = "CONTACT VISUEL!";
+                        break;
+                    case "MOUVEMENT CONTRAINTE":
 
-                    usercontrolInfoUser.LabelSession.Content = "CONTACT VISUEL!";
-                    break;
-                case "MOUVEMENT CONTRAINTE":
+                        usercontrolInfoUser.LabelSession.Content = "MOUVEMENT CONTRAINTE!";
+                        break;
+                    case "UN DANSEUR":
 
-                    usercontrolInfoUser.LabelSession.Content = "MOUVEMENT CONTRAINTE!";
-                    break;
-                case "UN DANSEUR":
+                        usercontrolInfoUser.LabelSession.Content = "UN DANSEUR!";
+                        break;
+                    case "DEUX DANSEURS":
 
-                    usercontrolInfoUser.LabelSession.Content = "UN DANSEUR!";
-                    break;
-                case "DEUX DANSEURS":
+                        usercontrolInfoUser.LabelSession.Content = "DEUX DANSEURS!";
+                        break;
+                    case "TROIS DANSEURS":
 
-                    usercontrolInfoUser.LabelSession.Content = "DEUX DANSEURS!";
-                    break;
-                case "TROIS DANSEURS":
+                        usercontrolInfoUser.LabelSession.Content = "TROIS DANSEURS!";
+                        break;
+                    case "QUATRE DANSEURS":
 
-                    usercontrolInfoUser.LabelSession.Content = "TROIS DANSEURS!";
-                    break;
-                case "QUATRE DANSEURS":
+                        usercontrolInfoUser.LabelSession.Content = "QUATRE DANSEURS!";
+                        break;
+                    case "TOUS LES DANSEURS":
 
-                    usercontrolInfoUser.LabelSession.Content = "QUATRE DANSEURS!";
-                    break;
-                case "TOUS LES DANSEURS":
+                        usercontrolInfoUser.LabelSession.Content = "TOUS LES DANSEURS!";
+                        break;
+                    case "CONTACT TABLE/DANSEUR":
 
-                    usercontrolInfoUser.LabelSession.Content = "TOUS LES DANSEURS!";
-                    break;
-                case "CONTACT TABLE/DANSEUR":
-
-                    usercontrolInfoUser.LabelSession.Content = "CONTACT TABLE/DANSEUR!";
-                    break;
-                case "PLAY-PAUSE":
-                    usercontrolInfoUser.LabelSession.Content = "PLAY-PAUSE!";
-                    ButtonPlayPause_ContactDown(null, null);
-                    break;
-                default:
-                    break;
+                        usercontrolInfoUser.LabelSession.Content = "CONTACT TABLE/DANSEUR!";
+                        break;
+                    case "PLAY-PAUSE":
+                        usercontrolInfoUser.LabelSession.Content = "PLAY-PAUSE!";
+                        ButtonPlayPause_ContactDown(null, null);
+                        break;
+                    default:
+                        return;
+                }
+                if (!e.Gesture.Name.Equals("PLAY-PAUSE"))
+                    if (NewGestureRegognized != null)
+                        NewGestureRegognized(this, e);
             }
+            catch { }
         }
         #endregion
 
@@ -380,28 +386,37 @@
 
         }
 
+        public void ApplyColor(List<Color> colors)
+        {
+            try
+            {
+                for (int i = 1; i <= colors.Count; i++)
+                    displayStackPanelAnnotations(i, new SolidColorBrush(colors[i - 1]));
+            }
+            catch { }
+        }
+
         //This function Sets a brush in a specific rectangle of the StackPanelAnnotation
         public void displayStackPanelAnnotations(int id, Brush brushAnnotation)
         {
-            Object o = null;
+            rect1.Fill = new SolidColorBrush(Colors.Black);
+            rect2.Fill = new SolidColorBrush(Colors.Black);
+            rect3.Fill = new SolidColorBrush(Colors.Black);
+            rect4.Fill = new SolidColorBrush(Colors.Black);
+
             switch (id)
             {
                 case 1: 
                     rect1.Fill = brushAnnotation;
-                    o = rect1.FindResource("Rect1Annotation");
-                    rect1.BeginStoryboard((Storyboard)o);
                     break;
-                case 2: rect2.Fill = brushAnnotation;
-                    o = rect2.FindResource("Rect2Annotation");
-                    rect2.BeginStoryboard((Storyboard)o);
+                case 2: 
+                    rect2.Fill = brushAnnotation;
                     break;
-                case 3: rect3.Fill = brushAnnotation;
-                    o = rect3.FindResource("Rect3Annotation");
-                    rect3.BeginStoryboard((Storyboard)o);
+                case 3: 
+                    rect3.Fill = brushAnnotation;
                     break;
-                case 4: rect4.Fill = brushAnnotation;
-                    o = rect4.FindResource("Rect4Annotation");
-                    rect4.BeginStoryboard((Storyboard)o);
+                case 4: 
+                    rect4.Fill = brushAnnotation;
                     break;
                 default: break;
             }
--- a/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/FingersDance.Control.SyncSource.csproj	Fri Nov 13 20:10:00 2009 +0100
@@ -132,6 +132,10 @@
     <Resource Include="Resources\WindowBackground.jpg" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\FingersDance.ActionFactory\FingersDance.Factory.csproj">
+      <Project>{C7B905EA-0678-4DA0-8EF8-7F9CBD22818E}</Project>
+      <Name>FingersDance.Factory</Name>
+    </ProjectReference>
     <ProjectReference Include="..\FingersDance.Control.Player\FingersDance.Control.Player.csproj">
       <Project>{D5625AA4-362F-4E46-9916-65F3B173ECBE}</Project>
       <Name>FingersDance.Control.Player</Name>
@@ -145,5 +149,8 @@
       <Name>FingersDance.Data</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <WCFMetadata Include="Service References\" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -9,6 +9,7 @@
 using System.Windows.Navigation;
 using FingersDance.Control.TimeLine;
 using FingersDance.Data;
+using FingersDance.Factory;
 
 namespace FingersDance.Control.SyncSource
 {
@@ -31,10 +32,33 @@
             //Initialisation du Timer
             UCTimeLine.initTimer(col, cut);
             this.UserControlPlayer.playerPlay();
-            this.userControlTimeLine.OnSuccessAnnotation+=new EventHandler(userControlTimeLine_OnSuccessAnnotation);
+            this.userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation);
+            this.userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded);
+            this.userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved);
             this.UserControlPlayer.PlayerStopOrPause +=new EventHandler(UserControlPlayer_PlayerStopOrPause);
         }
 
+        void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e)
+        {
+            try
+            {
+                DataDictionary Data = (new DataFactory()).Data;
+                Data.RemoveAnnotation((Annotation)sender);
+            }
+            catch { }
+        }
+
+        //  Ajout Annotation
+        void userControlTimeLine_AnnotationAdded(object sender, EventArgs e)
+        {
+            try
+            {
+                DataDictionary Data = (new DataFactory()).Data;
+                Data.AddAnnotation((Annotation)sender);
+            }
+            catch { }
+        }
+
         #region player
         private void UserControlPlayer_PlayerOpened(object sender, EventArgs e)
         {
@@ -45,12 +69,6 @@
 
         }
 
-        //Set a bursh color to the stack panel in the Player
-        public void UserControlPlayer_DisplayAnnotation(int id, Brush b)
-        {
-            UserControlPlayer.displayStackPanelAnnotations(id, b);
-
-        }
         public void UserControlPlayer_PlayerStopOrPause(object sender, EventArgs e)
         {
             try
@@ -105,18 +123,20 @@
             {
                 UCTimeLine.Slider.Value = UserControlPlayer.Player.Position.TotalMilliseconds;
             }
+            int SliderValue = (int)UCTimeLine.Slider.Value;
             if (UCTimeLine.FinishedDragging)
             {
-                int SliderValue = (int)UCTimeLine.Slider.Value;
                 TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue);
 
                 UserControlPlayer.Player.Position = ts;
                 UserControlPlayer.playerPlay();
-                UserControlPlayer.Time = SliderValue;
+                UserControlPlayer.Time = (float)SliderValue / 1000;
 
                 UCTimeLine.IsDragging = false;
                 UCTimeLine.FinishedDragging = false;
             }
+            DataDictionary Data = (new DataFactory()).Data;
+            UserControlPlayer.ApplyColor(Data.GetColors((int)((float)SliderValue / 1000)));
         }
         #endregion
 
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -33,6 +33,8 @@
         public event EventHandler DragStarted;
         public event EventHandler DragCompleted;
         public event EventHandler TimerTick;
+        public event EventHandler AnnotationAdded;
+        public event EventHandler AnnotationRemoved;
         //SAR
         public event EventHandler OnSuccessAnnotation;
         //ENDSAR
@@ -281,8 +283,11 @@
                 // If everything's fine, we create the new one
                 if (annotOk == true)
                 {
-                    cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), avm.TcBegin, avm.Dur, avm.GestureType, avm.Color));
+                    Annotation annotation = new Annotation("s_" + System.Guid.NewGuid(), avm.TcBegin, avm.Dur, avm.GestureType, avm.Color);
+                    cut.AnnotList.Add(annotation);
                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
+                    if (AnnotationAdded != null)
+                        AnnotationAdded(annotation, null);
                     AnnotWaiting = false;
                 }
 
@@ -313,7 +318,8 @@
                 // if not, we mark the beginning
                 if (annotOk == true)
                 {
-                    cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, 0, gestureType, CurrentColor));
+                    cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, 0, cut.AnnotList.Count.ToString(), CurrentColor));
+                    cut.AnnotList.Add(annotation);
                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
                     AnnotWaiting = true;
                 }
@@ -338,10 +344,13 @@
                 if (annotOk == true)
                 {
                     cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1);
-                    cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, currentDuration, gestureType, CurrentColor));
+                    Annotation annotation = new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, currentDuration, gestureType, CurrentColor);
+                    cut.AnnotList.Add(annotation);
                     //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth)));
                     tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX);
                     AnnotWaiting = false;
+                    if (AnnotationAdded != null)
+                        AnnotationAdded(annotation, null);
                 }
                 //Raise Event to display Annotation in all Openned UserPanels
                 if (annotOk)
@@ -447,6 +456,8 @@
                         // We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified
                         confirmCancelPopup.Visibility = Visibility.Hidden;
                         canceledAnnotationVM = null;
+                        if (AnnotationRemoved != null)
+                            AnnotationRemoved(a, null);
                         return;
                     }
                 }
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -186,11 +186,6 @@
         private void UserControlSyncSource_OnSuccessAnnotation(object sender, EventArgs e)
         {
             OnSuccessAnnotation(this, new EventArgs());
-        }
-
-        public void UserControlSyncSource_DisplayAnnotation(int id, Brush b)
-        {
-            UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b);
         }  
     }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Data/DataDictionary.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Media;
+
+namespace FingersDance.Data
+{
+    public class DataDictionary
+    {
+        Dictionary<int, List<Color>> _Data = new Dictionary<int, List<Color>>();
+
+        public DataDictionary()
+        {
+            if (_Data == null)
+                _Data = new Dictionary<int, List<Color>>();
+        }
+
+        public void AddAnnotation(Annotation annotation)
+        {
+            try
+            {
+                //  Recherche de l'élément qui précède le TC de début
+                List<Color> temp = new List<Color>();
+                int value = 0;
+                for (int i = (int)annotation.TcBegin; i >= 0; i--)
+                    if (_Data.ContainsKey(i))
+                    {
+                        value = i;
+                        i = -1;
+                    }
+
+                //  Ajout des couleurs de l'élément qui précède
+                if (!_Data.ContainsKey((int)annotation.TcBegin))
+                {
+                    if (_Data.ContainsKey(value))
+                        foreach (Color elt in _Data[value])
+                            temp.Add(elt);
+                    _Data.Add((int)annotation.TcBegin, temp);
+                }
+
+                //  Ajout de la couleur à tous les éléments entre le début et la fin de l'annotation
+                foreach (KeyValuePair<int, List<Color>> elt in _Data)
+                    if (elt.Key >= (int)annotation.TcBegin && elt.Key < (int)(annotation.TcBegin + annotation.Dur) && !elt.Value.Contains(annotation.Color))
+                        elt.Value.Add(annotation.Color);
+
+                //  Vérification que début et fin correspondent à deux éléments distincts et ajout de la fin de l'annotation si nécessaire (tc de fin inexistant)
+                if (((int)annotation.TcBegin) != ((int)(annotation.TcBegin + annotation.Dur)))
+                {
+                    temp = new List<Color>();
+                    if (!_Data.ContainsKey((int)(annotation.TcBegin + annotation.Dur)))
+                    {
+                        for (int i = (int)(annotation.TcBegin + annotation.Dur); i >= 0; i--)
+                            if (_Data.ContainsKey(i))
+                            {
+                                value = i;
+                                i = -1;
+                            }
+                        if (_Data.ContainsKey(value))
+                            foreach (Color elt in _Data[value])
+                                temp.Add(elt);
+                        temp.Remove(annotation.Color);
+                        _Data.Add((int)(annotation.TcBegin + annotation.Dur), temp);
+                    }
+                }
+                else if (!_Data.ContainsKey((int)(annotation.TcBegin + 1)))
+                {
+                    temp = new List<Color>();
+                    foreach (Color elt in _Data[(int)annotation.TcBegin])
+                        temp.Add(elt);
+                    _Data.Add((int)(annotation.TcBegin + 1), temp);
+                }
+            }
+            catch { }
+        }
+
+        public void RemoveAnnotation(Annotation annotation)
+        {
+            try
+            {
+                //  Suppression de la couleur à tous les éléments entre le début et la fin de l'annotation
+                foreach (KeyValuePair<int, List<Color>> elt in _Data)
+                    if (elt.Key >= (int)annotation.TcBegin && elt.Key < (int)(annotation.TcBegin + annotation.Dur) && elt.Value.Contains(annotation.Color))
+                        elt.Value.Remove(annotation.Color);
+            }
+            catch { }
+        }
+
+        public List<Color> GetColors(int TC)
+        {
+            try
+            {
+                for (int i = TC; i >= 0; i--)
+                    if (_Data.ContainsKey(i))
+                        return _Data[i];
+                return new List<Color>();
+            }
+            catch (Exception)
+            {
+                return new List<Color>();
+            }
+        }
+    }
+}
--- a/src/FingersDance.Data/FingersDance.Data.csproj	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance.Data/FingersDance.Data.csproj	Fri Nov 13 20:10:00 2009 +0100
@@ -3,7 +3,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -57,6 +57,7 @@
   <ItemGroup>
     <Compile Include="Annotation.cs" />
     <Compile Include="Cutting.cs" />
+    <Compile Include="DataDictionary.cs" />
     <Compile Include="Project.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <EmbeddedResource Include="Properties\Resources.resx">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.GestureControl/Nouveau document texte.txt	Fri Nov 13 20:10:00 2009 +0100
@@ -0,0 +1,577 @@
+for (int i = 0; i < list.Count - 1; i++)
+            {
+                if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UP && lastDirection != SurfaceGestureVectorDirection.UP)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.UP;
+                }
+                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWN && lastDirection != SurfaceGestureVectorDirection.DOWN)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.DOWN;
+                }
+                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.UPLEFT;
+                }
+                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.UPRIGHT;
+                }
+                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.DOWNLEFT;
+                }
+                else if (GetHorizontal(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.LEFT && lastDirection != SurfaceGestureVectorDirection.LEFT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.LEFT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.RIGHT && lastDirection != SurfaceGestureVectorDirection.RIGHT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = (Math.Abs(LastChange.X - list[i + 1].X)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.RIGHT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPLEFT && lastDirection != SurfaceGestureVectorDirection.UPLEFT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.UPLEFT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.UPRIGHT && lastDirection != SurfaceGestureVectorDirection.UPRIGHT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.UPRIGHT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNLEFT && lastDirection != SurfaceGestureVectorDirection.DOWNLEFT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.DOWNLEFT;
+                }
+                else if (GetVertical(list[lastPoint], list[i + 1]) == SurfaceGestureVectorDirection.DOWNRIGHT && lastDirection != SurfaceGestureVectorDirection.DOWNRIGHT)
+                {
+                    this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = (Math.Abs(LastChange.Y - list[i + 1].Y)), Origin = list[lastPoint] });
+                    LastChange = list[i + 1];
+                    lastDirection = SurfaceGestureVectorDirection.DOWNRIGHT;
+                }
+                ++lastPoint;
+            }
+
+            //  Analyse des extrémités de la gesture
+            /*
+
+            double diffX = Math.Abs(list[0].X - list[list.Count - 1].X);
+            double diffY = Math.Abs(list[0].Y - list[list.Count - 1].Y);
+
+            if (diffX < 10 && diffY > 10)
+            {
+                this.Clear();
+                if (up > down)
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up });
+                else
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down });
+            }
+            else if (diffY < 10 && diffX > 10)
+            {
+                this.Clear();
+                if (left > right)
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left });
+                else
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right });
+            }
+
+            */
+
+            //  Analyse détaillée de la gesture
+
+            List<SurfaceGestureVector> ThisTemp = new List<SurfaceGestureVector>();
+            List<SurfaceGestureVector> temp = new List<SurfaceGestureVector>();
+            List<SurfaceGestureVector> Tempo = new List<SurfaceGestureVector>();
+
+            if ((this.Count / 10) >= 1)
+            {
+                /*
+                for (int i = 1; i < this.Count + 1; i++)
+                {
+                    temp.Add(this[i-1]);
+                    if (i % 7 == 0)
+                    {
+                        SurfaceGestureVector result = Analyse(temp);
+                        if (ThisTemp.Count == 0 || !ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction))
+                            ThisTemp.Add(result);
+                        else
+                            ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght;
+                        temp.Clear();
+                    }
+                }
+                if (temp.Count > 0)
+                {
+                    SurfaceGestureVector result = Analyse(temp);
+                    if (ThisTemp[ThisTemp.Count - 1].Direction.Equals(result.Direction))
+                        ThisTemp[ThisTemp.Count - 1].Lenght += result.Lenght;
+                    else
+                        ThisTemp.Add(result);
+                    temp.Clear();
+                }
+                this.Clear();
+                foreach(SurfaceGestureVector elt in ThisTemp)
+                    this.Add(elt);
+                 */
+                switch (this.Count / 10)
+                {
+                    case 1:
+                        ThisTemp.Add(Analyse(this));
+                        this.Clear();
+                        if (ThisTemp.Count > 1)
+                        {
+                            double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+                            foreach (SurfaceGestureVector elt in ThisTemp)
+                            {
+                                switch (elt.Direction)
+                                {
+                                    case SurfaceGestureVectorDirection.DOWN:
+                                        down += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.DOWNLEFT:
+                                        downleft += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.DOWNRIGHT:
+                                        downright += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.LEFT:
+                                        left += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.RIGHT:
+                                        right += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.UP:
+                                        up += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.UPLEFT:
+                                        upleft += elt.Lenght;
+                                        break;
+                                    case SurfaceGestureVectorDirection.UPRIGHT:
+                                        upright += elt.Lenght;
+                                        break;
+                                    default:
+                                        break;
+                                }
+                            }
+                            if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
+                            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                                this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
+                        }
+                        else
+                            this.Add(ThisTemp[0]);
+                        break;
+                    case 2:
+                        for (int index = 1; index <= this.Count; index++)
+                        {
+                            if (index == this.Count / 2 || index == this.Count)
+                            {
+                                ThisTemp.Add(Analyse(temp));
+                                if (ThisTemp.Count > 1)
+                                {
+                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+                                    foreach (SurfaceGestureVector elt in ThisTemp)
+                                    {
+
+                                        switch (elt.Direction)
+                                        {
+                                            case SurfaceGestureVectorDirection.DOWN:
+                                                down += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNLEFT:
+                                                downleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
+                                                downright += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.LEFT:
+                                                left += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.RIGHT:
+                                                right += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UP:
+                                                up += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPLEFT:
+                                                upleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPRIGHT:
+                                                upright += elt.Lenght;
+                                                break;
+                                        }
+                                    }
+                                    if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
+                                }
+                                else
+                                    Tempo.Add(ThisTemp[0]);
+                            }
+                            else
+                                ThisTemp.Add(this[index]);
+                        }
+                        this.Clear();
+                        if (Tempo[0].Direction.Equals(Tempo[1].Direction))
+                            this.Add(Tempo[0]);
+                        else
+                            foreach (SurfaceGestureVector elt in Tempo)
+                                this.Add(elt);
+                        break;
+                    case 3:
+                        for (int index = 1; index <= this.Count; index++)
+                        {
+                            if (index == this.Count / 3 || index == this.Count)
+                            {
+                                ThisTemp.Add(Analyse(temp));
+                                if (ThisTemp.Count > 1)
+                                {
+                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+                                    foreach (SurfaceGestureVector elt in ThisTemp)
+                                    {
+
+                                        switch (elt.Direction)
+                                        {
+                                            case SurfaceGestureVectorDirection.DOWN:
+                                                down += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNLEFT:
+                                                downleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
+                                                downright += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.LEFT:
+                                                left += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.RIGHT:
+                                                right += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UP:
+                                                up += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPLEFT:
+                                                upleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPRIGHT:
+                                                upright += elt.Lenght;
+                                                break;
+                                        }
+                                    }
+                                    if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
+                                }
+                                else
+                                    Tempo.Add(ThisTemp[0]);
+                            }
+                            else
+                                ThisTemp.Add(this[index]);
+                        }
+                        this.Clear();
+                        if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction))
+                            this.Add(Tempo[0]);
+                        else
+                            foreach (SurfaceGestureVector elt in Tempo)
+                                this.Add(elt);
+                        break;
+                    default:
+                        for (int index = 1; index <= this.Count; index++)
+                        {
+                            if (index == this.Count / 4 || index == this.Count)
+                            {
+                                ThisTemp.Add(Analyse(temp));
+                                if (ThisTemp.Count > 1)
+                                {
+                                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+                                    foreach (SurfaceGestureVector elt in ThisTemp)
+                                    {
+
+                                        switch (elt.Direction)
+                                        {
+                                            case SurfaceGestureVectorDirection.DOWN:
+                                                down += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNLEFT:
+                                                downleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.DOWNRIGHT:
+                                                downright += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.LEFT:
+                                                left += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.RIGHT:
+                                                right += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UP:
+                                                up += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPLEFT:
+                                                upleft += elt.Lenght;
+                                                break;
+                                            case SurfaceGestureVectorDirection.UPRIGHT:
+                                                upright += elt.Lenght;
+                                                break;
+                                        }
+                                    }
+                                    if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
+                                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                                        Tempo.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
+                                }
+                                else
+                                    Tempo.Add(ThisTemp[0]);
+                            }
+                            else
+                                ThisTemp.Add(this[index]);
+                        }
+                        this.Clear();
+                        if (Tempo[0].Direction.Equals(Tempo[1].Direction) && Tempo[0].Direction.Equals(Tempo[2].Direction) && Tempo[0].Direction.Equals(Tempo[3].Direction))
+                            this.Add(Tempo[0]);
+                        else
+                            foreach (SurfaceGestureVector elt in Tempo)
+                                this.Add(elt);
+                        break;
+                }
+            }
+            else
+            {
+                ThisTemp.Add(Analyse(this));
+                this.Clear();
+                if (ThisTemp.Count > 1)
+                {
+                    double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+                    foreach (SurfaceGestureVector elt in ThisTemp)
+                    {
+
+                        switch (elt.Direction)
+                        {
+                            case SurfaceGestureVectorDirection.DOWN:
+                                down += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.DOWNLEFT:
+                                downleft += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.DOWNRIGHT:
+                                downright += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.LEFT:
+                                left += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.RIGHT:
+                                right += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.UP:
+                                up += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.UPLEFT:
+                                upleft += elt.Lenght;
+                                break;
+                            case SurfaceGestureVectorDirection.UPRIGHT:
+                                upright += elt.Lenght;
+                                break;
+                        }
+                    }
+                    if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = null });
+                    else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                        this.Add(new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = null });
+                }
+                else
+                    this.Add(ThisTemp[0]);
+            }
+        }
+
+        private SurfaceGestureVector Analyse(List<SurfaceGestureVector> list)
+        {
+            //  Analyse de la forme
+            if (list.Count == 1)
+                return list[0];
+            double up = 0, down = 0, left = 0, right = 0, upleft = 0, upright = 0, downleft = 0, downright = 0;
+            foreach (SurfaceGestureVector elt in list)
+            {
+
+                switch (elt.Direction)
+                {
+                    case SurfaceGestureVectorDirection.DOWN:
+                        down += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.DOWNLEFT:
+                        downleft += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.DOWNRIGHT:
+                        downright += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.LEFT:
+                        left += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.RIGHT:
+                        right += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.UP:
+                        up += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.UPLEFT:
+                        upleft += elt.Lenght;
+                        break;
+                    case SurfaceGestureVectorDirection.UPRIGHT:
+                        upright += elt.Lenght;
+                        break;
+                }
+            }
+            /*
+            //double cupleft = 0, cupright = 0, cdownleft = 0, cdownright = 0;
+
+            
+            if (list.Count > 2)
+            {
+                double min = 180;
+                for (int i = 1; i < list.Count - 2; i++)
+                {
+                    double a = GetDistancePoints(list[list.Count - 1].Origin, list[0].Origin);
+                    double b = GetDistancePoints(list[i].Origin, list[0].Origin);
+                    double c = GetDistancePoints(list[i].Origin, list[list.Count - 1].Origin);
+                    double angle = 180 * (Math.Acos((b * b + c * c - a * a) / (2 * b * c))) / Math.PI ;
+                    min = Math.Min(angle > 0 ? angle : 180, min);
+                }
+                if(min<130)
+                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = up, Origin = list[0].Origin };
+            }
+
+            if (up < 4 && upleft < 4 && upright < 4 && down < 4 && downleft < 4 && downright < 4 && right < 4 && left < 4)
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 };
+            if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(up))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upleft))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(upright))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(down))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downleft))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(downright))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNRIGHT, Lenght = downright, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(left))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin };
+            else if (Math.Max(up, Math.Max(upleft, Math.Max(upright, Math.Max(down, Math.Max(downleft, Math.Max(left, Math.Max(downright, right))))))).Equals(right))
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin };
+            else
+                return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.NONE, Lenght = 0, Origin = list[0].Origin });
+             */
+
+            double diffX = Math.Abs(list[0].Origin.X - list[list.Count - 1].Origin.X);
+            double diffY = Math.Abs(list[0].Origin.Y - list[list.Count - 1].Origin.Y);
+
+            if (diffX < 10 && diffY > 10)
+            {
+                if (list[0].Origin.Y > list[list.Count - 1].Origin.Y)
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UP, Lenght = up, Origin = list[0].Origin });
+                else
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWN, Lenght = down, Origin = list[0].Origin });
+            }
+            else if (diffY < 10 && diffX > 10)
+            {
+                if (list[list.Count - 1].Origin.X > list[0].Origin.X)
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.LEFT, Lenght = left, Origin = list[0].Origin });
+                else
+                    return (new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.RIGHT, Lenght = right, Origin = list[0].Origin });
+            }
+            else if (diffX > 10 && diffY > 10)
+            {
+                if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X)
+                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPLEFT, Lenght = upleft, Origin = list[0].Origin };
+                else if (list[0].Origin.Y > list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X < list[0].Origin.X)
+                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
+                else if (list[0].Origin.Y < list[list.Count - 1].Origin.Y && list[list.Count - 1].Origin.X > list[0].Origin.X)
+                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.DOWNLEFT, Lenght = downleft, Origin = list[0].Origin };
+                else
+                    return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.UPRIGHT, Lenght = upright, Origin = list[0].Origin };
+            }
+            else
+                return new SurfaceGestureVector { Direction = SurfaceGestureVectorDirection.TAP, Lenght = 0 };
\ No newline at end of file
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Fri Nov 13 11:58:42 2009 +0100
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Fri Nov 13 20:10:00 2009 +0100
@@ -524,23 +524,8 @@
         //On success annotation Display annotations in the different Panels
         private void Panel_OnSuccessAnnotation(object sender, EventArgs e)
         {
-            UserControlUserPanel PanelAnnotation = (UserControlUserPanel)sender;
-            int idUser = PanelAnnotation.id;
-            //Get Color Of User
-            Brush brushAnnot = new SolidColorBrush((new ColorFactory()).Colors[PanelAnnotation.idcolor]);
-            //set Color to All Panels
-            if(Panel1!=null)
-                Panel1.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
-            if (Panel2 != null)
-                Panel2.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
-            if (Panel3 != null)
-                Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
-            if (Panel4 != null)
-                Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
-
             // We save datas
             saveDatas();
-
         }
 
         //