public override void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; } } }
/// <summary> /// Called, when mouse/finger/pen click/touch map /// </summary> /// <param name="touchPoints">List of all touched points</param> private bool OnTouchStart(List <Geometries.Point> touchPoints) { // Sanity check if (touchPoints.Count == 0) { return(false); } var args = new TouchedEventArgs(touchPoints); TouchStarted?.Invoke(this, args); if (args.Handled) { return(true); } if (touchPoints.Count == 2) { (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints); _mode = TouchMode.Zooming; _innerRotation = Viewport.Rotation; } else { _mode = TouchMode.Dragging; _previousCenter = touchPoints.First(); } return(true); }
/// <summary> /// Called, when mouse/finger/pen click/touch map /// </summary> /// <param name="touchPoints">List of all touched points</param> private bool OnTouchStart(List <Geometries.Point> touchPoints) { // Sanity check if (touchPoints.Count == 0) { return(false); } // We have a new interaction with the screen, so stop all navigator animations Navigator.StopRunningAnimation(); var args = new TouchedEventArgs(touchPoints); TouchStarted?.Invoke(this, args); if (args.Handled) { return(true); } if (touchPoints.Count == 2) { (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints); _mode = TouchMode.Zooming; _innerRotation = Viewport.Rotation; } else { _mode = TouchMode.Dragging; _previousCenter = touchPoints.First(); } return(true); }
/// <summary> /// Manages the listener logic /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; } } }
public override void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); if (TouchPanel.IsGestureAvailable) { var gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.Tap) { int x = 0; } if (gesture.GestureType == GestureType.DoubleTap) { int y = 0; } } foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; } } }
private void UpdateTouchState() { var position = ViewportAdapter.PointToScreen(InputManager.TouchPosition()); if (BoundingRectangle().Intersects(new Rectangle(position, Vector2.One.ToPoint()))) { if (InputManager.TouchDown()) { _touchedDown = true; TouchStarted?.Invoke(this, position); } else if (InputManager.TouchUp() && _touchedDown) { _touchedDown = false; Tap?.Invoke(this, position); Action?.Invoke(this, position); } } else { _touchedDown = false; } }
protected void SingleTouchStart() { TouchStarted?.Invoke(FirstTouch); }