void OnTouchEffectTouchAction(object sender, TouchActionEventArgs args) { SKPoint pixelLocation = ConvertToPixel(args.Location); SKPoint bitmapLocation = inverseBitmapMatrix.MapPoint(pixelLocation); switch (args.Type) { case TouchActionType.Pressed: // Convert radius to bitmap/cropping scale float radius = inverseBitmapMatrix.ScaleX * RADIUS; // Find corner that the finger is touching int cornerIndex = croppingRect.HitTest(bitmapLocation, radius); if (cornerIndex != -1 && !touchPoints.ContainsKey(args.Id)) { TouchPoint touchPoint = new TouchPoint { CornerIndex = cornerIndex, Offset = bitmapLocation - croppingRect.Corners[cornerIndex] }; touchPoints.Add(args.Id, touchPoint); } break; case TouchActionType.Moved: if (touchPoints.ContainsKey(args.Id)) { TouchPoint touchPoint = touchPoints[args.Id]; croppingRect.MoveCorner(touchPoint.CornerIndex, bitmapLocation - touchPoint.Offset); InvalidateSurface(); } break; case TouchActionType.Released: case TouchActionType.Cancelled: if (touchPoints.ContainsKey(args.Id)) { touchPoints.Remove(args.Id); } break; } }
public void OnTouchAction(Element element, TouchActionEventArgs args) { TouchAction?.Invoke(element, args); }