コード例 #1
0
ファイル: BaseChartView.cs プロジェクト: iXamDev/xcharts
        private void HandlePan(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(this);

            Trace($"Pan translation: {translation.X}/{translation.Y}");

            StopDeceleration();

            switch (recognizer.State)
            {
            case UIGestureRecognizerState.Began:

                panGestureLastTranslation = recognizer.TranslationInView(this);

                ViewPort.Offset(panGestureLastTranslation);

                break;

            case UIGestureRecognizerState.Changed:

                var translationOffset = new CGPoint(panGestureLastTranslation.X - translation.X, panGestureLastTranslation.Y - translation.Y);

                ViewPort.Offset(translationOffset);

                Trace($"Pan translationOffset: {translationOffset.X}/{translationOffset.Y}");

                panGestureLastTranslation = translation;

                break;

            case UIGestureRecognizerState.Ended:
                Trace($"Pan gesture ended");

                var velocity = recognizer.VelocityInView(this);

                Trace($"Pan gesture velocity: {velocity.X}/{velocity.Y}");

                InitDeceleration(velocity);

                break;

            default:
                break;
            }

            SetNeedsDisplay();
        }