src/FingersDance.GestureControl/GestureControl.cs
changeset 189 b37888f59cf2
parent 178 56041bd3761e
child 193 96374d03e714
equal deleted inserted replaced
188:e642ad0c366b 189:b37888f59cf2
   133                 s.Transform(rot, true);
   133                 s.Transform(rot, true);
   134                 // Get a list of point from a Bezier curve
   134                 // Get a list of point from a Bezier curve
   135                 StylusPointCollection tmp2 = s.GetBezierStylusPoints();
   135                 StylusPointCollection tmp2 = s.GetBezierStylusPoints();
   136                 // Generate a list of SurfaceGesturePoint, just X and Y but can be improve
   136                 // Generate a list of SurfaceGesturePoint, just X and Y but can be improve
   137                 List<SurfaceGesturePoint> pointList = new List<SurfaceGesturePoint>();
   137                 List<SurfaceGesturePoint> pointList = new List<SurfaceGesturePoint>();
   138                 foreach (StylusPoint p in tmp2)
   138                 foreach (StylusPoint p in s.StylusPoints)
   139                     pointList.Add(new SurfaceGesturePoint { X = p.X, Y = p.Y });
   139                     pointList.Add(new SurfaceGesturePoint { X = p.X, Y = p.Y });
   140                 // create the gesture analyser and set the list
   140                 // create the gesture analyser and set the list
   141                 SurfaceGesture gesture = new SurfaceGesture(pointList, 1);
   141                 SurfaceGesture gesture = new SurfaceGesture(pointList, 1);
   142                 // try to get a pattern from the list, if one, raise a event
   142                 // try to get a pattern from the list, if one, raise a event
   143                 _Gestures.Add(gesture);
   143                 _Gestures.Add(gesture);
   166                 inProgess = null;
   166                 inProgess = null;
   167             }
   167             }
   168         }
   168         }
   169 
   169 
   170         #region Pattern
   170         #region Pattern
   171         /// <ary>
   171         /// <summary>
   172         /// return a String with the recognized pattern, "None" if no pattern
   172         /// return a String with the recognized pattern, "None" if no pattern
   173         /// </summary>
   173         /// </summary>
   174         /// <returns></returns>
       
   175         public String GetPattern(List<SurfaceGesture> gestures)
   174         public String GetPattern(List<SurfaceGesture> gestures)
   176         {            
   175         {            
   177             int found = 0;
   176             int found = 0;
   178             List<SurfaceGesture> tmp = new List<SurfaceGesture>();
   177             List<SurfaceGesture> tmp = new List<SurfaceGesture>();
   179             foreach (SurfaceGesturePattern p in Pattern)
   178             foreach (SurfaceGesturePattern p in Pattern)
   198                     }
   197                     }
   199                     if (found == p.Count)
   198                     if (found == p.Count)
   200                         return p.Name;
   199                         return p.Name;
   201                 }
   200                 }
   202             }
   201             }
   203 
       
   204             return "None";
   202             return "None";
   205         }
   203         }
   206 
   204 
   207         /// <summary>
   205         /// <summary>
   208         /// Load know patterns from the Resources/Patterns.xml file
   206         /// Load know patterns from the Resources/Patterns.xml file
   260                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.LEFT });
   258                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.LEFT });
   261                                     break;
   259                                     break;
   262                                 case "Right":
   260                                 case "Right":
   263                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.RIGHT });
   261                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.RIGHT });
   264                                     break;
   262                                     break;
   265                                 case "DownRight":
   263                                 case "Downright":
   266                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNRIGHT });
   264                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNRIGHT });
   267                                     break;
   265                                     break;
   268                                 case "DownLeft":
   266                                 case "Downleft":
   269                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNLEFT });
   267                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.DOWNLEFT });
   270                                     break;
   268                                     break;
   271                                 case "UpRight":
   269                                 case "Upright":
   272                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPRIGHT });
   270                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPRIGHT });
   273                                     break;
   271                                     break;
   274                                 case "UpLeft":
   272                                 case "Upleft":
   275                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPLEFT });
   273                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.UPLEFT });
       
   274                                     break;
       
   275                                 case "TAP":
       
   276                                     p.Add(new SurfaceGestureVector() { Direction = SurfaceGestureVectorDirection.TAP });
   276                                     break;
   277                                     break;
   277                                 default:
   278                                 default:
   278                                     break;
   279                                     break;
   279                             }
   280                             }
   280                         }
   281                         }