private void PointerReleased() { var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN, _currentStroke.Points); switch (gesture) { case WritePadAPI.GEST_RETURN: InkCanvas.Children.Remove(_currentStroke); _currentStroke.Points.Clear(); var strokes = (from object child in InkCanvas.Children select child as UIElement).ToList(); var result = RecognizeStrokes(strokes, true); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Text could not be recognized."); result = ""; } RecognizedTextBox.Text = result; return; case WritePadAPI.GEST_CUT: ClearInk(); return; } FinishStrokeDraw(); }
public override void TouchesEnded(MonoTouch.Foundation.NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN, currentStroke); if (!mMoved) { mX++; } AddPixelsXY(mX, mY, true); mCurrStroke = -1; mMoved = false; strokeLen = 0; mPath.AddLineTo(new PointF(mX, mY)); mPathList.Add(mPath); mPath = new UIBezierPath(); mPath.LineWidth = WritePadAPI.DEFAULT_INK_WIDTH; mPath.LineCapStyle = CGLineCap.Round; mPath.LineJoinStyle = CGLineJoin.Round; SetNeedsDisplay(); switch (gesture) { case WritePadAPI.GEST_RETURN: if (OnReturnGesture != null) { mPathList.RemoveAt(mPathList.Count - 1); WritePadAPI.recoDeleteLastStroke(); SetNeedsDisplay(); OnReturnGesture(); } break; case WritePadAPI.GEST_CUT: if (OnCutGesture != null) { mPathList.RemoveAt(mPathList.Count - 1); WritePadAPI.recoDeleteLastStroke(); SetNeedsDisplay(); OnCutGesture(); } break; } }
private void panelCanvas_MouseUp(object sender, MouseEventArgs e) { var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN, polylineList[polylineList.Count - 1]); switch (gesture) { case WritePadAPI.GEST_RETURN: polylineList.RemoveAt(polylineList.Count - 1); Refresh(); var result = RecognizeStrokes(polylineList, true); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Text could not be recognized."); result = ""; } textBox1.Text = result; return; case WritePadAPI.GEST_CUT: ClearInk(); return; } }
public async void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e, Canvas InkCanvas, TextBox RecognizedTextBox) { if (e.Pointer.PointerId != _currentPointerId) { return; } if (e.GetCurrentPoint(null).Properties.PointerUpdateKind == PointerUpdateKind.RightButtonReleased) { return; } var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN, _currentStroke.Points); switch (gesture) { case WritePadAPI.GEST_RETURN: InkCanvas.Children.Remove(_currentStroke); _currentStroke.Points.Clear(); var strokes = (from object child in InkCanvas.Children select child as UIElement).ToList(); var result = RecognizeStrokes(strokes, true); if (string.IsNullOrEmpty(result)) { var messageBox = new MessageDialog("Text could not be recognized."); messageBox.Commands.Add(new UICommand("Close")); await messageBox.ShowAsync(); result = ""; } RecognizedTextBox.Text = result; return; case WritePadAPI.GEST_CUT: ClearInk(InkCanvas); return; } FinishStrokeDraw(InkCanvas); }
public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN | WritePadAPI.GEST_UNDO | WritePadAPI.GEST_REDO, currentStroke); if (!mMoved) { mX++; } AddPixelsXY(mX, mY, true); mCurrStroke = -1; mMoved = false; strokeLen = 0; mPath.AddLineTo(new CGPoint(mX, mY)); mPathList.Add(mPath); mPath = new UIBezierPath(); mPath.LineWidth = WritePadAPI.DEFAULT_INK_WIDTH; mPath.LineCapStyle = CGLineCap.Round; mPath.LineJoinStyle = CGLineJoin.Round; SetNeedsDisplay(); switch (gesture) { case WritePadAPI.GEST_RETURN: if (OnReturnGesture != null) { mPathList.RemoveAt(mPathList.Count - 1); WritePadAPI.recoDeleteLastStroke(); SetNeedsDisplay(); OnReturnGesture(); } break; case WritePadAPI.GEST_CUT: if (OnCutGesture != null) { mPathList.RemoveAt(mPathList.Count - 1); WritePadAPI.recoDeleteLastStroke(); SetNeedsDisplay(); OnCutGesture(); } break; case WritePadAPI.GEST_UNDO: if (OnUndoGesture != null) { undoneStroke = mPathList [mPathList.Count - 1]; mPathList.RemoveAt(mPathList.Count - 1); WritePadAPI.recoDeleteLastStroke(); SetNeedsDisplay(); OnUndoGesture(); } break; case WritePadAPI.GEST_REDO: if (OnRedoGesture != null && undoneStroke != null) { mPathList.Add(undoneStroke); UIColor.Blue.SetStroke(); foreach (var aMPathList in mPathList) { aMPathList.Stroke(); } mPath.Stroke(); SetNeedsDisplay(); OnRedoGesture(); } break; } }