public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { var result = false; try { float diffY = e2.GetY() - e1.GetY(); float diffX = e2.GetX() - e1.GetX(); if (System.Math.Abs(diffX) > System.Math.Abs(diffY)) { if (System.Math.Abs(diffX) > SWIPE_THRESHOLD && System.Math.Abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { if (diffX > 0) { Swipe?.Invoke(this, EventArgs.Empty); } result = true; } } } catch { return(false); } return(result); }
SwipeGestureRecognizer GetSwipeGestureRecognizer(SwipeDirection direction) { var swipe = new SwipeGestureRecognizer { Direction = direction }; swipe.Swiped += (sender, e) => Swipe?.Invoke(this, e); return(swipe); }
public SwipeListener(Context context) { _context = context; var listener = new GestureListener(); listener.Click += (s, e) => Click?.Invoke(this, EventArgs.Empty); listener.Swipe += (s, e) => Swipe?.Invoke(this, EventArgs.Empty); _gestureDetector = new GestureDetector(_context, listener); }
/// <summary> /// Called, when mouse/finger/pen swiped over map /// </summary> /// <param name="velocityX">Velocity in x direction in pixel/second</param> /// <param name="velocityY">Velocity in y direction in pixel/second</param> private bool OnSwiped(double velocityX, double velocityY) { var args = new SwipedEventArgs(velocityX, velocityY); Swipe?.Invoke(this, args); // TODO // Perform standard behavior return(args.Handled); }
public void SwipeAway(Vector3 direction) { if (!_wasSwiped) { _wasSwiped = true; Swipe?.Invoke(); _rigidbody.AddForce(Vector3.up * SWIPE_FORCE); _rigidbody.AddForce(direction * SWIPE_FORCE); _rigidbody.AddTorque(direction * SWIPE_FORCE, ForceMode.Impulse); Destroy(gameObject, LIFETIME); } }
public static void OnSwipe(Point p) { if (p.X == 0 && p.Y == 0) { return; } var eX = p.X; var eY = p.Y; var d = Math.Sqrt(eX * eX + eY * eY); if (d > 25 && _panJustBegun) { _panJustBegun = false; var initialPos = new Point(_previousPosX, _previousPosY); if (eX > 0) { if (eY > eX) { Swipe?.Invoke(initialPos, Direction.Bottom); } else if (Math.Abs(eY) > eX) { Swipe?.Invoke(initialPos, Direction.Top); } else { Swipe?.Invoke(initialPos, Direction.Right); } } else { if (eY > Math.Abs(eX)) { Swipe?.Invoke(initialPos, Direction.Bottom); } else if (Math.Abs(eY) > Math.Abs(eX)) { Swipe?.Invoke(initialPos, Direction.Top); } else { Swipe?.Invoke(initialPos, Direction.Left); } } } }
/// <summary> /// When implemented by a class, enables a server control to process an event raised when a form is posted to the server. /// </summary> /// <param name="eventArgument">A <see cref="T:System.String" /> that represents an optional event argument to be passed to the event handler.</param> public void RaisePostBackEvent(string eventArgument) { var swipeInfo = new SwipePaymentInfo(eventArgument); Swipe?.Invoke(this, new SwipeEventArgs(swipeInfo)); }
public void SwipeLeeftRight(object sender, SwipedEventArgs e) { Swipe?.Invoke(this, e); }