src/FingersDance.GestureControl/GestureControl.cs
changeset 178 56041bd3761e
parent 176 0896f36b9d57
child 189 b37888f59cf2
--- a/src/FingersDance.GestureControl/GestureControl.cs	Tue Oct 27 10:10:26 2009 +0100
+++ b/src/FingersDance.GestureControl/GestureControl.cs	Wed Oct 28 11:57:38 2009 +0100
@@ -110,37 +110,41 @@
 
         protected void AreaStrokeCollected(object source, RoutedEventArgs e)
         {
-            if (inProgess == null)
+            try
             {
-                inProgess = new Thread(RunCapture);
-                inProgess.Start();
-            }
-            else
-            {
-                inProgess.Abort();
-                inProgess = null;
-                inProgess = new Thread(RunCapture);
-                inProgess.Start();
+                if (inProgess == null)
+                {
+                    inProgess = new Thread(RunCapture);
+                    inProgess.Start();
+                }
+                else
+                {
+                    inProgess.Abort();
+                    inProgess = null;
+                    inProgess = new Thread(RunCapture);
+                    inProgess.Start();
+                }
+                Debug.WriteLine("collected", "Stroke");
+                System.Windows.Controls.InkCanvasStrokeCollectedEventArgs tmp = e as System.Windows.Controls.InkCanvasStrokeCollectedEventArgs;
+                // Apply a rotation with the angle of the first contact
+                Matrix rot = Matrix.Identity;
+                rot.Rotate(-this.angle);
+                Stroke s = tmp.Stroke;
+                s.Transform(rot, true);
+                // Get a list of point from a Bezier curve
+                StylusPointCollection tmp2 = s.GetBezierStylusPoints();
+                // Generate a list of SurfaceGesturePoint, just X and Y but can be improve
+                List<SurfaceGesturePoint> pointList = new List<SurfaceGesturePoint>();
+                foreach (StylusPoint p in tmp2)
+                    pointList.Add(new SurfaceGesturePoint { X = p.X, Y = p.Y });
+                // create the gesture analyser and set the list
+                SurfaceGesture gesture = new SurfaceGesture(pointList, 1);
+                // try to get a pattern from the list, if one, raise a event
+                _Gestures.Add(gesture);
+                SurfaceInkCanvas ink = e.OriginalSource as SurfaceInkCanvas;
+                ink.Strokes.Clear();
             }
-            Debug.WriteLine("collected", "Stroke");
-            System.Windows.Controls.InkCanvasStrokeCollectedEventArgs tmp = e as System.Windows.Controls.InkCanvasStrokeCollectedEventArgs;
-            // Apply a rotation with the angle of the first contact
-            Matrix rot = Matrix.Identity;
-            rot.Rotate(-this.angle);
-            Stroke s = tmp.Stroke;
-            s.Transform(rot, true);
-            // Get a list of point from a Bezier curve
-            StylusPointCollection tmp2 = s.GetBezierStylusPoints();
-            // Generate a list of SurfaceGesturePoint, just X and Y but can be improve
-            List<SurfaceGesturePoint> pointList = new List<SurfaceGesturePoint>();
-            foreach (StylusPoint p in tmp2)
-                pointList.Add(new SurfaceGesturePoint { X = p.X, Y = p.Y });
-            // create the gesture analyser and set the list
-            SurfaceGesture gesture = new SurfaceGesture(pointList, 1);
-            // try to get a pattern from the list, if one, raise a event
-            _Gestures.Add(gesture);
-            SurfaceInkCanvas ink = e.OriginalSource as SurfaceInkCanvas;
-            ink.Strokes.Clear();
+            catch { }
         }
 
         void RunCapture()