コード例 #1
0
ファイル: ScopeView.cs プロジェクト: electronoob/WFS210-App
        /// <summary>
        /// Registers the pan gesture recognizer.
        /// </summary>
        void RegisterPanGestureRecognizer()
        {
            float previousX = 0;

            panGesture = new UIPanGestureRecognizer(() => {
                switch (panGesture.State)
                {
                case UIGestureRecognizerState.Began:
                    previousX = (float)panGesture.LocationOfTouch(0, this).X;
                    break;

                case UIGestureRecognizerState.Changed:
                    var touch      = panGesture.LocationOfTouch(0, this);
                    var copy       = ScrollPosition;
                    var delta      = touch.X - previousX;
                    copy          -= (int)delta;
                    copy           = (int)Math.Min(Math.Max(copy, 0), 4096 - TotalSamples);
                    previousX      = (float)touch.X;
                    ScrollPosition = copy;
                    UpdateScrollIndicator();
                    Update();
                    break;

                case UIGestureRecognizerState.Ended:
                    break;
                }
            });
            panGesture.MaximumNumberOfTouches = 2;
            panGesture.MinimumNumberOfTouches = 2;
            this.AddGestureRecognizer(panGesture);
        }
コード例 #2
0
ファイル: ViewController.cs プロジェクト: windywake/PolyLib
        void HandlePanTouch(UIPanGestureRecognizer recognizer)
        {
            bool startingAnim = false;

            if (recognizer.State == UIGestureRecognizerState.Changed)
            {
                startingAnim = true;
            }

            if (startingAnim)
            {
                var loc            = recognizer.LocationOfTouch(0, recognizer.View);
                var touchAnimation = new RandomTouch(_currentTriangulation, 6, (float)(loc.X * UIScreen.MainScreen.Scale), (float)(loc.Y * UIScreen.MainScreen.Scale), 250);
                _polyLibViewRef.AddAnimation(touchAnimation);
            }
        }