문제

나는 감지하려는 수평 와이프와 제스처 GestureRecognizer 로 연결하 CrossSliding 이벤트입니다.

        _gr = new GestureRecognizer
        {
            GestureSettings = GestureSettings.ManipulationTranslateX |
                              GestureSettings.ManipulationTranslateY |
                              GestureSettings.CrossSlide
        };

        _gr.CrossSliding += OnSwipe;
        _gr.ManipulationStarted += OnManipulationStarted;
        _gr.ManipulationUpdated += OnManipulationUpdated;
        _gr.ManipulationCompleted += OnManipulationCompleted;

        _gr.CrossSlideHorizontally = true;

당신이 볼 수 있듯이에서 위의 코드는,뿐만 아니라 와이프가 감지될 것이지만,또한 드래그 제스처입니다.

내 문제입니다 나는 할 수 없을 사로.

나는 사용자 정의하려면 최소한도의 거리에는 사용자가 포인터를 끌어지기 전에 몸짓으로 간주됩니다.현재 상태에서도 가장 느리고 가장 작은 수평한 끌기 동작을 트리거 CrossSliding 이벤트입니다.

을 보았 CrossSlideThresholds 클래스는 사용자 정의 할 수 있습 제스처 그러나를 볼 수 없었던 방법이 될 수 있을 구성하는 데 사용되는 속도 및 거리의 와이프 제스처입니다.

CrossSliding 이벤트 적절한지 확인하는 방법을 씁니다.그렇다면,어떻게 구성할 수 있습니 속도와 슬쩍거리?

하지 않을 경우,어떻게 감지하는 와이프 제스처?

도움이 되었습니까?

해결책

나는 찾을 수없는 방식으로 구축을 감지하는 와이프,그래서 내가 구현되는 내 자신의 탐지 방법입니다.

코드 감지하는 수평합니다.

이 방법은 다음과 같은 이벤트에 대한 처리기 GestureRecognizer 이벤트:

readonly Stopwatch _manipulationTimer = new Stopwatch();

public void OnManipulationStarted(ManipulationStartedEventArgs e)
{
    _manipulationTimer.Restart();
}

public void OnManipulationCompleted(ManipulationCompletedEventArgs e)
{
    var millis = _manipulationTimer.ElapsedMilliseconds;

    if (Math.Abs(e.Cumulative.Translation.Y) < MaxVerticalSwipeDistanceInPix &&
        Math.Abs(e.Cumulative.Translation.X) > MinHorizontalSwipeDistanceInPix && 
        millis > MinSwipeDurationInMillis && 
        millis < MaxSwipeDurationInMillis && 
        Math.Abs(e.Cumulative.Scale - 1) < 0.01 // 1 touch point 
        )
    { 
        var leftSwipe = e.Cumulative.Translation.X < 0;
        if (leftSwipe)
        {
        }
        else // right swipe
        {               
        }
    }

    _manipulationTimer.Stop();
    _manipulationTimer.Reset();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top