Exemplo n.º 1
0
        public void Initialize()
        {
            Map             = new Map();
            BackgroundColor = UIColor.White;

            _canvas.MultipleTouchEnabled = true;
            AddSubview(_canvas);

            TryInitializeViewport();

            ClipsToBounds          = true;
            MultipleTouchEnabled   = true;
            UserInteractionEnabled = true;

            _canvas.PaintSurface += OnPaintSurface;

            var doubleTapGestureRecognizer = new UITapGestureRecognizer(OnDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                CancelsTouchesInView = false,
            };

            AddGestureRecognizer(doubleTapGestureRecognizer);

            var tapGestureRecognizer = new UITapGestureRecognizer(OnSingleTapped)
            {
                NumberOfTapsRequired = 1,
                CancelsTouchesInView = false,
            };

            tapGestureRecognizer.RequireGestureRecognizerToFail(doubleTapGestureRecognizer);
            AddGestureRecognizer(tapGestureRecognizer);
        }
Exemplo n.º 2
0
        public DataGridRenderer() : base()
        {
            var gr_pan = new pan_gr(this);

            gr_pan.MaximumNumberOfTouches = 1;
            // TODO or maybe two fingers should be scroll but one finger is select?
            this.AddGestureRecognizer(gr_pan);

            var gr_singletap_datacells = new UITapGestureRecognizer(on_singletap);

            gr_singletap_datacells.NumberOfTapsRequired = 1;

                        #if not // TODO worth noting that we don't have double tap or long press
            var gr_doubletap_datacells = new UITapGestureRecognizer(on_doubletap);
            gr_doubletap_datacells.NumberOfTapsRequired = 2;

            gr_singletap_datacells.RequireGestureRecognizerToFail(gr_doubletap_datacells);

            var gr_longpress_datacells = new UILongPressGestureRecognizer(on_longpress);

            this.AddGestureRecognizer(gr_longpress_datacells);
            this.AddGestureRecognizer(gr_doubletap_datacells);
                        #endif

            this.AddGestureRecognizer(gr_singletap_datacells);
        }
Exemplo n.º 3
0
        private void InitializeGestures()
        {
            _singleTapRecognizer         = new UITapGestureRecognizer(
                () => CloseButton.Hidden = !CloseButton.Hidden)
            {
                NumberOfTapsRequired = (uint)1
            };

            _doubleTapRecognizer = new UITapGestureRecognizer(ZoomTo)
            {
                NumberOfTapsRequired = (uint)2
            };

            _swipeRecognizer = new UISwipeGestureRecognizer(RaiseToHide)
            {
                Direction = UISwipeGestureRecognizerDirection.Down |
                            UISwipeGestureRecognizerDirection.Up
            };

            _singleTapRecognizer.RequireGestureRecognizerToFail(_doubleTapRecognizer);

            ScrollView.AddGestureRecognizer(_singleTapRecognizer);
            ScrollView.AddGestureRecognizer(_doubleTapRecognizer);
            View.AddGestureRecognizer(_swipeRecognizer);
        }
Exemplo n.º 4
0
        public UIScrollViewImage()
        {
            AutoresizingMask = UIViewAutoresizing.All;

            ivMain = new UIImageView();
            //			ivMain.AutoresizingMask = UIViewAutoresizing.All;
            ivMain.ContentMode = UIViewContentMode.ScaleAspectFit;
            //			ivMain.BackgroundColor = UIColor.Red; // DEBUG
            AddSubview(ivMain);

            // Setup zoom
            MaximumZoomScale               = maxZoom;
            MinimumZoomScale               = minZoom;
            ShowsVerticalScrollIndicator   = false;
            ShowsHorizontalScrollIndicator = false;
            BouncesZoom = true;
            ViewForZoomingInScrollView += (UIScrollView sv) => {
                return(ivMain);
            };

            // Setup gestures
            grTap = new UITapGestureRecognizer(() => {
                if (OnSingleTap != null)
                {
                    OnSingleTap();
                }
            });
            grTap.NumberOfTapsRequired = 1;
            AddGestureRecognizer(grTap);

            grDoubleTap = new UITapGestureRecognizer(() => {
                if (ZoomScale >= defaultZoom)
                {
                    SetZoomScale(sizeToFitZoom, true);
                }
                else
                {
                    //SetZoomScale (defaultZoom, true);

                    // Zoom to user specified point instead of center
                    var point    = grDoubleTap.LocationInView(grDoubleTap.View);
                    var zoomRect = GetZoomRect(defaultZoom, point);
                    ZoomToRect(zoomRect, true);
                }
            });
            grDoubleTap.NumberOfTapsRequired = 2;
            AddGestureRecognizer(grDoubleTap);

            // To use single tap and double tap gesture recognizers together. See for reference:
            // http://stackoverflow.com/questions/8876202/uitapgesturerecognizer-single-tap-and-double-tap
            grTap.RequireGestureRecognizerToFail(grDoubleTap);
        }
Exemplo n.º 5
0
        private void Initialize()
        {
            _invalidate = () => {
                RunOnUIThread(() => {
                    SetNeedsDisplay();
                    _canvas?.SetNeedsDisplay();
                });
            };

            BackgroundColor = UIColor.White;

            _canvas.TranslatesAutoresizingMaskIntoConstraints = false;
            _canvas.MultipleTouchEnabled = true;
            _canvas.PaintSurface        += OnPaintSurface;
            AddSubview(_canvas);

            AddConstraints(new[]
            {
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _canvas,
                                          NSLayoutAttribute.Leading, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _canvas,
                                          NSLayoutAttribute.Trailing, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _canvas,
                                          NSLayoutAttribute.Top, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _canvas,
                                          NSLayoutAttribute.Bottom, 1.0f, 0.0f)
            });

            ClipsToBounds          = true;
            MultipleTouchEnabled   = true;
            UserInteractionEnabled = true;

            var doubleTapGestureRecognizer = new UITapGestureRecognizer(OnDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                CancelsTouchesInView = false,
            };

            AddGestureRecognizer(doubleTapGestureRecognizer);

            var tapGestureRecognizer = new UITapGestureRecognizer(OnSingleTapped)
            {
                NumberOfTapsRequired = 1,
                CancelsTouchesInView = false,
            };

            tapGestureRecognizer.RequireGestureRecognizerToFail(doubleTapGestureRecognizer);
            AddGestureRecognizer(tapGestureRecognizer);

            _viewport.SetSize(ViewportWidth, ViewportHeight);
        }
Exemplo n.º 6
0
        void TryAddTapGetsture()
        {
            if (tapGestureRecognizer != null)
            {
                return;
            }

            tapGestureRecognizer = new UITapGestureRecognizer(g => UpdateBars(0.25f))
            {
                NumberOfTapsRequired = 1
            };

            tapGestureRecognizer.RequireGestureRecognizerToFail(doubleTapGestureRecognizer);
            imageView.AddGestureRecognizer(tapGestureRecognizer);
        }
Exemplo n.º 7
0
		private void Initialize ()
		{
			AutoresizingMask = UIViewAutoresizing.All;

			ivMain = new UIImageView ();
			//			ivMain.AutoresizingMask = UIViewAutoresizing.All;
			ivMain.ContentMode = UIViewContentMode.ScaleAspectFit;
			//			ivMain.BackgroundColor = UIColor.Red; // DEBUG
			AddSubview (ivMain);

			// Setup zoom
			MaximumZoomScale = maxZoom;
			MinimumZoomScale = minZoom;
			ShowsVerticalScrollIndicator = false;
			ShowsHorizontalScrollIndicator = false;
			BouncesZoom = true;
			ViewForZoomingInScrollView += (UIScrollView sv) => {
				return ivMain;
			};

			// Setup gestures
			grTap = new UITapGestureRecognizer (() => {
				if (OnSingleTap != null) {
					OnSingleTap();
				}
			});
			grTap.NumberOfTapsRequired = 1;
			AddGestureRecognizer (grTap);

			grDoubleTap = new UITapGestureRecognizer (() => {
				if (ZoomScale >= defaultZoom) {
					SetZoomScale (sizeToFitZoom, true);
				} else {
					//SetZoomScale (defaultZoom, true);

					// Zoom to user specified point instead of center
					var point = grDoubleTap.LocationInView(grDoubleTap.View);
					var zoomRect = GetZoomRect(defaultZoom, point);
					ZoomToRect(zoomRect, true);
				}
			});
			grDoubleTap.NumberOfTapsRequired = 2;
			AddGestureRecognizer (grDoubleTap);

			// To use single tap and double tap gesture recognizers together. See for reference:
			// http://stackoverflow.com/questions/8876202/uitapgesturerecognizer-single-tap-and-double-tap
			grTap.RequireGestureRecognizerToFail (grDoubleTap);
		}
Exemplo n.º 8
0
        public void Initialize()
        {
            Map             = new Map();
            BackgroundColor = UIColor.White;

            _scale = DetermineSkiaScale();

            _canvas.TranslatesAutoresizingMaskIntoConstraints = false;
            _canvas.MultipleTouchEnabled = true;

            AddSubview(_canvas);

            AddConstraints(new[] {
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Leading, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Trailing, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Top, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Bottom, 1.0f, 0.0f)
            });

            TryInitializeViewport();

            ClipsToBounds          = true;
            MultipleTouchEnabled   = true;
            UserInteractionEnabled = true;

            _canvas.PaintSurface += OnPaintSurface;

            var doubleTapGestureRecognizer = new UITapGestureRecognizer(OnDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                CancelsTouchesInView = false,
            };

            AddGestureRecognizer(doubleTapGestureRecognizer);

            var tapGestureRecognizer = new UITapGestureRecognizer(OnSingleTapped)
            {
                NumberOfTapsRequired = 1,
                CancelsTouchesInView = false,
            };

            tapGestureRecognizer.RequireGestureRecognizerToFail(doubleTapGestureRecognizer);
            AddGestureRecognizer(tapGestureRecognizer);
        }
Exemplo n.º 9
0
        public void Initialize()
        {
            Map             = new Map();
            BackgroundColor = UIColor.White;

            _canvas.TranslatesAutoresizingMaskIntoConstraints = false;
            _canvas.MultipleTouchEnabled = true;
            _canvas.PaintSurface        += OnPaintSurface;
            AddSubview(_canvas);

            AddConstraints(new[] {
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Leading, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Trailing, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Top, 1.0f, 0.0f),
                NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Bottom, 1.0f, 0.0f)
            });

            // Unfortunately the SKGLView does not have a IgnorePixelScaling property. We have to adjust for density with SKGLView.Scale.
            _density = PixelsPerDeviceIndependentUnit;

            TryInitializeViewport(ScreenWidth, ScreenHeight);

            ClipsToBounds          = true;
            MultipleTouchEnabled   = true;
            UserInteractionEnabled = true;

            var doubleTapGestureRecognizer = new UITapGestureRecognizer(OnDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                CancelsTouchesInView = false,
            };

            AddGestureRecognizer(doubleTapGestureRecognizer);

            var tapGestureRecognizer = new UITapGestureRecognizer(OnSingleTapped)
            {
                NumberOfTapsRequired = 1,
                CancelsTouchesInView = false,
            };

            tapGestureRecognizer.RequireGestureRecognizerToFail(doubleTapGestureRecognizer);
            AddGestureRecognizer(tapGestureRecognizer);
        }
Exemplo n.º 10
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Slider.ValueChanged += Slider_ValueChanged;

            pinchRecognizer = new UIPinchGestureRecognizer(OnPlotPinch);
            panRecognizer   = new UIPanGestureRecognizer(OnPlotPan);
            panRecognizer.MinimumNumberOfTouches = 2;

            longPressRecognizer = new UILongPressGestureRecognizer(OnPlotLongPress);

            tapRecognizer = new UITapGestureRecognizer(OnPlotTap);
            tapRecognizer.RequireGestureRecognizerToFail(longPressRecognizer);

            Plot.AddGestureRecognizer(pinchRecognizer);
            Plot.AddGestureRecognizer(panRecognizer);
            Plot.AddGestureRecognizer(longPressRecognizer);
            Plot.AddGestureRecognizer(tapRecognizer);
        }
Exemplo n.º 11
0
        public IOSGestures(IOSGameView view)
        {
            _view = view;

            UIPanGestureRecognizer dragGesture = new UIPanGestureRecognizer(onDrag);

            UITapGestureRecognizer singleTapGesture = new UITapGestureRecognizer(onSingleTap);

            singleTapGesture.NumberOfTapsRequired = 1;

            UITapGestureRecognizer doubleTapGesture = new UITapGestureRecognizer(onDoubleTap);

            doubleTapGesture.NumberOfTapsRequired = 2;

            UILongPressGestureRecognizer longPressGesture = new UILongPressGestureRecognizer(onLongPress);

            addGesture(dragGesture);
            addGesture(singleTapGesture);
            addGesture(doubleTapGesture);
            addGesture(longPressGesture);

            singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
        }
        protected override void OnAttached()
        {
            mapView = Control as MKMapView;
            if (mapView == null)
            {
                throw new NotSupportedException(Control.GetType() + " is not supported.");
            }

            behavior = (Element as Map)?.Behaviors?.OfType <ClickBehavior>()?.FirstOrDefault();
            if (behavior == null)
            {
                return;
            }

            tapGesture = new UITapGestureRecognizer(recognizer =>
                                                    MapClicked?.Invoke(this, new MapClickedEventArgs(
                                                                           ConvertLocationToPosition(recognizer, mapView)))
                                                    )
            {
                NumberOfTapsRequired = 1,
            };

            longPressGesture = new UILongPressGestureRecognizer(recognizer =>
            {
                if (recognizer.State != UIGestureRecognizerState.Began)
                {
                    return;
                }

                MapLongClicked?.Invoke(this, new MapClickedEventArgs(
                                           ConvertLocationToPosition(recognizer, mapView)));
            });

            tapGesture.RequireGestureRecognizerToFail(longPressGesture);
            mapView.AddGestureRecognizer(longPressGesture);
            mapView.AddGestureRecognizer(tapGesture);
        }
Exemplo n.º 13
0
        public DraggableBall(RectangleF frame) : base(frame)
        {
            var pangesture = new UIPanGestureRecognizer(detectPan);

            this.AddGestureRecognizer(pangesture);
            this.Layer.CornerRadius = 25;
            this.Layer.BorderColor  = UIColor.Black.CGColor;
            this.Layer.BorderWidth  = 2;
            this.BackgroundColor    = UIColor.Orange;
            this.TextColor          = UIColor.White;

            var doubletouch = new UITapGestureRecognizer(doubletapped);

            doubletouch.NumberOfTapsRequired = 2;
            this.AddGestureRecognizer(doubletouch);

            var singletouch = new UITapGestureRecognizer(tapped);

            singletouch.NumberOfTapsRequired = 1;
            singletouch.RequireGestureRecognizerToFail(doubletouch);
            this.AddGestureRecognizer(singletouch);

            this.TextAlignment = UITextAlignment.Center;
        }
Exemplo n.º 14
0
        public DataPanelView(IRegularPanel <TGraphics> dp, Func <DataPanelView <TGraphics>, TGraphics> func_gr)
        {
            _dp      = dp;
            _func_gr = func_gr;
            _dp.SetView(this);

            this.AutoresizingMask = UIViewAutoresizing.None;

            var gr_singletap_datacells = new UITapGestureRecognizer(on_singletap);

            gr_singletap_datacells.NumberOfTapsRequired = 1;

            var gr_doubletap_datacells = new UITapGestureRecognizer(on_doubletap);

            gr_doubletap_datacells.NumberOfTapsRequired = 2;

            gr_singletap_datacells.RequireGestureRecognizerToFail(gr_doubletap_datacells);

            var gr_longpress_datacells = new UILongPressGestureRecognizer(on_longpress);

            this.AddGestureRecognizer(gr_longpress_datacells);
            this.AddGestureRecognizer(gr_doubletap_datacells);
            this.AddGestureRecognizer(gr_singletap_datacells);
        }
Exemplo n.º 15
0
        UIGestureRecognizer[] CreateGestureRecognizers()
        {
            var list = new List <UIGestureRecognizer>();
            //if (HandlesDownUps)  WE NEED TO ALWAYS MONITOR FOR DOWN TO BE ABLE TO UNDO A CANCEL
            {  // commenting out if (HanglesDownUps) causes FormsDragNDrop listview to not recognize cell selections after a scroll.  Why?  I have no clue.
               // Let's always trigger the down gesture recognizer so we can get the starting location
                var downUpGestureRecognizer = new DownUpGestureRecognizer(new Action <DownUpGestureRecognizer, UITouch[]>(OnDown), new Action <DownUpGestureRecognizer, UITouch[]>(OnUp));
                downUpGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) => false);
                downUpGestureRecognizer.ShouldReceiveTouch            = ((UIGestureRecognizer gr, UITouch touch) => !(touch.View is UIControl));
                list.Add(downUpGestureRecognizer);
                //downUpGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }
            UILongPressGestureRecognizer uILongPressGestureRecognizer = null;

            if (HandlesLongs)
            {
                uILongPressGestureRecognizer = new UILongPressGestureRecognizer(new Action <UILongPressGestureRecognizer>(OnLongPressed));
                uILongPressGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) => false);
                list.Add(uILongPressGestureRecognizer);
                //uILongPressGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }
            if (HandlesTaps)
            {
                var uITapGestureRecognizer = new UITapGestureRecognizer(new Action <UITapGestureRecognizer>(OnTapped));
                uITapGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) =>
                {
                    return(thisGr.GetType() != otherGr.GetType());
                });
                uITapGestureRecognizer.ShouldReceiveTouch = ((UIGestureRecognizer gr, UITouch touch) =>
                {
                    // these are handled BEFORE the touch call is passed to the listener.
                    return(!(touch.View is UIControl));
                    //return touch.View == gr.View;
                });
                if (uILongPressGestureRecognizer != null)
                {
                    uITapGestureRecognizer.RequireGestureRecognizerToFail(uILongPressGestureRecognizer);
                }
                list.Add(uITapGestureRecognizer);
                //uITapGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }
            if (HandlesPans)
            {
                var uIPanGestureRecognizer = new UIPanGestureRecognizer(new Action <UIPanGestureRecognizer>(OnPanned));
                uIPanGestureRecognizer.MinimumNumberOfTouches        = 1;
                uIPanGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true);
                list.Add(uIPanGestureRecognizer);
                //uIPanGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }
            if (HandlesPinches)
            {
                var uIPinchGestureRecognizer = new UIPinchGestureRecognizer(new Action <UIPinchGestureRecognizer>(OnPinched));
                uIPinchGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true);
                list.Add(uIPinchGestureRecognizer);
                //uIPinchGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }
            if (HandlesRotates)
            {
                var uIRotationGestureRecognizer = new UIRotationGestureRecognizer(new Action <UIRotationGestureRecognizer>(OnRotated));
                uIRotationGestureRecognizer.ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true);
                list.Add(uIRotationGestureRecognizer);
                //uIRotationGestureRecognizer.ShouldReceiveTouch = (recognizer, touch) => {
                //	return _element.get_IgnoreChildrenTouches() ? touch.View==_view : true;
                //};
            }

            /*
             *          var control = (UIView)_view.GetPropertyValue ("Control");
             *          if (control is UIButton)
             *                  control.UserInteractionEnabled = !(HandlesTaps || HandlesDownUps);
             */
            return(list.ToArray());
        }
        private void AddMultipleGesture()
        {
            UITapGestureRecognizer twoFingerTapGesture = new UITapGestureRecognizer(this, new Selector("DidTwoFingerTap:"));
            twoFingerTapGesture.NumberOfTapsRequired = 1;
            twoFingerTapGesture.NumberOfTouchesRequired = 2;
            scrollView.AddGestureRecognizer(twoFingerTapGesture);

            UITapGestureRecognizer singleTapGesture = new UITapGestureRecognizer(this, new Selector("DidSingleTap:"));
            singleTapGesture.NumberOfTapsRequired = 1;
            singleTapGesture.NumberOfTouchesRequired = 1;
            scrollView.AddGestureRecognizer(singleTapGesture);

            UITapGestureRecognizer doubleTapRecognizer = new UITapGestureRecognizer(this, new Selector("DidDoubleTap:"));
            doubleTapRecognizer.NumberOfTapsRequired = 2;
            doubleTapRecognizer.NumberOfTouchesRequired = 1;
            scrollView.AddGestureRecognizer(doubleTapRecognizer);

            singleTapGesture.RequireGestureRecognizerToFail(doubleTapRecognizer);
            scrollView.MinimumZoomScale = 1f;
            scrollView.MaximumZoomScale = 2.5f;

            CenterScrollViewContents();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom.
        /// </summary>
        /// <param name="defaultMapCenter">Default map center.</param>
        /// <param name="defaultMap">Default map.</param>
        /// <param name="defaultMapTilt">Default map tilt.</param>
        /// <param name="defaultMapZoom">Default map zoom.</param>
        public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom)
        {
            // set clip to bounds to prevent objects from being rendered/show outside of the mapview.
            this.ClipsToBounds = true;

            _mapCenter = defaultMapCenter;
            _map       = defaultMap;
            _mapTilt   = defaultMapTilt;
            _mapZoom   = defaultMapZoom;

            _doubleTapAnimator = new MapViewAnimator(this);

            this.BackgroundColor        = UIColor.White;
            this.UserInteractionEnabled = true;

            _markers = new List <MapMarker> ();

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                panGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                panGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                pinchGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                pinchGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                rotationGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                rotationGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                // TODO: workaround for xamarin bug, remove later!
//				singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                // TODO: workaround for xamarin bug, remove later!
//				doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }
            else
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle;

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble;

                singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }

            // set scalefactor.
            _scaleFactor = this.ContentScaleFactor;

            // create the cache renderer.
            _cacheRenderer = new MapRenderer <CGContextWrapper> (
                new CGContextRenderer(_scaleFactor));
            _cachedScene           = new Scene2DSimple();
            _cachedScene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Exemplo n.º 18
0
		void Setup ()
		{
			SceneView = (SCNView)this.View;

			SceneView.BackgroundColor = SKColor.Black;

			//setup ivars
			Boxes = new List<SCNNode> ();

			//setup the scene
			SetupScene ();

			//present it
			SceneView.Scene = Scene;

			//tweak physics
			SceneView.Scene.PhysicsWorld.Speed = 2.0f;

			//let's be the delegate of the SCNView
			SceneView.WeakSceneRendererDelegate = this;

			SceneView.JitteringEnabled = true;

			//initial point of view
			SceneView.PointOfView = CameraNode;

			//setup overlays
			var overlay = new SpriteKitOverlayScene (SceneView.Bounds.Size);
			SceneView.OverlayScene = overlay;

			#if __IOS__
			var gestureRecognizers = new List<UIGestureRecognizer> ();
			if (SceneView.GestureRecognizers != null)
				gestureRecognizers.AddRange (SceneView.GestureRecognizers);

			// add a tap gesture recognizer
			UITapGestureRecognizer tapGesture = new UITapGestureRecognizer (HandleTouch);

			// add a pan gesture recognizer
			UIPanGestureRecognizer panGesture = new UIPanGestureRecognizer (HandleTouchPan);

			// add a double tap gesture recognizer
			UITapGestureRecognizer doubleTapGesture = new UITapGestureRecognizer (HandleDoubleTouch);
			doubleTapGesture.NumberOfTapsRequired = 2;

			tapGesture.RequireGestureRecognizerToFail (panGesture);

			gestureRecognizers.Add (doubleTapGesture);
			gestureRecognizers.Add (tapGesture);
			gestureRecognizers.Add (panGesture);

			//register gesture recognizers
			SceneView.GestureRecognizers = gestureRecognizers.ToArray ();
			#endif
		}
Exemplo n.º 19
0
        UIGestureRecognizer[] CreateGestureRecognizers()
        {
            var list = new List <UIGestureRecognizer>();
            //if (HandlesDownUps)  WE NEED TO ALWAYS MONITOR FOR DOWN TO BE ABLE TO UNDO A CANCEL
            {  // commenting out if (HanglesDownUps) causes FormsDragNDrop listview to not recognize cell selections after a scroll.  Why?  I have no clue.
               // Let's always trigger the down gesture recognizer so we can get the starting location
                var downUpGestureRecognizer = new DownUpGestureRecognizer(new Action <DownUpGestureRecognizer, UITouch[]>(OnDown), new Action <DownUpGestureRecognizer, UITouch[]>(OnUp))
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => false),
                    ShouldReceiveTouch            = ((UIGestureRecognizer gr, UITouch touch) => !(touch.View is UIControl))
                };
                list.Add(downUpGestureRecognizer);
            }
            UILongPressGestureRecognizer uILongPressGestureRecognizer = null;

            if (HandlesLongs)
            {
                uILongPressGestureRecognizer = new UILongPressGestureRecognizer(new Action <UILongPressGestureRecognizer>(OnLongPressed))
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => false)
                };
                list.Add(uILongPressGestureRecognizer);
            }
            if (HandlesTaps)
            {
                var uITapGestureRecognizer = new UITapGestureRecognizer(new Action <UITapGestureRecognizer>(OnTapped))
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) =>
                    {
                        return(thisGr.GetType() != otherGr.GetType());
                    }),
                    ShouldReceiveTouch = ((UIGestureRecognizer gr, UITouch touch) =>
                    {
                        // these are handled BEFORE the touch call is passed to the listener.
                        return(!(touch.View is UIControl));
                    })
                };
                if (uILongPressGestureRecognizer != null)
                {
                    uITapGestureRecognizer.RequireGestureRecognizerToFail(uILongPressGestureRecognizer);
                }
                list.Add(uITapGestureRecognizer);
            }
            if (HandlesPans)
            {
                var uIPanGestureRecognizer = new UIPanGestureRecognizer(new Action <UIPanGestureRecognizer>(OnPanned))
                {
                    MinimumNumberOfTouches        = 1,
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIPanGestureRecognizer);
            }
            if (HandlesPinches)
            {
                var uIPinchGestureRecognizer = new UIPinchGestureRecognizer(new Action <UIPinchGestureRecognizer>(OnPinched))
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIPinchGestureRecognizer);
            }
            if (HandlesRotates)
            {
                var uIRotationGestureRecognizer = new UIRotationGestureRecognizer(new Action <UIRotationGestureRecognizer>(OnRotated))
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIRotationGestureRecognizer);
            }
            return(list.ToArray());
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom.
        /// </summary>
        /// <param name="defaultMapCenter">Default map center.</param>
        /// <param name="defaultMap">Default map.</param>
        /// <param name="defaultMapTilt">Default map tilt.</param>
        /// <param name="defaultMapZoom">Default map zoom.</param>
        public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom)
        {
            // register the default listener.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            // enable all interactions by default.
            this.MapAllowPan = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // set clip to bounds to prevent objects from being rendered/show outside of the mapview.
            this.ClipsToBounds = true;

            MapCenter = defaultMapCenter;
            _map = defaultMap;
            MapTilt = defaultMapTilt;
            MapZoom = defaultMapZoom;

            _map.MapChanged += MapChanged;

            _doubleTapAnimator = new MapViewAnimator(this);

            this.BackgroundColor = UIColor.White;
            this.UserInteractionEnabled = true;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                panGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                panGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                pinchGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                pinchGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                rotationGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                rotationGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                // TODO: workaround for xamarin bug, remove later!
                //				singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
                //				singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                // TODO: workaround for xamarin bug, remove later!
                //				doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
                //				doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }
            else
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle;

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble;

                singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }

            // set scalefactor.
            _scaleFactor = (float)this.ContentScaleFactor;

            // create the cache renderer.
            _cacheRenderer = new MapRenderer<CGContextWrapper>(
                new CGContextRenderer(_scaleFactor));
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
        private void SetupImageModeGestureRecognizers()
        {
            UITapGestureRecognizer doubleTapper = null;
            doubleTapper = new UITapGestureRecognizer (ImageDoubleTapped);
            doubleTapper.NumberOfTapsRequired = 2;
            doubleTapper.WeakDelegate = this;
            DoubleTapperPhoto = doubleTapper;

            UILongPressGestureRecognizer longPresser = new UILongPressGestureRecognizer (ImageLongPressed);
            longPresser.WeakDelegate = this;
            LongPresserPhoto = longPresser;

            UITapGestureRecognizer singleTapper = null;
            singleTapper = new UITapGestureRecognizer (ImageSingleTapped);
            singleTapper.RequireGestureRecognizerToFail (doubleTapper);
            singleTapper.RequireGestureRecognizerToFail (longPresser);
            singleTapper.WeakDelegate = this;
            SingleTapperPhoto = singleTapper;

            UIPanGestureRecognizer panner = new UIPanGestureRecognizer (dismissingPanGestureRecognizerPanned);
            panner.WeakDelegate = this;
            ScrollView.AddGestureRecognizer (panner);
            PanRecognizer = panner;

            View.AddGestureRecognizer (singleTapper);
            View.AddGestureRecognizer (doubleTapper);
            View.AddGestureRecognizer (longPresser);
        }