Example #1
0
        /// <summary>
        /// This view's owner (ModelView) receives the: ShouldRecognizeSimultaneouslyWithGestureRecognizer
        /// callback for each of its delegates.
        /// </summary>
        public void SetupGestureRecognizers()
        {
            // Pinch - Zoom
            ZoomRecognizer          = new UIPinchGestureRecognizer(this, new Selector("ZoomCameraWithGesture:"));
            ZoomRecognizer.Enabled  = false;
            ZoomRecognizer.Delegate = new GestureDelegate(this);
            View.AddGestureRecognizer(ZoomRecognizer);

            // Orbit & Dolly
            OrbitDollyRecognizer = new OrbitDollyGestureRecognizer();
            OrbitDollyRecognizer.AddTarget(this, new Selector("OrbitDollyCameraWithGesture:"));
            OrbitDollyRecognizer.MaximumNumberOfTouches = 2;
            OrbitDollyRecognizer.Enabled  = false;
            OrbitDollyRecognizer.Delegate = new GestureDelegate(this);
            View.AddGestureRecognizer(OrbitDollyRecognizer);

            // Zoom Extents / Restore Last View
            DoubleTapGestureRecognizer = new UITapGestureRecognizer();
            DoubleTapGestureRecognizer.AddTarget(this, new Selector("ZoomExtentsWithGesture:"));
            DoubleTapGestureRecognizer.NumberOfTapsRequired = 2;
            DoubleTapGestureRecognizer.Enabled = false;
            View.AddGestureRecognizer(DoubleTapGestureRecognizer);
        }
Example #2
0
        private void OrbitDollyCameraWithGesture(OrbitDollyGestureRecognizer gesture)
        {
            if (Camera == null)
            {
                return;
            }

            if (gesture.State == UIGestureRecognizerState.Began)
            {
                ActiveGesturesCount++;
            }

            if (gesture.State == UIGestureRecognizerState.Changed)
            {
                FastDrawing = true;
                CameraIsAtInitialPosition = false;

                if (gesture.HasSingleTouch)
                {
                    Camera.GestureOrbit((Size)View.Bounds.Size.ToRoundedCGSize(), gesture.AnchorLocation, gesture.CurrentLocation);
                    gesture.AnchorLocation = gesture.CurrentLocation;
                }

                if (gesture.HasTwoTouches)
                {
                    Camera.LateralPan(gesture.StartLocation, gesture.MidpointLocation, false, false);
                    gesture.StartLocation = gesture.MidpointLocation;
                }

                View.SetNeedsDisplay();
            }

            if (gesture.State == UIGestureRecognizerState.Ended || gesture.State == UIGestureRecognizerState.Cancelled)
            {
                ActiveGesturesCount--;
            }
        }