protected override void OnPointerInput( PointerInputEvent touch, ref GestureEventResult result) { result.DidHandleEvent = true; if (touch.State == PointerInputState.Began) { if (this.State == GestureState.Possible) { this.State = GestureState.Began; this._gestureStart = touch.Point; this._delegate.OnTapBegan(); } } else if (touch.State == PointerInputState.Moved) { if (this.State == GestureState.Began) { double distance = touch.Point.DistanceTo(this._gestureStart); if (distance > Application.TouchSlop) { this.State = GestureState.Failed; this._delegate.OnTapEnded(); } } } else if (touch.State == PointerInputState.Ended) { if (this.State == GestureState.Began) { double distance = touch.Point.DistanceTo(this._gestureStart); if (distance <= Application.TouchSlop) { this.State = GestureState.Recognized; this._delegate.OnTapped(); } else { this.State = GestureState.Failed; } this._delegate.OnTapEnded(); } else { this.State = GestureState.Failed; } } else if (touch.State == PointerInputState.Canceled) { if (this.State == GestureState.Began) { this.State = GestureState.Failed; this._delegate.OnTapEnded(); } else { this.State = GestureState.Failed; } } }
protected override void OnPointerInput( PointerInputEvent touch, ref GestureEventResult result) { result.DidHandleEvent = true; if (touch.State == PointerInputState.Began) { if (this.State == GestureState.Possible) { this.State = GestureState.Began; this._swipeDirection = 0; this._gestureStart = touch.Point; this._delegate.OnTapBegan(); } } else if (this.State != GestureState.Possible) { float dx = (float)(touch.Point.X - this._gestureStart.X); if (this._swipeDirection == 0) { this._swipeDirection = Math.Sign(dx); } if (Math.Sign(dx) != this._swipeDirection) { dx = 0; } else { dx = Math.Abs(dx); } double dy = Math.Abs(touch.Point.Y - this._gestureStart.Y); if (touch.State == PointerInputState.Moved) { if (this.State == GestureState.Began) { if (dx >= Application.TouchSlop) { this._delegate.OnSwipeBegan(this._swipeDirection); this.State = GestureState.Changed; } else if (dy >= Application.TouchSlop) { this.State = GestureState.Failed; this._delegate.OnTapEnded(); } } else if (this.State == GestureState.Changed) { this._delegate.OnSwipeMoved(this._swipeDirection, dx); } } else if (touch.State == PointerInputState.Ended) { if (this.State == GestureState.Began) { this.State = GestureState.Recognized; this._delegate.OnTapped(); this._delegate.OnTapEnded(); } else if (this.State == GestureState.Changed) { this._delegate.OnSwipeEnded(this._swipeDirection, dx); this._delegate.OnTapEnded(); this.State = GestureState.Recognized; } else { this.State = GestureState.Failed; } } else if (touch.State == PointerInputState.Canceled) { if (this.State == GestureState.Began) { this._delegate.OnTapEnded(); } else if (this.State == GestureState.Changed) { this._delegate.OnSwipeCanceled(this._swipeDirection); this._delegate.OnTapEnded(); } if (this.State != GestureState.Possible) { this.State = GestureState.Canceled; } } } }