public bool IsSwipeLeft(Gesture gesture) { if (IsLongEnough(gesture, MinSwipeLength) && IsFastEnough(gesture, MinSwipeVelocity) && IsHorizontalEnough(gesture)) { return gesture.Delta.X < 0; } return false; }
protected virtual void OnGestured(Gesture e) { var handler = Gestured; if (handler != null) { handler(this, new GestureEventArgs(this, e)); } }
public GestureEventArgs(IGestureTracker tracker, Gesture gesture) { _gestureTrackers.Add(tracker); Gesture = gesture; }
internal static bool IsFastEnough(Gesture gesture, double minSwipeVelocity) { var delta = gesture.Velocity; if (Math.Abs(delta.X) < minSwipeVelocity) { return false; } return true; }
internal static bool IsLongEnough(Gesture gesture, double minSwipeLength) { var delta = gesture.Delta; if (Math.Abs(delta.X) < minSwipeLength) { return false; } return true; }
private static bool IsCommand(Gesture gesture, RoutedCommand command) { return gesture.CommandArgs != null && gesture.CommandArgs.Command == command; }
private bool IsHorizontalEnough(Gesture gesture) { var xs = new double[] { gesture.Delta.X, gesture.Velocity.X }; var ys = new double[] { gesture.Delta.Y, gesture.Velocity.Y }; for (int i = 0; i < 2; i++) { if (Math.Abs(xs[i]) < (2 * Math.Abs(ys[i]))) { return false; } } return true; }