public void RaisePointerEvent(NSSet touches, PointerEventArgs.PointerEventType Type, bool PointerDown) { var touch = (UITouch)touches.AnyObject; PreviousPoint = touch.PreviousLocationInView(this); var newPoint = touch.LocationInView(this); InvokeOnMainThread(SetNeedsDisplay); PointerEvent?.Invoke(this, new PointerEventArgs(Type, PreviousPoint.ToPoint(), newPoint.ToPoint(), PointerDown)); }
public override void TouchesMoved(NSSet touches, UIEvent evt) { var touch = (UITouch)touches.AnyObject; var currentPoint = touch.LocationInView(this); if (Math.Abs(currentPoint.X - PreviousPoint.X) >= 4 || Math.Abs(currentPoint.Y - PreviousPoint.Y) >= 4) { var newPoint = new PointF((currentPoint.X + PreviousPoint.X) / 2, (currentPoint.Y + PreviousPoint.Y) / 2); CurrentPath.AddQuadCurveToPoint(newPoint, PreviousPoint); PreviousPoint = currentPoint; InvokeOnMainThread(SetNeedsDisplay); PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Move, PreviousPoint.ToPoint(), newPoint.ToPoint(), PointerDown)); } else { CurrentPath.AddLineTo(currentPoint); InvokeOnMainThread(SetNeedsDisplay); } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { IndexCount++; var path = new UIBezierPath { LineWidth = PenWidth }; var touch = (UITouch)touches.AnyObject; PreviousPoint = touch.PreviousLocationInView(this); var newPoint = touch.LocationInView(this); path.MoveTo(newPoint); InvokeOnMainThread(SetNeedsDisplay); CurrentPath = path; var line = new VESLine { Path = CurrentPath, Color = CurrentLineColor, Index = IndexCount }; Lines.Add(line); PointerDown = true; PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Down, PreviousPoint.ToPoint(), newPoint.ToPoint(), PointerDown)); }