/// <summary> /// called when a gesture is detected, we use this to detect a scratchout gesture /// and erase strokes /// </summary> protected override void OnGesture(InkCanvasGestureEventArgs e) { base.OnGesture(e); ReadOnlyCollection <GestureRecognitionResult> results = e.GetGestureRecognitionResults(); if (results.Count > 0 && results[0].ApplicationGesture == ApplicationGesture.ScratchOut && results[0].RecognitionConfidence == RecognitionConfidence.Strong) { //hit test the InkAnalysisCanvas's Strokes StrokeCollection hitStrokes = this.Strokes.HitTest(e.Strokes.GetBounds(), 1 /*percent*/); //remove any hit strokes from the InkAnalysisCanvas if (hitStrokes.Count > 0) { //OnStrokesChanged will be called after this and //remove the erased strokes from the InkAnalyzer this.Strokes.Remove(hitStrokes); } e.Cancel = false; } else { //cancel the event, it wasn't a scratchout e.Cancel = true; } }
//<Snippet1> void inkCanvas1_Gesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection <GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); // Check the first recognition result for a gesture. if (gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong) { switch (gestureResults[0].ApplicationGesture) { case ApplicationGesture.Down: // Do something. break; case ApplicationGesture.ArrowDown: // Do something. break; case ApplicationGesture.Circle: // Do something. break; } } }
private static void InkCanvasGestureHandler(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection <GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); if (gestureResults[0].RecognitionConfidence != RecognitionConfidence.Poor) { switch (gestureResults[0].ApplicationGesture) { case ApplicationGesture.ChevronUp: m_Window.m_Translate.Y += TranslateY; break; case ApplicationGesture.ChevronDown: m_Window.m_Translate.Y -= TranslateY; break; case ApplicationGesture.ChevronLeft: m_Window.m_Translate.X += TranslateX; break; case ApplicationGesture.ChevronRight: m_Window.m_Translate.X -= TranslateX; break; case ApplicationGesture.Check: m_RecognitionModeIsHandwriting = !m_RecognitionModeIsHandwriting; break; } } }
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 INK_Gesture(object sender, InkCanvasGestureEventArgs e) { string s = string.Empty; foreach (var res in e.GetGestureRecognitionResults()) { s += res.ApplicationGesture.ToString() + "; "; } Guest.Name = s; }
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 inkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { String gestures = ""; // Выборка "предпологаемых" гестур. foreach (GestureRecognitionResult res in e.GetGestureRecognitionResults()) { gestures += res.ApplicationGesture.ToString() + "; "; } // Отображаем название гестуры. gestureName.Text = gestures; }
private void InkCanvas_OnGesture(object sender, InkCanvasGestureEventArgs e) { var recognitionResults = e.GetGestureRecognitionResults(); this.ArgsBox.Items.Insert(0, $"recieved gesture: {recognitionResults.Count}"); foreach (var gestureRecognitionResult in recognitionResults) { string gesture = $"{gestureRecognitionResult.ApplicationGesture} confidence: {gestureRecognitionResult.RecognitionConfidence}"; this.ArgsBox.Items.Insert(0, gesture); } }
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 HandleInkCanvasGesture(object sender, InkCanvasGestureEventArgs e) { System.Collections.ObjectModel.ReadOnlyCollection <GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); System.Windows.Ink.RecognitionConfidence?lowestConfidence = null; System.Windows.Ink.ApplicationGesture? applicationGesture = null; foreach (GestureRecognitionResult gestureResult in gestureResults) { if (lowestConfidence == null || gestureResult.RecognitionConfidence < lowestConfidence) { lowestConfidence = gestureResult.RecognitionConfidence; applicationGesture = gestureResult.ApplicationGesture; } } switch (applicationGesture) { case System.Windows.Ink.ApplicationGesture.Right: if (this.PreviousPageCommand.CanExecute(null)) { this.PreviousPageCommand.Execute(null); } break; case System.Windows.Ink.ApplicationGesture.Left: if (this.NextPageCommand.CanExecute(null)) { this.NextPageCommand.Execute(null); } break; case System.Windows.Ink.ApplicationGesture.Check: this.AutoScale(); break; default: break; } }
void inkCanvas1_Gesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection <GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); // Check the first recognition result for a gesture. if ((gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong) && (gestureResults[0].ApplicationGesture == ApplicationGesture.ScratchOut)) { StrokeCollection hitStrokes = inkCanvas1.Strokes.HitTest( e.Strokes.GetBounds(), 10); if (hitStrokes.Count > 0) { inkCanvas1.Strokes.Remove(hitStrokes); } } }
/// <summary> /// This is the InkCanvas gesture event handler. Here certain gestures are received /// and acted upon accordingly. /// </summary> void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { GestureRecognitionResult topResult = e.GetGestureRecognitionResults()[0]; if (topResult.RecognitionConfidence == RecognitionConfidence.Strong) { ApplicationGesture gesture = topResult.ApplicationGesture; switch (gesture) { case ApplicationGesture.ScratchOut: StrokeCollection strokesToRemove = myInkCanvas.Strokes.HitTest(e.Strokes.GetBounds(), 10); if (strokesToRemove.Count > 0) { myInkCanvas.Strokes.Remove(strokesToRemove); } break; case ApplicationGesture.Right: myScrollViewer.ScrollToHorizontalOffset(myScrollViewer.HorizontalOffset + 30); break; case ApplicationGesture.Left: myScrollViewer.ScrollToHorizontalOffset(myScrollViewer.HorizontalOffset - 30); break; case ApplicationGesture.Up: myScrollViewer.ScrollToVerticalOffset(myScrollViewer.VerticalOffset - 30); break; case ApplicationGesture.Down: myScrollViewer.ScrollToVerticalOffset(myScrollViewer.VerticalOffset + 30); break; } } }
private async void inkCanvasBoard_Gesture(object sender, InkCanvasGestureEventArgs e) { bool removeStrokes = true; inkCanvasBoard.Strokes.Add(e.Strokes); await Task.Delay(TimeSpan.FromSeconds(laserDelay)); foreach (Stroke s in e.Strokes) { if (!inkCanvasBoard.Strokes.Contains(s)) { removeStrokes = false; break; } } if (removeStrokes) { inkCanvasBoard.Strokes.Remove(e.Strokes); } }
/// <summary> /// A handler which handles the Gesture events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnInkCanvasGesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection <GestureRecognitionResult> results = e.GetGestureRecognitionResults(); if (results.Count != 0 && results[0].RecognitionConfidence == RecognitionConfidence.Strong) { if (CurrentInkModeOption == OptionId.GestureOnly) { // Show gesture feedback in the GestureOnly mode GestureResultAdorner.ShowMessage(results[0].ApplicationGesture.ToString(), e.Strokes.GetBounds().TopLeft); } else { // In InkAndGesture mode, and if not using highlighter, if a ScratchOut // gesture is detected then remove the underlying strokes if (results[0].ApplicationGesture == ApplicationGesture.ScratchOut && !e.Strokes[0].DrawingAttributes.IsHighlighter) { StrokeCollection strokesToRemove = MyInkCanvas.Strokes.HitTest(e.Strokes.GetBounds(), 10); if (strokesToRemove.Count != 0) { MyInkCanvas.Strokes.Remove(strokesToRemove); } } else { // Otherwise cancel the gesture. e.Cancel = true; } } } else { // Cancel the gesture. 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 ..."); }
private void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { textBox.Text += "InkCanvas_Gesture\n"; }
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 InkCanvasOnGesture(object sender, InkCanvasGestureEventArgs e) { ListBox1.Items.Add(e.GetGestureRecognitionResults()[0].ApplicationGesture); }
private void Gesture(object sender, InkCanvasGestureEventArgs e) { Trace.WriteLine("InkCanvas gestrue."); }
private void canvas_Gesture(object sender, InkCanvasGestureEventArgs e) { }
private void inkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { textBox2.Text = e.GetGestureRecognitionResults()[0].ApplicationGesture.ToString(); inkCanvas.Strokes.Clear(); }
//int ArrowRightGestureCount = 0; //WPFInk.videoSummarization.MySpiral mySpiral; //WPFInk.videoSummarization.SpiralSummarization spiralSummarization; void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection <GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); if (gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong) { switch (gestureResults[0].ApplicationGesture) { case ApplicationGesture.ScratchOut: InkCollector.removeHitStrokes(e.Strokes); //删除笔迹 InkCollector.removeHitImages(e.Strokes); //删除图片 InkCollector.removeHitTextBoxes(e.Strokes); //删除文本 InkCollector.removeHitMyGraphics(e.Strokes); //删除图形 _inkFrame.OperatePieMenu.Visibility = Visibility.Collapsed; //Console.WriteLine("擦除"); break; case ApplicationGesture.Left: if (_inkFrame.InkCollector.CommandStack.Count > 0) { Command cmd = _inkFrame.InkCollector.CommandStack.Pop(); _inkFrame.InkCollector.UndoCommandStack.Push(cmd); cmd.undo(); //Console.WriteLine(_inkFrame.InkCollector.CommandStack.Count); } break; case ApplicationGesture.Right: if (_inkFrame.InkCollector.UndoCommandStack.Count > 0) { Command cmd = _inkFrame.InkCollector.UndoCommandStack.Pop(); _inkFrame.InkCollector.CommandStack.Push(cmd); cmd.execute(); } //Console.WriteLine("反撤销"); break; case ApplicationGesture.Check: foreach (MyStroke myStroke in InkCollector.SelectedStrokes) { DeleteStrokeCommand dsc = new DeleteStrokeCommand(_inkFrame.InkCollector, myStroke); dsc.execute(); } InkCollector.SelectedStrokes.Clear(); if (CheckGestureCount++ < 3) { _inkFrame._imageSelector.Visibility = Visibility.Visible; } else { _inkFrame._peopleImageSelector.Visibility = Visibility.Visible; } //Console.WriteLine("对勾"); break; case ApplicationGesture.Curlicue: //Console.WriteLine("清除文字"); break; case ApplicationGesture.ChevronLeft: //System.Windows.MessageBox.Show("插入行"); Rect ChevronLeftRect = e.Strokes.GetBounds(); Point keyPoint = new Point(ChevronLeftRect.TopLeft.X, ChevronLeftRect.TopLeft.Y + ChevronLeftRect.Height / 2); Rect LeftDownRect = new Rect(new Point(0, keyPoint.Y), new Point(ChevronLeftRect.BottomRight.X, _inkFrame._inkCanvas.ActualHeight)); foreach (MyStroke ms in _inkFrame.InkCollector.Sketch.MyStrokes) { if (MathTool.getInstance().isHitRects(LeftDownRect, ms.Stroke.GetBounds()) == true) { MoveCommand mc = new MoveCommand(ms, 0, 100); mc.execute(); _inkFrame.InkCollector.CommandStack.Push(mc); } } break; case ApplicationGesture.Up: Rect UpRect = e.Strokes.GetBounds(); Rect RightRectUp = new Rect(new Point(UpRect.TopLeft.X, UpRect.TopLeft.Y), new Point(_inkFrame._inkCanvas.ActualWidth, UpRect.BottomLeft.Y)); foreach (MyStroke ms in _inkFrame.InkCollector.Sketch.MyStrokes) { if (MathTool.getInstance().isHitRects(RightRectUp, ms.Stroke.GetBounds()) == true) { MoveCommand mcs = new MoveCommand(ms, 50, 0); mcs.execute(); _inkFrame.InkCollector.CommandStack.Push(mcs); } } break; case ApplicationGesture.Down: Rect DownRect = e.Strokes.GetBounds(); Rect RightRectDown = new Rect(new Point(DownRect.TopLeft.X, DownRect.TopLeft.Y), new Point(_inkFrame._inkCanvas.ActualWidth, DownRect.BottomLeft.Y)); foreach (MyStroke ms in _inkFrame.InkCollector.Sketch.MyStrokes) { if (MathTool.getInstance().isHitRects(RightRectDown, ms.Stroke.GetBounds()) == true) { MoveCommand mcs = new MoveCommand(ms, 50, 0); mcs.execute(); _inkFrame.InkCollector.CommandStack.Push(mcs); } } break; case ApplicationGesture.ArrowRight: //向右箭头 //_inkFrame._inkCanvas.Children.Clear(); ///*测试螺旋式摘要*/ //if (ArrowRightGestureCount == 0) //{ // //mySpiral = new MySpiral(70, new StylusPoint(400, 400), 5, 2, _inkFrame._inkCanvas); // mySpiral = new MySpiral(80, new StylusPoint(_inkFrame._inkCanvas.ActualWidth / 2, _inkFrame._inkCanvas.ActualHeight / 2), 5, 2, _inkFrame._inkCanvas); //} //spiralSummarization = new SpiralSummarization(@"E:\task\idea\螺旋式摘要\麋鹿王1_clip.avi", mySpiral, keyFrames); //InkCollector.SpiralSummarization = spiralSummarization; //InkCollector.Mode = InkMode.SpiralSummarization; //ArrowRightGestureCount++; break; } } }
public void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection<GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); Rect bound = e.Strokes.GetBounds(); System.Drawing.Rectangle rectangleBound = ConvertClass.getInstance().RectToRectangle(bound); if (gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong) { switch (gestureResults[0].ApplicationGesture) { case ApplicationGesture.ScratchOut: foreach (MyButton myButton in _inkFrame.InkCollector.Sketch.MyButtons) { Rect rectMyButton=new Rect(new Point(myButton.Left,myButton.Top),new Point(myButton.Left+myButton.Width,myButton.Top+myButton.Height)); if (MathTool.getInstance().isHitRects(e.Strokes.GetBounds(), rectMyButton) == true) { DeleteButtonCommand dbc = new DeleteButtonCommand(_inkFrame.InkCollector, myButton,_videoList); dbc.execute(); InkCollector.CommandStack.Push(dbc); } } foreach (MyArrow myArrow in _inkFrame.InkCollector.Sketch.MyArrows) { Rect rectMyButton = new Rect(myArrow.StartPoint,myArrow.EndPoint); if (MathTool.getInstance().isHitRects(e.Strokes.GetBounds(), rectMyButton) == true) { Command dac = new DeleteArrowCommand(_inkFrame.InkCollector, myArrow); dac.execute(); InkCollector.CommandStack.Push(dac); } } break; case ApplicationGesture.Down: if (downcount == 1) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[0].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[1].TimeStart); } else if (downcount == 0) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[5].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[6].TimeStart); } else if (downcount == 2) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[6].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[7].TimeStart); InkCollector.Mode = InkMode.VideoPlay; } //else if (downcount == 3) //{ // getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), // (int)_inkFrame.InkCollector.Sketch.MyButtons[8].TimeEnd, // (int)_inkFrame.InkCollector.Sketch.MyButtons[9].TimeStart); //} downcount++; //getKeyFramesInGivenVideoClip(GlobalValues.FilesPath + "/麋鹿王.avi", 0, // 1069000); break; } } }
protected override void OnGesture(InkCanvasGestureEventArgs e) { base.OnGesture(e); }
private void PointerCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { e.Handled = true; e.Cancel = true; }