public override bool DispatchTouchEvent(MotionEvent e) { var index = e.ActionIndex; var action = e.ActionMasked; var pointerId = e.GetPointerId(index); switch (action & MotionEventActions.Mask) { case MotionEventActions.PointerDown: MultiTouchGesture?.Invoke(this, EventArgs.Empty); break; case MotionEventActions.Up: if ((DateTime.Now - _downTime).TotalMilliseconds < 200) { SingleTapGesture?.Invoke(this, EventArgs.Empty); } break; } switch (action) { case MotionEventActions.Down: _downTime = DateTime.Now; if (_velocityTracker == null) { _velocityTracker = VelocityTracker.Obtain(); } else { // Reset the velocity tracker back to its initial state. _velocityTracker.Clear(); } if (IfVelocityTrackerIsNull()) { return(true); } _velocityTracker.AddMovement(e); break; case MotionEventActions.Move: if (IfVelocityTrackerIsNull()) { return(true); } _velocityTracker.AddMovement(e); _velocityTracker.ComputeCurrentVelocity(Sensitivity); TryExportVelocity(_velocityTracker.GetXVelocity(pointerId), _velocityTracker.GetYVelocity(pointerId)); break; case MotionEventActions.Up: case MotionEventActions.Cancel: if (IfVelocityTrackerIsNull()) { return(true); } _velocityTracker.Recycle(); _velocityTracker = null; break; } return(true); }
/// <summary> /// Raises the <see cref="MultiTouchGesture"/> event. /// </summary> /// <param name="x">The x-coordinate of the normalized center of the gesture.</param> /// <param name="y">The y-coordinate of the normalized center of the gesture.</param> /// <param name="theta">The amount that the fingers rotated during the gesture.</param> /// <param name="distance">The amount that the fingers pinched during the gesture.</param> /// <param name="numfingers">The number of fingers that were used in the gesture.</param> protected virtual void OnMultiTouchGesture(Single x, Single y, Single theta, Single distance, Int32 numfingers) => MultiTouchGesture?.Invoke(this, x, y, theta, distance, numfingers);