void GestureCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { #if DEBUG var debug_resultsQuery = e.GetGestureRecognitionResults() .Where(r => r.ApplicationGesture != ApplicationGesture.NoGesture); foreach (var r in debug_resultsQuery) { Debug.WriteLine("{0}: {1}", r.ApplicationGesture, r.RecognitionConfidence); } Debug.WriteLine(""); #endif // 信頼性 (RecognitionConfidence) を無視したほうが、Circle と Triangle の認識率は上がるようです。 var gestureResult = e.GetGestureRecognitionResults() .FirstOrDefault(r => r.ApplicationGesture != ApplicationGesture.NoGesture); if (gestureResult == null) { wavesPlayer.Play(AnswerResult.None.ToString()); return; } AnswerResult answerResult; switch (gestureResult.ApplicationGesture) { case ApplicationGesture.Circle: case ApplicationGesture.DoubleCircle: answerResult = AnswerResult.Correct; break; case ApplicationGesture.Triangle: answerResult = AnswerResult.Intermediate; break; case ApplicationGesture.Check: case ApplicationGesture.ArrowDown: case ApplicationGesture.ChevronDown: case ApplicationGesture.DownUp: case ApplicationGesture.Up: case ApplicationGesture.Down: case ApplicationGesture.Left: case ApplicationGesture.Right: case ApplicationGesture.Curlicue: case ApplicationGesture.DoubleCurlicue: answerResult = AnswerResult.Incorrect; break; default: throw new InvalidOperationException(); } wavesPlayer.Play(answerResult.ToString()); var gestureCanvas = (InkCanvas)sender; var question = (Question)gestureCanvas.DataContext; question.Result = answerResult; gestureCanvas.Strokes.Clear(); gestureCanvas.Strokes.Add(e.Strokes); }
private void InkCanvas_OnGesture(object sender, InkCanvasGestureEventArgs e) { var recognitionResults = e.GetGestureRecognitionResults(); this.ArgsBox.Items.Insert(0, string.Format("recieved gesture: {0}", recognitionResults.Count)); foreach (var gestureRecognitionResult in recognitionResults) { string gesture = string.Format("{0} confidence: {1}", gestureRecognitionResult.ApplicationGesture, gestureRecognitionResult.RecognitionConfidence); this.ArgsBox.Items.Insert(0, gesture); } }
protected override void OnGesture(InkCanvasGestureEventArgs e) { GestureRecognitionResult Result = e.GetGestureRecognitionResults()[0]; if (Result.ApplicationGesture != ApplicationGesture.NoGesture && Result.RecognitionConfidence <= Confidence) { if (this.Gesture != null) { Gesture(Result.ApplicationGesture); } } }
private void InkLayer_Gesture(object sender, InkCanvasGestureEventArgs e) { var gestures = e.GetGestureRecognitionResults(); var recognized = false; e.Cancel = true; e.Handled = true; // Gesture recognition var gestureBounds = e.Strokes.GetBounds(); var position = new Point(gestureBounds.X + (gestureBounds.Width/2), gestureBounds.Y + (gestureBounds.Height/2)); var layerStack = (InkLayer.Tag as ViewModels.Controls.LayerStack); var layer = (InkLayer.DataContext as ViewModels.Controls.Layer); var i = 0; var maxSearch = 2; while (!recognized && i <= maxSearch && i < gestures.Count) { var gesture = gestures[i].ApplicationGesture; var confidence = gestures[i].RecognitionConfidence; // If the user is a Teacher on the QuestionsPage + Square/Circle => CheckBox/RadioButton if (IsBulletQuestionLayer() && gestureBounds.Width > 20 && gestureBounds.Width < 90 && confidence == RecognitionConfidence.Strong && (gesture == ApplicationGesture.Square || gesture == ApplicationGesture.Circle)) { // Add Bullet if recognize as Square or Circle layerStack.AddNewBullet(position); // Remove the Stroke for this gesture recognized = true; e.Cancel = false; e.Handled = false; } // Square => TextBox else if (!IsQuestionPage() && gestureBounds.Width > 120 && confidence == RecognitionConfidence.Strong && gesture == ApplicationGesture.Square) { // Add Bullet if recognize as Square or Circle layerStack.AddNewTextBox(position); // Remove the Stroke for this gesture recognized = true; e.Cancel = false; e.Handled = false; } i++; } }
private void _onGestureRecognition(object sender, InkCanvasGestureEventArgs e) { var results = e.GetGestureRecognitionResults(); if (results.Count == 0 || results[0].RecognitionConfidence != RecognitionConfidence.Strong) return; var gesture = results[0].ApplicationGesture; var bounds = e.Strokes.GetBounds(); TouchGestureEventArgs args = null; if (_systemGestures.Contains(gesture)) { args = new TouchGestureEventArgs(TouchSurface.SystemGestureRecognizedEvent, gesture, e.Strokes, bounds); } else if (_componentGestures.Contains(gesture)) { args = new TouchGestureEventArgs(TouchSurface.ComponentGestureRecognizedEvent, gesture, e.Strokes, bounds); } if (args != null) { RaiseEvent(args); if (args.Handled && FeedbackDuration > TimeSpan.Zero) { _inkCanvas.DrawGesture(gesture, FeedbackAttributes, bounds); GuiTimer.StartAfter(FeedbackDuration, t => _inkCanvas.Children.Clear()); } } }
private void inkCanvas_Gesture_1(object sender, InkCanvasGestureEventArgs e) { }
protected virtual new void OnGesture(InkCanvasGestureEventArgs e) { }
void OnGesture(object sender, InkCanvasGestureEventArgs e) { ApplicationGesture topGesture = e.GetGestureRecognitionResults()[0].ApplicationGesture; if (topGesture == ApplicationGesture.ScratchOut) { StrokeCollection strokesToDelete = myInkCanvas.Strokes.HitTest(e.Strokes.GetBounds(), 1); myInkCanvas.Strokes.Remove(strokesToDelete); } else { e.Cancel = true; } }
private void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { try { StrokeCollection collection = e.Strokes; StylusPointCollection points = collection[0].StylusPoints; while (points.Count < MAXSIZE) { var prev = points[points.Count - 2]; var last = points[points.Count - 1]; double diffX = last.X - prev.X; double diffY = last.Y - prev.Y; double newX = diffX + last.X; double newY = diffY + last.Y; points.Add(new StylusPoint(newX, newY)); } if (!testMode) { int t = Int32.Parse(TargetTextBox.Text); data.Add(new MyNumber(points, t)); updateTargetsLabel(); Counter++; } else { testInputX = "testInputX=["; testInputY = "testInputY=["; testInputP = "testInputP=["; for (int i = 0; i < points.Count; i++) { testInputX += points[i].X + " ;"; testInputY += points[i].Y + " ;"; testInputP += points[i].PressureFactor + " ;"; } testInputX = testInputX.Remove(testInputX.Length - 1, 1) + "];"; testInputY = testInputY.Remove(testInputY.Length - 1, 1) + "];"; testInputP = testInputP.Remove(testInputP.Length - 1, 1) + "];"; StreamWriter swx = new StreamWriter("XTest.txt"); StreamWriter swy = new StreamWriter("YTest.txt"); StreamWriter swp = new StreamWriter("PTest.txt"); swx.WriteLine(testInputX); swy.WriteLine(testInputY); swp.WriteLine(testInputP); swp.Close(); swx.Close(); swy.Close(); SimulateButton_Click(null, null); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } //MessageBox.Show("Ok Data Wrote ..."); }
void TouchCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { GestureRecognitionResult recognitionResult = e.GetGestureRecognitionResults().FirstOrDefault(); if (recognitionResult != null && recognitionResult.RecognitionConfidence == RecognitionConfidence.Strong && recognitionResult.ApplicationGesture == ApplicationGesture.ScratchOut) Strokes.Clear(); }
private void PointerCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { e.Handled = true; e.Cancel = true; }