/// <summary> /// Excutes the asyncronous action assoicated with the gesture /// </summary> /// <param name="result">The final <see cref="GestureResult"/></param> /// <param name="param">The Gesture Paramater</param> public async void ExecuteGesture(GestureResult result, object param) { if (_asyncExecute != null) { await Execute(result, param); } }
/// <summary> /// Excutes the action assoicated with the gesture /// </summary> /// <param name="result">The final <see cref="GestureResult"/></param> /// <param name="param">The Gesture Paramater cast to T before calling the action</param> public void ExecuteGesture(GestureResult result, object param) { if (_execute != null) { _execute(result, param as T); } }
/// <summary> /// Used by <see cref="GesturesContentView"/>. /// </summary> /// <param name="gesture">The resulting gesture<see cref="GestureResult"/></param> /// <returns>True if the gesture was handled,false otherwise</returns> public bool ProcessGesture(GestureResult gesture) { //Check the view stack first if (ExcludeChildren && gesture.ViewStack != null && gesture.ViewStack.Count != 0 && _viewInterests.All(x => x.View != gesture.ViewStack[0])) { return(false); //The innermost (source) is not an actual interested view } var interestedview = InterestedView(gesture.Origin); if (interestedview == null) { return(false); } gesture.StartView = interestedview.View; //Check for perfect matches first var interest = interestedview.Interests.Where(x => x.GestureType == gesture.GestureType && ( (x.Direction & Directionality.HorizontalMask) == (gesture.Direction & Directionality.HorizontalMask) && (x.Direction & Directionality.VerticalMask) == (gesture.Direction & Directionality.VerticalMask)) ).ToList(); if (!interest.Any()) { //Check for match on the dominant axis var horizontaldirection = gesture.HorizontalDistance < gesture.VerticalDistance ? Directionality.None : gesture.Direction & Directionality.HorizontalMask; var verticaldirection = gesture.HorizontalDistance < gesture.VerticalDistance ? gesture.Direction & Directionality.VerticalMask : Directionality.None; //Swap in the new direction so the user knows what the final match was gesture.Direction = horizontaldirection | verticaldirection; interest = interestedview.Interests.Where(x => x.GestureType == gesture.GestureType && (x.Direction & Directionality.HorizontalMask) == horizontaldirection && (x.Direction & Directionality.VerticalMask) == verticaldirection).ToList(); } //Winnow out the swipe gestures to match on either a perfect direction match (ie Up,Left) or based on the dominant axis //Is there one or more interest int this gesture? if (!interest.Any()) { return(false); } var final = interest.First(); //Finish setting up our gestureresult gesture.Origin = new Point(Math.Max(gesture.Origin.X - interestedview.View.X, 0), Math.Max(gesture.Origin.Y - interestedview.View.Y, 0)); SatisfyInterest(final, gesture); return(true); }
private void SatisfyInterest(GestureInterest gi, GestureResult args) { var commandparam = gi.GestureParameter ?? args.StartView.BindingContext ?? BindingContext; if (gi.GestureCommand != null && gi.GestureCommand.CanExecuteGesture(args, gi.GestureParameter)) { gi.GestureCommand.ExecuteGesture(args, commandparam); } var handler = GestureRecognized; if (handler != null) { handler(args.StartView, args); } }
private void G_GestureRecognized1(object sender, GestureResult e) { if (e.GestureType == GestureType.DoubleTap) { DisplayAlert("Gesture", "DoubleTap", "OK"); } else if (e.GestureType == GestureType.Down) { DisplayAlert("Gesture", "Down", "OK"); } else if (e.GestureType == GestureType.LongPress) { DisplayAlert("Gesture", "LongPress", "OK"); } else if (e.GestureType == GestureType.Move) { DisplayAlert("Gesture", "Move", "OK"); } else if (e.GestureType == GestureType.Pinch) { DisplayAlert("Gesture", "Pinch", "OK"); } else if (e.GestureType == GestureType.SingleTap) { DisplayAlert("Gesture", "SingleTap", "OK"); } else if (e.GestureType == GestureType.Swipe) { DisplayAlert("Gesture", "Swipe", "OK"); } else if (e.GestureType == GestureType.Unknown) { DisplayAlert("Gesture", "Unknown", "OK"); } else if (e.GestureType == GestureType.Up) { DisplayAlert("Gesture", "Up", "OK"); } }
/// <summary> /// Virtual aync funciton that the user can override to provide /// any custom functionality required. /// </summary> /// <param name="gesture"><see cref="GestureResult"/></param> /// <param name="annoyingbaseobjectthing"></param> /// <returns></returns> protected virtual async Task Execute(GestureResult gesture, object annoyingbaseobjectthing) { await _asyncExecute(gesture, annoyingbaseobjectthing as T); }
/// <summary> /// Tests to see if a gesture's action can execute /// </summary> /// <param name="result">The final <see cref="GestureResult"/></param> /// <param name="annoyingbaseobjectthing">The Gesture Paramater</param> /// <returns>true if the action can execute,false othewise</returns> public bool CanExecuteGesture(GestureResult result, object annoyingbaseobjectthing) { return(_canexecute == null || _canexecute(result, annoyingbaseobjectthing as T)); }
/// <summary> /// Tests to see if a gesture's action can execute /// </summary> /// <param name="result">The final <see cref="GestureResult"/></param> /// <param name="param">The Gesture Paramater cast to T before calling the function</param> /// <returns>true if the action can execute,false othewise</returns> public bool CanExecuteGesture(GestureResult result, object param) { return(_canexecute == null || _canexecute(result, param as T)); }