public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIPinchGestureRecognizer pinch = new UIPinchGestureRecognizer (handlePinchGesture);
            this.CollectionView.AddGestureRecognizer (pinch);
        }
Beispiel #2
0
		public void Initialize() 
		{
			Map = new Map();

			_renderer = new MapRenderer();
			BackgroundColor = UIColor.White;
		
			InitializeViewport();

			ClipsToBounds = true;

			var pinchGesture = new UIPinchGestureRecognizer(PinchGesture) { Enabled = true };
			AddGestureRecognizer(pinchGesture);

			UIDevice.Notifications.ObserveOrientationDidChange((n, a) => {
				if (this.Window != null) {

					// after rotation all textures show up as white. I don't know why. 
					// By deleting all textures they are rebound and they show up properly.
					_renderer.DeleteAllBoundTextures();	

					Frame = new CGRect (0, 0, Frame.Width, Frame.Height);
					Map.Viewport.Width = Frame.Width;
					Map.Viewport.Height = Frame.Height;
					Map.NavigateTo(Map.Viewport.Extent);
				}});
							
		}
		private void TrackGestureChaged (UIPinchGestureRecognizer pinchGestureRecognizer)
		{
			// compute the current pinch fraction
			float fraction = (float)(1f - pinchGestureRecognizer.Scale / startScale);
			shouldCompleteTransition = (fraction > 0.5);
			UpdateInteractiveTransition (fraction);
		}
		// This method is invoked when the application has loaded and is ready to run. In this 
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			// create and initialize a UICollectionViewFlowLayout
			flowLayout = new UICollectionViewFlowLayout (){
				SectionInset = new UIEdgeInsets (25,5,10,5),
				MinimumInteritemSpacing = 5,
				MinimumLineSpacing = 5,
				ItemSize = new CGSize (100, 100)
			};

			circleLayout = new CircleLayout (Monkeys.Instance.Count){
				ItemSize = new CGSize (100, 100)
			};
		
			imagesController = new ImagesCollectionViewController (flowLayout);

			nfloat sf = 0.4f;
			UICollectionViewTransitionLayout trLayout = null;
			UICollectionViewLayout nextLayout;

			pinch = new UIPinchGestureRecognizer (g => {

				var progress = Math.Abs(1.0f -  g.Scale)/sf;

				if(trLayout == null){
					if(imagesController.CollectionView.CollectionViewLayout is CircleLayout)
						nextLayout = flowLayout;
					else
						nextLayout = circleLayout;

					trLayout = imagesController.CollectionView.StartInteractiveTransition (nextLayout, (completed, finished) => {	
						Console.WriteLine ("transition completed");
						trLayout = null;
					});
				}

				trLayout.TransitionProgress = (nfloat)progress;

				imagesController.CollectionView.CollectionViewLayout.InvalidateLayout ();

				if(g.State == UIGestureRecognizerState.Ended){
					if (trLayout.TransitionProgress > 0.5f)
						imagesController.CollectionView.FinishInteractiveTransition ();
					else
						imagesController.CollectionView.CancelInteractiveTransition ();
				}

			});

			imagesController.CollectionView.AddGestureRecognizer (pinch);

			window.RootViewController = imagesController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
		public override void ViewDidLoad ()
		{
			CollectionView.RegisterClassForCell (typeof (Cell), cellClass);

			var pinchRecognizer = new UIPinchGestureRecognizer (handlePinchGesture);
			handlePinchGesture (pinchRecognizer);

			CollectionView.AddGestureRecognizer (pinchRecognizer);
		}
		private void TrackGestureEnded (UIPinchGestureRecognizer pinchGestureRecognizer)
		{
			InteractionInProgress = false;
			if (!shouldCompleteTransition || pinchGestureRecognizer.State == UIGestureRecognizerState.Cancelled) {
				CancelInteractiveTransition ();
			} else {
				FinishInteractiveTransition ();
			}
		}
        protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
        {
            base.OnElementChanged (e);

            if (e.NewElement == null) {
                RemoveGestureRecognizer ();

                return;
            }

            var gestureView = e.NewElement as GestureAwareContentView;

            _longPressGestureRecognizer = new UILongPressGestureRecognizer (
                sender => {
                    var offset = sender.LocationInView(NativeView);

                    GestureUtil.ExecuteCommand(gestureView.LongPress,
                        new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y));
                });

            _pinchGestureRecognizer = new UIPinchGestureRecognizer (
                sender => {
                    var scale = sender.Scale;

                    GestureUtil.ExecuteCommand(gestureView.Pinch,
                        new GestureScale(sender.State.ToGestureState(), scale));
                });

            _panGestureRecognizer = new UIPanGestureRecognizer (
                sender => {
                    var offset = sender.TranslationInView(NativeView);

                    GestureUtil.ExecuteCommand(gestureView.Pan,
                        new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y));
                });

            _swipeGestureRecognizer = new UISwipeGestureRecognizer (
                sender => {
                    var offset = sender.LocationInView(NativeView);

                    GestureUtil.ExecuteCommand(gestureView.Swipe,
                        new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y));
                });

            _rotationGestureRecognizer = new UIRotationGestureRecognizer (
                sender => {
                    GestureUtil.ExecuteCommand (gestureView.Rotate);
                });

            AddGestureRecognizer (_longPressGestureRecognizer);
            AddGestureRecognizer (_pinchGestureRecognizer);
            AddGestureRecognizer (_panGestureRecognizer);
            AddGestureRecognizer (_swipeGestureRecognizer);
            AddGestureRecognizer (_rotationGestureRecognizer);
        }
        public void handlePinchGesture(UIPinchGestureRecognizer gesture)
        {
            if (gesture.State == UIGestureRecognizerState.Began)
            {
                scaleStart = this.scale;
            }
            else if (gesture.State == UIGestureRecognizerState.Changed)
            {
                this.scale = scaleStart * gesture.Scale;

                this.CollectionView.CollectionViewLayout.InvalidateLayout ();
            }
        }
        public PlayGroundView()
        {
            pinchGesture = new UIPinchGestureRecognizer (Scale);
            this.AddGestureRecognizer (pinchGesture);

            var rotationGesture = new UIRotationGestureRecognizer (Rotate);
            this.AddGestureRecognizer (rotationGesture);

            var panGesture = new UIPanGestureRecognizer (Move);
            this.AddGestureRecognizer (panGesture);

            this.BackgroundColor = UIColor.DarkGray;
        }
Beispiel #10
0
        public void Initialize()
        {
            Map = new Map();
            BackgroundColor = UIColor.White;
            _renderer = new MapRenderer(this);

            InitializeViewport();

            ClipsToBounds = true;

            var pinchGesture = new UIPinchGestureRecognizer(PinchGesture) { Enabled = true };
            AddGestureRecognizer(pinchGesture);
        }
        private void CreatePinchGestureRecognizer()
        {
            pinchGesture = new UIPinchGestureRecognizer(() =>
            {

                if ((pinchGesture.State == UIGestureRecognizerState.Began ||
                     pinchGesture.State == UIGestureRecognizerState.Changed) && (pinchGesture.NumberOfTouches == 2))
                {
                    pinchGesture.View.Transform *= CGAffineTransform.MakeScale(pinchGesture.Scale, pinchGesture.Scale);
                    pinchGesture.Scale = 1;
                }
             });
        }
        public FAViewController(UICollectionViewFlowLayout layout, FAViewSize size)
            : base(layout)
        {
            _fasize = size;

            _datasource = FA.Empty.Values();
            _searchresult = _datasource;
            _searchbar = new UISearchBar ();
            _searchbar.SearchBarStyle = UISearchBarStyle.Prominent;
            _pinchrecognizer = new UIPinchGestureRecognizer (PinchDetected);

            var searchdelegate = new UISearchFADelegate(this, _searchbar);
            _searchbar.Delegate = searchdelegate;
        }
		private void TrackGestureBegan (UIPinchGestureRecognizer pinchGestureRecognizer)
		{
			startScale = pinchGestureRecognizer.Scale;

			// start an interactive transition!
			InteractionInProgress = true;

			// perform the required operation
			if (operation == CEInteractionOperation.Pop) {
				viewController.NavigationController.PopViewController (true);
			} else {
				viewController.DismissViewController (true, null);
			}
		}
		public void HandlePinch (UIPinchGestureRecognizer pinchGestureRecognizer)
		{
			switch (gestureRecognizer.State) {
			case UIGestureRecognizerState.Began:
				TrackGestureBegan (pinchGestureRecognizer);
				break;
			case UIGestureRecognizerState.Changed:
				TrackGestureChaged (pinchGestureRecognizer);
				break;
			case UIGestureRecognizerState.Ended:
			case UIGestureRecognizerState.Cancelled:
				TrackGestureEnded (pinchGestureRecognizer);
				break;
			}
		}
		public void HandlePinch (UIPinchGestureRecognizer sender)
		{
			if (sender.NumberOfTouches < 2)
				return;

			PointF point1 = sender.LocationOfTouch (0, sender.View);
			PointF point2 = sender.LocationOfTouch (1, sender.View);
			float distance = (float) Math.Sqrt ((point1.X - point2.X) * (point1.X - point2.X) +
			                                    (point1.Y - point2.Y) * (point1.Y - point2.Y));
			PointF point = sender.LocationInView (sender.View);

			if (sender.State == UIGestureRecognizerState.Began) {
				if (HasActiveInteraction)
					return;

				initialPinchDistance = distance;
				initialPinchPoint = point;
				HasActiveInteraction = true;
				InteractionBegan (point);
				return;
			}

			if (!HasActiveInteraction)
				return;

			switch (sender.State) {
			case UIGestureRecognizerState.Changed:
				float offsetX = point.X - initialPinchPoint.X;
				float offsetY = point.Y - initialPinchPoint.Y;
				float distanceDelta = distance - initialPinchDistance;

				if (NavigationOperation == UINavigationControllerOperation.Pop)
					distanceDelta = -distanceDelta;

				SizeF size = collectionView.Bounds.Size;
				float dimension = (float)Math.Sqrt (size.Width * size.Width + size.Height * size.Height);
				float progress = (float) Math.Max (Math.Min (distanceDelta / dimension, 1.0), 0.0);
				Update (progress, new UIOffset (offsetX, offsetY));
				break;
			case UIGestureRecognizerState.Ended:
				EndInteraction (true);
				break;
			case UIGestureRecognizerState.Cancelled:
				EndInteraction (false);
				break;
			}
		}
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_swipeDown != null)
         {
             _swipeDown.Dispose();
             _swipeDown = null;
         }
         if (_swipeLeft != null)
         {
             _swipeLeft.Dispose();
             _swipeLeft = null;
         }
         if (_swipeRight != null)
         {
             _swipeRight.Dispose();
             _swipeRight = null;
         }
         if (_swipeUp != null)
         {
             _swipeUp.Dispose();
             _swipeUp = null;
         }
         if (_doubleTap != null)
         {
             _doubleTap.Dispose();
             _doubleTap = null;
         }
         if (_singleTap != null)
         {
             _singleTap.Dispose();
             _singleTap = null;
         }
         if (_pinch != null)
         {
             _pinch.Dispose();
             _pinch = null;
         }
     }
     // don't try and dispose the base - it will try and dispose of the native control that we didn't create
     //base.Dispose(disposing);
 }
		public void handlePinchGesture (UIPinchGestureRecognizer sender)
		{
			PinchLayout pinchLayout = (PinchLayout) CollectionView.CollectionViewLayout;

			switch (sender.State) {
			case UIGestureRecognizerState.Began:
				CGPoint initialPinchPoint = sender.LocationInView (CollectionView);
				pinchLayout.pinchedCellPath = CollectionView.IndexPathForItemAtPoint (initialPinchPoint);
				break;
			case UIGestureRecognizerState.Changed:
				pinchLayout.setPinchedCellScale ((float)sender.Scale);
				pinchLayout.setPinchedCellCenter (sender.LocationInView (CollectionView));
				break;
			default:
				CollectionView.PerformBatchUpdates (delegate {
					pinchLayout.pinchedCellPath = null;
					pinchLayout.setPinchedCellScale (1.0f);
				}, null);
				break;
			}
		}
		protected override void OnElementChanged (ElementChangedEventArgs<Label> e)
		{
			base.OnElementChanged (e);

			longPressGestureRecognizer = new UILongPressGestureRecognizer (() => Console.WriteLine ("Long Press"));
			pinchGestureRecognizer = new UIPinchGestureRecognizer (() => Console.WriteLine ("Pinch"));
			panGestureRecognizer = new UIPanGestureRecognizer (() => Console.WriteLine ("Pan"));
			swipeGestureRecognizer = new UISwipeGestureRecognizer (() => Console.WriteLine ("Swipe"));
			rotationGestureRecognizer = new UIRotationGestureRecognizer (() => Console.WriteLine ("Rotation"));

			if (e.NewElement == null) {
				if (longPressGestureRecognizer != null) {
					this.RemoveGestureRecognizer (longPressGestureRecognizer);
				}
				if (pinchGestureRecognizer != null) {
					this.RemoveGestureRecognizer (pinchGestureRecognizer);
				}
				if (panGestureRecognizer != null) {
					this.RemoveGestureRecognizer (panGestureRecognizer);
				}
				if (swipeGestureRecognizer != null) {
					this.RemoveGestureRecognizer (swipeGestureRecognizer);
				}
				if (rotationGestureRecognizer != null) {
					this.RemoveGestureRecognizer (rotationGestureRecognizer);
				}
			}

			if (e.OldElement == null) {
				this.AddGestureRecognizer (longPressGestureRecognizer);
				this.AddGestureRecognizer (pinchGestureRecognizer);
				this.AddGestureRecognizer (panGestureRecognizer);
				this.AddGestureRecognizer (swipeGestureRecognizer);
				this.AddGestureRecognizer (rotationGestureRecognizer);
			}
		}
        protected void PinchDetected(UIPinchGestureRecognizer pinch)
        {
            if (pinch.State != UIGestureRecognizerState.Ended) {
                return;
            }

            var location = pinch.LocationInView (CollectionView);
            var path = CollectionView.IndexPathForItemAtPoint (location);
            if (path == null) {
                var visiblecells = CollectionView.IndexPathsForVisibleItems;
                int center = visiblecells.Length / 2;
                path = visiblecells [center];
            }
            if (pinch.Scale > 1) {
                _fasize.Increment ();
            }

            if (pinch.Scale < 1) {
                _fasize.Decrement ();
            }

            Zoom (path);
        }
Beispiel #20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            using (var data = NSData.FromFile("picture.jpg"))
            {
                startImage = UIImage.LoadFromData(data);
                ratio      = startImage.Size.Width / startImage.Size.Height;
                height     = (App.ScreenWidth) / ratio;
                center     = (App.ScreenHeight - height) / 2;
                width      = App.ScreenWidth;
                UIGraphics.BeginImageContextWithOptions(new CGSize(App.ScreenWidth, App.ScreenHeight), true, 1.0f);
                startImage.Draw(new CGRect(0, center, width, height));
                resultImage = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();


                var testh2 = resultImage.Size.Height;
                var testw2 = resultImage.Size.Width;
                cropperView = new CropperView();
                var test = new UIImageView(new CGRect(0, 0, App.ScreenWidth, App.ScreenHeight));
                test.Image            = resultImage;
                imageViewToMove       = new ImageViewToMove();
                imageViewToMove.Frame = test.Frame;
                cropperView.Frame     = View.Frame;
                var h = (App.ScreenWidth * 0.9);
                if (h > height)
                {
                    h = height - 10;
                }
                cropperView.CropSize = new CGSize(h, h);
                cropperView.Origin   = new CGPoint((App.ScreenWidth - h) / 2, center + ((height - h) / 2));

                imageViewToMove.ImgX          = 0;
                imageViewToMove.ImgY          = 0;
                imageViewToMove.ImgW          = App.ScreenWidth;
                imageViewToMove.ImgH          = App.ScreenHeight;
                imageViewToMove.ImageViewCrop = test;
            }
            var centerButtonX = View.Bounds.GetMidX() - 35f;
            var bottomButtonY = View.Bounds.Bottom - 70;
            var btn           = new UIButton()
            {
                Frame = new CGRect(0, bottomButtonY, App.ScreenWidth / 2, 70)
            };

            btn.BackgroundColor = UIColor.FromRGB(219, 179, 74);
            btn.SetTitle("Done", UIControlState.Normal);
            btn.SetTitleColor(UIColor.White, UIControlState.Normal);

            View.AddSubviews(imageViewToMove, cropperView, btn);
            View.BackgroundColor = UIColor.Black;
            nfloat dx = 0;
            nfloat dy = 0;

            pan1 = new UIPanGestureRecognizer(() =>
            {
                if ((pan1.State == UIGestureRecognizerState.Began ||
                     pan1.State == UIGestureRecognizerState.Changed) && (pan1.NumberOfTouches == 1))
                {
                    var p0 = pan1.LocationInView(View);

                    if (dx == 0)
                    {
                        dx = p0.X - (nfloat)imageViewToMove.ImgX;
                    }

                    if (dy == 0)
                    {
                        dy = p0.Y - (nfloat)imageViewToMove.ImgY;
                    }
                    imageViewToMove.ImgX          = p0.X - dx;
                    imageViewToMove.ImgY          = p0.Y - dy;
                    var test                      = new UIImageView(new CGRect(imageViewToMove.ImgX, imageViewToMove.ImgY, imageViewToMove.ImgW, imageViewToMove.ImgH));
                    test.Image                    = resultImage;
                    imageViewToMove.ImageViewCrop = test;
                }
                else if (pan1.State == UIGestureRecognizerState.Ended)
                {
                    dx = 0;
                    dy = 0;
                }
            });

            nfloat s0 = 1;

            pinch1 = new UIPinchGestureRecognizer(() =>
            {
                nfloat s         = pinch1.Scale;
                nfloat ds        = (nfloat)Math.Abs(s - s0);
                nfloat sf        = 0;
                const float rate = 0.5f;
                if (s >= s0)
                {
                    sf = 1 + ds * rate;
                }
                else if (s < s0)
                {
                    sf = 1 - ds * rate;
                }
                s0 = s;
                imageViewToMove.ImgW = imageViewToMove.ImgW * sf;
                imageViewToMove.ImgH = imageViewToMove.ImgH * sf;
                imageViewToMove.ImgX = imageViewToMove.ImgX * sf;
                imageViewToMove.ImgY = imageViewToMove.ImgY * sf;
                height     = height * sf;
                center     = center * sf;
                var test   = new UIImageView(new CGRect(imageViewToMove.ImgX, imageViewToMove.ImgY, imageViewToMove.ImgW, imageViewToMove.ImgH));
                test.Image = resultImage;
                imageViewToMove.ImageViewCrop = test;
                if (pinch1.State == UIGestureRecognizerState.Ended)
                {
                    s0 = 1;
                }
            });

            doubleTap = new UITapGestureRecognizer((gesture) => Crop())
            {
            };


            btn.AddGestureRecognizer(doubleTap);
            cropperView.AddGestureRecognizer(pan1);
            cropperView.AddGestureRecognizer(pinch1);
        }
Beispiel #21
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;
        }
Beispiel #22
0
        public UIView getLargeView()
        {
            this.largeView.UserInteractionEnabled = true;
            this.largeView.MultipleTouchEnabled   = true;
            this.largeView.ClipsToBounds          = true;
            this.largeView.Frame = new CGRect(Constants.MAIN_ORIGIN_X, Constants.MAIN_ORIGIN_Y,
                                              Constants.MAIN_WIDTH, Constants.CONTENT_HEIGHT);
            //adding largeImage

            this.largeImage.BackgroundColor = UIColor.Red;

            this.largeImage.Frame = this.largeView.Frame;
            //this.largeImage.UserInteractionEnabled = true;
            //this.largeImage.MultipleTouchEnabled = true;

            var panGesture = new UIPanGestureRecognizer((g) =>
            {
                if (g.State == UIGestureRecognizerState.Changed && g.NumberOfTouches == 2)
                {
                    var t = g.TranslationInView(largeView);
                    var imageViewPosition = largeView.Center;
                    imageViewPosition.X  += t.X;
                    imageViewPosition.Y  += t.Y;
                    largeView.Center      = imageViewPosition;
                    g.SetTranslation(new PointF(), largeView.Superview);
                }
                if (g.State == UIGestureRecognizerState.Cancelled || g.State == UIGestureRecognizerState.Ended)
                {
                    largeTouchesEnd("pan");
                }
            });

            panGesture.MinimumNumberOfTouches = 2;
            panGesture.MaximumNumberOfTouches = 2;
            var pinchGesture = new UIPinchGestureRecognizer((g) =>
            {
                if (g.State == UIGestureRecognizerState.Began)
                {
                    largeView.Transform = CGAffineTransform.MakeIdentity();
                    g.Scale             = 1.0f;
                }
                if (g.State == UIGestureRecognizerState.Cancelled || g.State == UIGestureRecognizerState.Ended)
                {
                    largeTouchesEnd("scale");
                }
                //_scale = g.Scale;
                if (g.State == UIGestureRecognizerState.Changed)
                {
                    var midPoint        = g.LocationInView(largeView.Superview);
                    CGAffineTransform s = largeView.Transform;
                    s.Scale(g.Scale, g.Scale);
                    largeView.Center    = midPoint;
                    largeView.Transform = s;
                    //Console.WriteLine("affine +     " + s);
                    g.Scale = 1.0f;
                }
            });
            var rotateGesture = new UIRotationGestureRecognizer((g) =>
            {
                //_angle = g.Rotation;
                if (g.State == UIGestureRecognizerState.Changed)
                {
                    CGAffineTransform r = largeView.Transform;
                    var midPoint        = g.LocationInView(largeView.Superview);
                    largeView.Center    = midPoint;
                    r.Rotate(g.Rotation);
                    largeView.Transform = r;                             //.Rotate(_angle);// = MakeTransform();
                    g.Rotation          = 0.0f;
                }
                if (g.State == UIGestureRecognizerState.Cancelled || g.State == UIGestureRecognizerState.Ended)
                {
                    largeTouchesEnd("rotate");
                }
            });

            panGesture.ShouldRecognizeSimultaneously    = (gesture1, gesture2) => true;
            pinchGesture.ShouldRecognizeSimultaneously  = (gesture1, gesture2) => true;
            rotateGesture.ShouldRecognizeSimultaneously = (gesture1, gesture2) => true;

            largeView.AddGestureRecognizer(panGesture);
            largeView.AddGestureRecognizer(pinchGesture);
            largeView.AddGestureRecognizer(rotateGesture);

            //largeview will manage the view when it belongs to the pageviewcontroller
            // @todo
            //this.largeView.AddSubview(this.largeImage);

            return(this.largeView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            using (var image = UIImage.FromFile("monkey.png")) {
                imageView       = new UIImageView(new CGRect(0, 0, image.Size.Width, image.Size.Height));
                imageView.Image = image;
            }

            cropperView = new CropperView {
                Frame = View.Frame
            };
            View.AddSubviews(imageView, cropperView);

            nfloat dx = 0;
            nfloat dy = 0;

            pan = new UIPanGestureRecognizer(() => {
                if ((pan.State == UIGestureRecognizerState.Began || pan.State == UIGestureRecognizerState.Changed) && (pan.NumberOfTouches == 1))
                {
                    var p0 = pan.LocationInView(View);

                    if (dx == 0)
                    {
                        dx = p0.X - cropperView.Origin.X;
                    }

                    if (dy == 0)
                    {
                        dy = p0.Y - cropperView.Origin.Y;
                    }

                    var p1 = new CGPoint(p0.X - dx, p0.Y - dy);

                    cropperView.Origin = p1;
                }
                else if (pan.State == UIGestureRecognizerState.Ended)
                {
                    dx = 0;
                    dy = 0;
                }
            });

            nfloat s0 = 1;

            pinch = new UIPinchGestureRecognizer(() => {
                nfloat s         = pinch.Scale;
                nfloat ds        = (nfloat)Math.Abs(s - s0);
                nfloat sf        = 0;
                const float rate = 0.5f;

                if (s >= s0)
                {
                    sf = 1 + ds * rate;
                }
                else if (s < s0)
                {
                    sf = 1 - ds * rate;
                }
                s0 = s;

                cropperView.CropSize = new CGSize(cropperView.CropSize.Width * sf, cropperView.CropSize.Height * sf);

                if (pinch.State == UIGestureRecognizerState.Ended)
                {
                    s0 = 1;
                }
            });

            doubleTap = new UITapGestureRecognizer((gesture) => Crop())
            {
                NumberOfTapsRequired = 2, NumberOfTouchesRequired = 1
            };

            cropperView.AddGestureRecognizer(pan);
            cropperView.AddGestureRecognizer(pinch);
            cropperView.AddGestureRecognizer(doubleTap);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            // get the element
            var gestureView = (GestureView)this.Element;

            // setup the swipe actions
            _swipeDown = new UISwipeGestureRecognizer(() =>
            {
                gestureView.OnSwipeDown();
            })
            {
                Direction = UISwipeGestureRecognizerDirection.Down
            };

            _swipeUp = new UISwipeGestureRecognizer(() =>
            {
                gestureView.OnSwipeUp();
            })
            {
                Direction = UISwipeGestureRecognizerDirection.Up
            };

            _swipeLeft = new UISwipeGestureRecognizer(() =>
            {
                gestureView.OnSwipeLeft();
            })
            {
                Direction = UISwipeGestureRecognizerDirection.Left
            };

            _swipeRight = new UISwipeGestureRecognizer(() =>
            {
                gestureView.OnSwipeRight();
            })
            {
                Direction = UISwipeGestureRecognizerDirection.Right
            };

            // setup the tap gesture
            _singleTap = new UITapGestureRecognizer(() =>
            {
                gestureView.OnSingleTap();
            })
            {
                NumberOfTapsRequired = 1
            };
            _doubleTap = new UITapGestureRecognizer(() =>
            {
                gestureView.OnDoubleTap();
            })
            {
                NumberOfTapsRequired = 2
            };

            // setup the pinch gesture
            _pinch = new UIPinchGestureRecognizer(() =>
            {
                gestureView.PinchScale    = _pinch.Scale;
                gestureView.PinchVelocity = _pinch.Velocity;
                switch (_pinch.State)
                {
                case UIGestureRecognizerState.Began:
                    gestureView.CurrentPinchState = GestureView.PinchGestureState.Started;
                    break;

                case UIGestureRecognizerState.Changed:
                    gestureView.CurrentPinchState = GestureView.PinchGestureState.Continuing;
                    break;

                case UIGestureRecognizerState.Ended:
                    gestureView.CurrentPinchState = GestureView.PinchGestureState.Ended;
                    break;
                }
                gestureView.OnPinch();
            });

            // remove the gesture when the control is removed
            if (e.NewElement == null)
            {
                if (_swipeDown != null)
                {
                    this.RemoveGestureRecognizer(_swipeDown);
                }
                if (_swipeLeft != null)
                {
                    this.RemoveGestureRecognizer(_swipeLeft);
                }
                if (_swipeRight != null)
                {
                    this.RemoveGestureRecognizer(_swipeRight);
                }
                if (_swipeUp != null)
                {
                    this.RemoveGestureRecognizer(_swipeUp);
                }
                if (_doubleTap != null)
                {
                    this.RemoveGestureRecognizer(_doubleTap);
                }
                if (_singleTap != null)
                {
                    this.RemoveGestureRecognizer(_singleTap);
                }
                if (_pinch != null)
                {
                    this.RemoveGestureRecognizer(_pinch);
                }
            }

            // only add the gesture when the control is not being reused
            if (e.OldElement == null)
            {
                this.AddGestureRecognizer(_swipeDown);
                this.AddGestureRecognizer(_swipeLeft);
                this.AddGestureRecognizer(_swipeRight);
                this.AddGestureRecognizer(_swipeUp);
                this.AddGestureRecognizer(_doubleTap);
                this.AddGestureRecognizer(_singleTap);
                this.AddGestureRecognizer(_pinch);
            }
        }
Beispiel #25
0
		UIPinchGestureRecognizer CreatePinchRecognizer(Action<UIPinchGestureRecognizer> action)
		{
			var result = new UIPinchGestureRecognizer(action);
			return result;
		}
Beispiel #26
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;
        }
Beispiel #27
0
 public void PinchGestureRecognizer(UIPinchGestureRecognizer sender)
 {
     TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.Pinch, new TimeSpan(_nowUpdate.Ticks), new Vector2(sender.LocationOfTouch(0, sender.View)), new Vector2(sender.LocationOfTouch(1, sender.View)), new Vector2(0, 0), new Vector2(0, 0)));
 }
        public void ReLoadView(bool roate)
        {
            cropperView = new CropperView((imageHeight - 200) / 2, (imageWidth - 200) / 2, 200, 200)
            {
                Frame = mainImageView.Frame
            };
            mainContainer.AddSubviews(mainImageView, cropperView);
            nfloat dx = 0;
            nfloat dy = 0;

            pan = new UIPanGestureRecognizer(() =>
            {
                if ((pan.State == UIGestureRecognizerState.Began || pan.State == UIGestureRecognizerState.Changed) && (pan.NumberOfTouches == 1))
                {
                    var p0 = pan.LocationInView(View);

                    if (dx == 0)
                    {
                        dx = p0.X - cropperView.Origin.X;
                    }

                    if (dy == 0)
                    {
                        dy = p0.Y - cropperView.Origin.Y;
                    }

                    var p1             = new CGPoint(p0.X - dx, p0.Y - dy);
                    cropperView.Origin = p1;
                }
                else if (pan.State == UIGestureRecognizerState.Ended)
                {
                    dx = 0;
                    dy = 0;
                }
            });

            nfloat s0 = 1;

            pinch = new UIPinchGestureRecognizer(() =>
            {
                nfloat s         = pinch.Scale;
                nfloat ds        = (nfloat)Math.Abs(s - s0);
                nfloat sf        = 0;
                const float rate = 0.5f;

                if (s >= s0)
                {
                    sf = 1 + ds * rate;
                }
                else if (s < s0)
                {
                    sf = 1 - ds * rate;
                }
                s0 = s;

                cropperView.CropSize = new CGSize(cropperView.CropSize.Width * sf, cropperView.CropSize.Height * sf);

                if (pinch.State == UIGestureRecognizerState.Ended)
                {
                    s0 = 1;
                }
            });

            cropperView.AddGestureRecognizer(pan);
            cropperView.AddGestureRecognizer(pinch);
        }
Beispiel #29
0
        private void Initialize()
        {
			BackgroundColor = GlobalTheme.BackgroundColor;
			UserInteractionEnabled = true;
			MultipleTouchEnabled = true;

			_doubleTapGesture = new UITapGestureRecognizer(HandleDoubleTapGestureRecognizer);
            _doubleTapGesture.DelaysTouchesBegan = true;
            _doubleTapGesture.NumberOfTapsRequired = 2;
			AddGestureRecognizer(_doubleTapGesture);
            
			_pinchGesture = new UIPinchGestureRecognizer(HandlePinchGestureRecognizer);
            AddGestureRecognizer(_pinchGesture);

			_panGesture = new UIPanGestureRecognizer(HandlePanGestureRecognizer);
			_panGesture.MinimumNumberOfTouches = 1;
			_panGesture.MaximumNumberOfTouches = 1;
			AddGestureRecognizer(_panGesture);

            WaveFormView = new SessionsWaveFormView(new RectangleF(0, _scaleHeight, Bounds.Width, Bounds.Height - _scaleHeight));
            AddSubview(WaveFormView);

            WaveFormScaleView = new SessionsWaveFormScaleView(new RectangleF(0, 0, Bounds.Width, _scaleHeight));
            AddSubview(WaveFormScaleView);

			WaveFormView.AddGestureRecognizer(_doubleTapGesture);

            _lblZoom = new UILabel(new RectangleF(0, 0, 60, 20));
            _lblZoom.BackgroundColor = GlobalTheme.BackgroundColor;
            _lblZoom.TextColor = UIColor.White;
			_lblZoom.Font = UIFont.FromName("HelveticaNeue", 11);
            _lblZoom.TextAlignment = UITextAlignment.Center;
            _lblZoom.Text = "100.0%";
            _lblZoom.Alpha = 0;
            AddSubview(_lblZoom);

            _viewCenterLine = new UIView(new RectangleF(Bounds.Width / 2, 0, 1, Bounds.Height));
            _viewCenterLine.BackgroundColor = GlobalTheme.LightColor;
            _viewCenterLine.Alpha = 0;
            AddSubview(_viewCenterLine);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            screenSize                    = UIScreen.MainScreen.Bounds.Size;
            mainContainer                 = new UIView();
            mainContainer.Frame           = new CGRect(0, 0, screenSize.Width, screenSize.Height);
            mainContainer.BackgroundColor = UIColor.Black;
            this.View.AddSubview(mainContainer);

            double maxWidth  = screenSize.Width;
            double maxHeight = screenSize.Height;

            // Bottom Bar, which will contain the controlls
            UIView bottomBar = new UIView();

            bottomBar.Frame           = new CGRect(0, screenSize.Height - 70, screenSize.Width, 50);
            bottomBar.BackgroundColor = UIColor.Black;
            mainContainer.AddSubview(bottomBar);

            // Adding Items to bottom bar
            var btnCancel = new UIButton(new CGRect(30, 10, 100, 30));

            btnCancel.SetTitle("Cancel", UIControlState.Normal);
            btnCancel.SetTitleColor(UIColor.White, UIControlState.Normal);
            btnCancel.BackgroundColor = UIColor.Clear;
            btnCancel.TouchUpInside  += async(s, e) =>
            {
                await this.DismissViewControllerAsync(true);

                _callback?.Invoke(false);
            };
            bottomBar.AddSubview(btnCancel);

            UIButton rotationButton = new UIButton();

            image = new UIImage("rotate_button.png");
            rotationButton.Frame = new CGRect(screenSize.Width / 2 - 40, 10, 80, 30);
            rotationButton.SetImage(image, UIControlState.Normal);
            rotationButton.AddTarget((s, e) => { RotateImageTapped(); }, UIControlEvent.TouchUpInside);
            bottomBar.AddSubview(rotationButton);


            var btnSave = new UIButton(new CGRect(screenSize.Width - 120, 10, 100, 30));

            btnSave.SetTitle("Save", UIControlState.Normal);
            btnSave.SetTitleColor(UIColor.White, UIControlState.Normal);
            btnSave.BackgroundColor = UIColor.Clear;
            btnSave.TouchUpInside  += Crop;
            bottomBar.AddSubview(btnSave);

            if (ImagePath == null)
            {
                return;
            }
            using (var image = UIImage.FromFile(ImagePath))
            {
                imageWidth          = Math.Min(image.Size.Width, maxWidth);
                imageHeight         = imageWidth * image.Size.Height / image.Size.Width;
                mainImageView       = new UIImageView(new CGRect(0, ((screenSize.Height - 70) - imageHeight) / 2, imageWidth, imageHeight));
                mainImageView.Image = image;
                xRatio = image.Size.Width / imageWidth;
                yRatio = image.Size.Height / imageHeight;
            }
            double cropW = Math.Min(imageWidth, imageHeight) > 300 ? 300 : 200;

            cropperView = new CropperView((imageWidth - cropW) / 2, (imageHeight - cropW) / 2, cropW, cropW)
            {
                Frame = mainImageView.Frame
            };
            mainContainer.AddSubviews(mainImageView, cropperView);

            nfloat dx = 0;
            nfloat dy = 0;

            pan = new UIPanGestureRecognizer(() =>
            {
                if ((pan.State == UIGestureRecognizerState.Began || pan.State == UIGestureRecognizerState.Changed) && (pan.NumberOfTouches == 1))
                {
                    var p0 = pan.LocationInView(View);

                    if (dx == 0)
                    {
                        dx = p0.X - cropperView.Origin.X;
                    }

                    if (dy == 0)
                    {
                        dy = p0.Y - cropperView.Origin.Y;
                    }

                    var p1             = new CGPoint(p0.X - dx, p0.Y - dy);
                    cropperView.Origin = p1;
                }
                else if (pan.State == UIGestureRecognizerState.Ended)
                {
                    dx = 0;
                    dy = 0;
                }
            });

            nfloat s0 = 1;

            pinch = new UIPinchGestureRecognizer(() =>
            {
                nfloat s         = pinch.Scale;
                nfloat ds        = (nfloat)Math.Abs(s - s0);
                nfloat sf        = 0;
                const float rate = 0.5f;

                if (s >= s0)
                {
                    sf = 1 + ds * rate;
                }
                else if (s < s0)
                {
                    sf = 1 - ds * rate;
                }
                s0 = s;

                cropperView.CropSize = new CGSize(cropperView.CropSize.Width * sf, cropperView.CropSize.Height * sf);

                if (pinch.State == UIGestureRecognizerState.Ended)
                {
                    s0 = 1;
                }
            });

            cropperView.AddGestureRecognizer(pan);
            cropperView.AddGestureRecognizer(pinch);
        }
        UIPinchGestureRecognizer CreatePinchRecognizer(Action <UIPinchGestureRecognizer> action)
        {
            var result = new UIPinchGestureRecognizer(action);

            return(result);
        }
		// Scales the image by the current scale
		void ScaleImage (UIPinchGestureRecognizer gestureRecognizer)
		{
			AdjustAnchorPointForGestureRecognizer (gestureRecognizer);
			if (gestureRecognizer.State == UIGestureRecognizerState.Began || gestureRecognizer.State == UIGestureRecognizerState.Changed) {
				gestureRecognizer.View.Transform *= CGAffineTransform.MakeScale (gestureRecognizer.Scale, gestureRecognizer.Scale);
				// Reset the gesture recognizer's scale - the next callback will get a delta from the current scale.
				gestureRecognizer.Scale = 1;
			}
		}
		private void PrepareGestureRecognizerInView (UIView view)
		{
			gestureRecognizer = new UIPinchGestureRecognizer (HandlePinch);
			view.AddGestureRecognizer (gestureRecognizer);
		}
		// Add gesture recognizers to one of our images
		void AddGestureRecognizersToImage (UIImageView image)
		{
			image.UserInteractionEnabled = true;
			
			var rotationGesture = new UIRotationGestureRecognizer (RotateImage);
			image.AddGestureRecognizer (rotationGesture);
			
			var pinchGesture = new UIPinchGestureRecognizer (ScaleImage);
			pinchGesture.Delegate = new GestureDelegate (this);
			image.AddGestureRecognizer (pinchGesture);
			
			var panGesture = new UIPanGestureRecognizer (PanImage);
			panGesture.MaximumNumberOfTouches = 2;
			panGesture.Delegate = new GestureDelegate (this);
			image.AddGestureRecognizer (panGesture);
			
			var longPressGesture = new UILongPressGestureRecognizer (ShowResetMenu);
			image.AddGestureRecognizer (longPressGesture);
		}
        public RegisterCommonMethods(BaseActivity context, CommonMethods c, ImageFrameLayout ImagesUploaded, UITextField Email, UITextField Username, UITextField Name, UITextView DescriptionText, UIButton CheckUsername, UIButton Images,
                                     UILabel ImagesProgressText, UIImageView LoaderCircle, UIProgressView ImagesProgress, UISwitch UseLocationSwitch, UISwitch LocationShareAll, UISwitch LocationShareLike, UISwitch LocationShareMatch, UISwitch LocationShareFriend, UISwitch LocationShareNone,
                                     UISwitch DistanceShareAll, UISwitch DistanceShareLike, UISwitch DistanceShareMatch, UISwitch DistanceShareFriend, UISwitch DistanceShareNone, UIView ImageEditorControls, UIImageView TopSeparator, UIImageView RippleImageEditor, UIView ImageEditorStatus, UIButton ImageEditorCancel, UIButton ImageEditorOK, UIImageView ImageEditor, UIView ImageEditorFrame, UIView ImageEditorFrameBorder)
        {
            this.context = context;
            this.c       = c;

            this.ImagesUploaded         = ImagesUploaded;
            this.Email                  = Email;
            this.Username               = Username;
            this.Name                   = Name;
            this.DescriptionText        = DescriptionText;
            this.CheckUsername          = CheckUsername;
            this.Images                 = Images;
            this.ImagesProgressText     = ImagesProgressText;
            this.LoaderCircle           = LoaderCircle;
            this.ImagesProgress         = ImagesProgress;
            this.UseLocationSwitch      = UseLocationSwitch;
            this.LocationShareAll       = LocationShareAll;
            this.LocationShareLike      = LocationShareLike;
            this.LocationShareMatch     = LocationShareMatch;
            this.LocationShareFriend    = LocationShareFriend;
            this.LocationShareNone      = LocationShareNone;
            this.DistanceShareAll       = DistanceShareAll;
            this.DistanceShareLike      = DistanceShareLike;
            this.DistanceShareMatch     = DistanceShareMatch;
            this.DistanceShareFriend    = DistanceShareFriend;
            this.DistanceShareNone      = DistanceShareNone;
            this.ImageEditorControls    = ImageEditorControls;
            this.TopSeparator           = TopSeparator;
            this.RippleImageEditor      = RippleImageEditor;
            this.ImageEditorStatus      = ImageEditorStatus;
            this.ImageEditorCancel      = ImageEditorCancel;
            this.ImageEditorOK          = ImageEditorOK;
            this.ImageEditor            = ImageEditor;
            this.ImageEditorFrame       = ImageEditorFrame;
            this.ImageEditorFrameBorder = ImageEditorFrameBorder;

            CheckUsername.TouchUpInside += CheckUsername_Click;
            Images.TouchUpInside        += Images_Click;

            UseLocationSwitch.TouchUpInside   += UseLocationSwitch_Click;
            LocationShareAll.TouchUpInside    += LocationShareAll_Click;
            LocationShareLike.TouchUpInside   += LocationShareLike_Click;
            LocationShareMatch.TouchUpInside  += LocationShareMatch_Click;
            LocationShareFriend.TouchUpInside += LocationShareFriend_Click;
            LocationShareNone.TouchUpInside   += LocationShareNone_Click;

            DistanceShareAll.TouchUpInside    += DistanceShareAll_Click;
            DistanceShareLike.TouchUpInside   += DistanceShareLike_Click;
            DistanceShareMatch.TouchUpInside  += DistanceShareMatch_Click;
            DistanceShareFriend.TouchUpInside += DistanceShareFriend_Click;
            DistanceShareNone.TouchUpInside   += DistanceShareNone_Click;

            ImageEditorCancel.TouchDown += ImageEditorButton_TouchDown;
            ImageEditorOK.TouchDown     += ImageEditorButton_TouchDown;

            UIPanGestureRecognizer move = new UIPanGestureRecognizer();

            move.AddTarget(() => MoveImage(move));
            ImageEditor.AddGestureRecognizer(move);

            UIPinchGestureRecognizer zoom = new UIPinchGestureRecognizer();

            zoom.AddTarget(() => ZoomImage(zoom));
            ImageEditor.AddGestureRecognizer(zoom);

            client = new WebClient();
            client.UploadProgressChanged += Client_UploadProgressChanged;
            client.UploadFileCompleted   += Client_UploadFileCompleted;
            client.Headers.Add("Content-Type", "image/jpeg");
        }
Beispiel #36
0
        /// <summary>
        /// Pinch the specified pinch.
        /// </summary>
        /// <param name="pinch">Pinch.</param>
        private void Pinch(UIPinchGestureRecognizer pinch)
        {
            //RectangleF2D rect = _rect;
            RectangleF rect = this.Frame;
            if (this.MapAllowZoom &&
                rect.Width > 0)
            {
                this.StopCurrentAnimation();
                if (pinch.State == UIGestureRecognizerState.Ended)
                {
            //					_mapZoom = _mapZoomLevelBefore.Value;
            //
            //					double zoomFactor = this.Map.Projection.ToZoomFactor (this.MapZoom);
            //					zoomFactor = zoomFactor * pinch.Scale;
            //					_mapZoom = (float)this.Map.Projection.ToZoomLevel (zoomFactor);
            //
            //					this.NormalizeZoom ();

                    this.Change(true); // notifies change.

                    _mapZoomLevelBefore = null;
                }
                else if (pinch.State == UIGestureRecognizerState.Began)
                {
                    _mapZoomLevelBefore = _mapZoom;
                }
                else
                {
                    _mapZoom = _mapZoomLevelBefore.Value;

                    double zoomFactor = this.Map.Projection.ToZoomFactor(_mapZoom);
                    zoomFactor = zoomFactor * pinch.Scale;
                    _mapZoom = (float)this.Map.Projection.ToZoomLevel(zoomFactor);

                    this.NormalizeZoom();

                    this.InvokeOnMainThread(InvalidateMap);
                }
            }
        }
Beispiel #37
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitElements();

            var circleLayer = new CAShapeLayer();
            var circlePath  = UIBezierPath.FromRect(cadreIV.Frame);

            circlePath.UsesEvenOddFillRule = true;
            circleLayer.Path = circlePath.CGPath;
            var maskPath = UIBezierPath.FromRect(new CGRect(0, (int)headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2, View.Frame.Width, (int)(View.Frame.Height - (headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2 + View.Frame.Width / 8))));

            maskPath.AppendPath(circlePath);
            maskPath.UsesEvenOddFillRule = true;
            fillLayer.Path      = maskPath.CGPath;
            fillLayer.FillRule  = CAShapeLayer.FillRuleEvenOdd;
            fillLayer.FillColor = maskColor.CGColor;

            View.Layer.AddSublayer(fillLayer);

            nfloat width_height_ratio;
            int    image_height, image_width;

            if (imageView.Image.Size.Height > imageView.Image.Size.Width)
            {
                width_height_ratio = imageView.Image.Size.Height / imageView.Image.Size.Width;
                image_width        = (int)View.Frame.Width;
                image_height       = (int)(image_width * width_height_ratio);
                imageView.Frame    = new Rectangle(0, (int)(headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2), image_width, image_height);
            }
            else if (imageView.Image.Size.Height < imageView.Image.Size.Width)
            {
                width_height_ratio = imageView.Image.Size.Width / imageView.Image.Size.Height;
                image_width        = (int)View.Frame.Width;
                image_height       = (int)(image_width / width_height_ratio);
                imageView.Frame    = new Rectangle(0, (int)(headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2), image_width, image_height);
            }
            else if (imageView.Image.Size.Height == imageView.Image.Size.Width)
            {
                image_width     = (int)View.Frame.Width;
                image_height    = image_width;
                imageView.Frame = new Rectangle(0, (int)(headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2), image_width, image_height);
            }

            backBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PopViewController(true);
            };
            pinchGesture = new UIPinchGestureRecognizer(() =>
            {
                if (pinchGesture.State == UIGestureRecognizerState.Began || pinchGesture.State == UIGestureRecognizerState.Changed)
                {
                    if (cadreIV.Frame.X > 0 && cadreIV.Frame.Y > (int)(headerView.Frame.Y + headerView.Frame.Height) && cadreIV.Frame.X + cadreIV.Frame.Width < View.Frame.Width && cadreIV.Frame.Y + cadreIV.Frame.Height < (imageView.Frame.Height + imageView.Frame.Y))
                    {
                        pinchGesture.View.Transform *= CGAffineTransform.MakeScale(pinchGesture.Scale, pinchGesture.Scale);
                        pinchGesture.Scale           = 1;

                        circleLayer = new CAShapeLayer();
                        circlePath  = UIBezierPath.FromRect(cadreIV.Frame);
                        circlePath.UsesEvenOddFillRule = true;
                        circleLayer.Path = circlePath.CGPath;
                        maskPath         = UIBezierPath.FromRect(new CGRect(0, (int)headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2, View.Frame.Width, (int)(View.Frame.Height - (headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2 + View.Frame.Width / 8))));
                        maskPath.AppendPath(circlePath);
                        maskPath.UsesEvenOddFillRule = true;
                        fillLayer.Path     = maskPath.CGPath;
                        fillLayer.FillRule = CAShapeLayer.FillRuleEvenOdd;

                        View.Layer.AddSublayer(fillLayer);
                    }
                    else
                    {
                        if (pinchGesture.Scale < 1)
                        {
                            pinchGesture.View.Transform *= CGAffineTransform.MakeScale(pinchGesture.Scale, pinchGesture.Scale);
                            pinchGesture.Scale           = 1;

                            circleLayer = new CAShapeLayer();
                            circlePath  = UIBezierPath.FromRect(cadreIV.Frame);
                            circlePath.UsesEvenOddFillRule = true;
                            circleLayer.Path = circlePath.CGPath;
                            maskPath         = UIBezierPath.FromRect(new CGRect(0, (int)headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2, View.Frame.Width, (int)(View.Frame.Height - (headerView.Frame.Y + headerView.Frame.Height + headerView.Frame.Height / 2 + View.Frame.Width / 8))));
                            maskPath.AppendPath(circlePath);
                            maskPath.UsesEvenOddFillRule = true;
                            fillLayer.Path     = maskPath.CGPath;
                            fillLayer.FillRule = CAShapeLayer.FillRuleEvenOdd;

                            View.Layer.AddSublayer(fillLayer);
                        }
                    }
                }
            });
            cadreIV.AddGestureRecognizer(pinchGesture);
            UIStoryboard sb = UIStoryboard.FromName("Main", null);
            //CropGalleryViewController.currentImage = current_imgBn.CurrentImage;
            var vc = sb.InstantiateViewController(nameof(CompanyDataViewControllerNew));

            if (came_from == "edit")
            {
                vc = sb.InstantiateViewController(nameof(EditCompanyDataViewControllerNew));
            }
            readyBn.TouchUpInside += (s, e) =>
            {
                x = cadreIV.Frame.X;
                y = cadreIV.Frame.Y;
                w = cadreIV.Frame.Width;
                h = cadreIV.Frame.Height;

                var wwww1 = (float)(imageView.Image.Size.Width / View.Frame.Width);
                var hhhh1 = (float)(imageView.Image.Size.Height / imageView.Frame.Height);
                var ppp   = (float)(cadreIV.Frame.X * wwww1);
                var lll   = (float)(cadreIV.Frame.Y * hhhh1 - imageView.Frame.Y * wwww1);
                var www   = (float)(cadreIV.Frame.Width * wwww1);
                var hhh   = (float)(cadreIV.Frame.Height * hhhh1);

                cropped_result = CenterCrop(imageView.Image, new RectangleF(ppp, lll, www, hhh));

                this.NavigationController.PushViewController(vc, true);
                var vc_list = this.NavigationController.ViewControllers.ToList();
                vc_list.RemoveAt(vc_list.Count - 2);
                vc_list.RemoveAt(vc_list.Count - 2);
                if (came_from_gallery_or_camera == Constants.camera)
                {
                    vc_list.RemoveAt(vc_list.Count - 2);
                }
                this.NavigationController.ViewControllers = vc_list.ToArray();
            };
            cancelBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PushViewController(vc, true);
                //this.NavigationController.PopViewController(true);
            };
            remove_imageBn.TouchUpInside += (s, e) =>
            {
                EditCompanyDataViewControllerNew.logo_id = null;
                cropped_result = null;
                currentImage   = null;
                this.NavigationController.PushViewController(vc, true);
                var vc_list = this.NavigationController.ViewControllers.ToList();
                vc_list.RemoveAt(vc_list.Count - 2);
                vc_list.RemoveAt(vc_list.Count - 2);
                if (came_from_gallery_or_camera == Constants.camera)
                {
                    vc_list.RemoveAt(vc_list.Count - 2);
                }
                this.NavigationController.ViewControllers = vc_list.ToArray();
            };
            readyBn.Font        = UIFont.FromName(Constants.fira_sans, 17f);
            cancelBn.Font       = UIFont.FromName(Constants.fira_sans, 17f);
            remove_imageBn.Font = UIFont.FromName(Constants.fira_sans, 17f);
        }
Beispiel #38
0
 public abstract void Pinch(UIPinchGestureRecognizer pinch);
Beispiel #39
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))
            var downUpGestureRecognizer = new DownUpGestureRecognizer(OnDown, 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(OnLongPressed)
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => false)
                };
                list.Add(uILongPressGestureRecognizer);
            }
            if (HandlesTaps)
            {
                var uITapGestureRecognizer = new 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(OnPanned)
                {
                    MinimumNumberOfTouches        = 1,
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIPanGestureRecognizer);
            }
            if (HandlesPinches)
            {
                var uIPinchGestureRecognizer = new UIPinchGestureRecognizer(OnPinched)
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIPinchGestureRecognizer);
            }
            if (HandlesRotates)
            {
                var uIRotationGestureRecognizer = new UIRotationGestureRecognizer(OnRotated)
                {
                    ShouldRecognizeSimultaneously = ((thisGr, otherGr) => true)
                };
                list.Add(uIRotationGestureRecognizer);
            }
            return(list.ToArray());
        }
Beispiel #40
0
 public override void Pinch(UIPinchGestureRecognizer pinch)
 {
 }
Beispiel #41
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            actvw.HidesWhenStopped = true;

            // Pinch gesture to scale font
            var pinchGestureRecognizer = new UIPinchGestureRecognizer((recog) => {
                //Console.WriteLine ("recog.State={0}, scale={1}", recog.State, recog.Scale);
                if (recog.State == UIGestureRecognizerState.Began)
                {
                }
                else if (recog.State == UIGestureRecognizerState.Changed)
                {
                    int unitSize = (int)Math.Min(maxFontSize, Math.Max(minFontSize, this.unitFontSize * recog.Scale));
                    ShowProgressionLabel(String.Format("Size = {0}", unitSize));
                    _tableViewSource.SetHeightForRow(CalculateRowHeightFromUnitFontSize(unitSize));
                    tblvwGlyphList.ReloadData();
                }
                else if (recog.State == UIGestureRecognizerState.Recognized)
                {
                    int unitSize = (int)Math.Min(maxFontSize, Math.Max(minFontSize, this.unitFontSize * recog.Scale));
                    if (unitSize != unitFontSize)
                    {
                        this.unitFontSize = unitSize;
                        UpdateGlyphsWithCurrentFontSize();
                    }
                    DismissProgressionLabel();
                }
            });

            tblvwGlyphList.AddGestureRecognizer(pinchGestureRecognizer);

            #region Toolbar button to save every image to PNG

            var saveButton = new UIBarButtonItem(FontAwesomeUtil.GetUIImageForBarItem(GlyphNames.Save), UIBarButtonItemStyle.Plain
                                                 , (s, e) => {
                var alert               = new UIAlertView();
                alert.Title             = String.Format("{0}x{0} size of images are going to be generated.", this.unitFontSize);
                alert.Message           = "Clear any image in document folder before newly generate?";
                int nYesButton          = alert.AddButton("Clear");
                int nNoButton           = alert.AddButton("No");
                int nCancelButton       = alert.AddButton("Cancel");
                alert.CancelButtonIndex = nCancelButton;
                alert.Clicked          += (s2, e2) => {
                    if (nYesButton == e2.ButtonIndex)
                    {
                        DeleteAllPNGsInDocumentFolder();
                        SaveEveryImageToPNG();
                    }
                    else if (nNoButton == e2.ButtonIndex)
                    {
                        SaveEveryImageToPNG();
                    }
                };
                alert.Show();
            });
            SetToolbarItems(new UIBarButtonItem[] { saveButton }, false);
            #endregion

            UpdateGlyphsWithCurrentFontSize();
        }
Beispiel #42
0
        /// <summary>
        /// Pinch the specified pinch.
        /// </summary>
        /// <param name="pinch">Pinch.</param>
        private void Pinch(UIPinchGestureRecognizer pinch)
        {
            CGRect rect = this.Frame;
            if (this.MapAllowZoom &&
                rect.Width > 0)
            {
                this.StopCurrentAnimation();
                if (pinch.State == UIGestureRecognizerState.Ended)
                {
                    this.NotifyMovementByInvoke();

                    _mapZoomLevelBefore = null;

                    // raise map touched event.
                    this.RaiseMapTouched();
                    this.RaiseMapTouchedUp();
                }
                else if (pinch.State == UIGestureRecognizerState.Began)
                {
                    this.RaiseMapTouchedDown();
                    _mapZoomLevelBefore = MapZoom;
                }
                else
                {
                    MapZoom = _mapZoomLevelBefore.Value;

                    double zoomFactor = this.Map.Projection.ToZoomFactor(MapZoom);
                    zoomFactor = zoomFactor * pinch.Scale;
                    MapZoom = (float)this.Map.Projection.ToZoomLevel(zoomFactor);

                    this.NotifyMovementByInvoke();

                    // raise map move event.
                    this.RaiseMapMove();
                }
            }
        }
Beispiel #43
0
        void updateGestures(object sender, EventArgs e)
        {
            var enabledGestures = TouchPanel.EnabledGestures;

            if ((enabledGestures & GestureType.Hold) != 0)
            {
                if (recognizerLongPress == null)
                {
                    recognizerLongPress = new UILongPressGestureRecognizer(this, new Selector("LongPressGestureRecognizer"));
                    recognizerLongPress.MinimumPressDuration = 1.0;
                    AddGestureRecognizer(recognizerLongPress);
                }
            }
            else if (recognizerLongPress != null)
            {
                RemoveGestureRecognizer(recognizerLongPress);
                recognizerLongPress = null;
            }

            if ((enabledGestures & GestureType.Tap) != 0)
            {
                if (recognizerTap == null)
                {
                    recognizerTap = new UITapGestureRecognizer(this, new Selector("TapGestureRecognizer"));
                    recognizerTap.NumberOfTapsRequired = 1;
                    AddGestureRecognizer(recognizerTap);
                }
            }
            else if (recognizerTap != null)
            {
                RemoveGestureRecognizer(recognizerTap);
                recognizerTap = null;
            }

            if ((enabledGestures & GestureType.DoubleTap) != 0)
            {
                if (recognizerDoubleTap == null)
                {
                    recognizerDoubleTap = new UITapGestureRecognizer(this, new Selector("TapGestureRecognizer"));
                    recognizerDoubleTap.NumberOfTapsRequired = 2;
                    AddGestureRecognizer(recognizerDoubleTap);
                }
            }
            else if (recognizerDoubleTap != null)
            {
                RemoveGestureRecognizer(recognizerDoubleTap);
                recognizerDoubleTap = null;
            }

            if ((enabledGestures & GestureType.FreeDrag) != 0)
            {
                if (recognizerPan == null)
                {
                    recognizerPan = new UIPanGestureRecognizer(this, new Selector("PanGestureRecognizer"));
                    recognizerPan.CancelsTouchesInView = false;
                    AddGestureRecognizer(recognizerPan);
                }
            }
            else if (recognizerPan != null)
            {
                RemoveGestureRecognizer(recognizerPan);
                recognizerPan = null;
            }

            if ((enabledGestures & GestureType.Flick) != 0)
            {
                if (recognizerLeftRightSwipe == null)
                {
                    recognizerLeftRightSwipe = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerLeftRightSwipe.Direction = UISwipeGestureRecognizerDirection.Down | UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
                    AddGestureRecognizer(recognizerLeftRightSwipe);
                }

                if (recognizerUpDownSwipe == null)
                {
                    recognizerUpDownSwipe = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerUpDownSwipe.Direction = UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
                    AddGestureRecognizer(recognizerUpDownSwipe);
                }
            }
            else if (recognizerLeftRightSwipe != null)
            {
                RemoveGestureRecognizer(recognizerLeftRightSwipe);
                recognizerLeftRightSwipe = null;
            }

            if ((enabledGestures & GestureType.Flick) != 0)
            {
                if (recognizerUpDownSwipe == null)
                {
                    recognizerUpDownSwipe = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerUpDownSwipe.Direction = UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Down;
                    AddGestureRecognizer(recognizerUpDownSwipe);
                }
            }
            else if (recognizerUpDownSwipe != null)
            {
                RemoveGestureRecognizer(recognizerUpDownSwipe);
                recognizerUpDownSwipe = null;
            }

            if ((enabledGestures & GestureType.Pinch) != 0)
            {
                if (recognizerPinch == null)
                {
                    recognizerPinch = new UIPinchGestureRecognizer(this, new Selector("PinchGestureRecognizer"));
                    AddGestureRecognizer(recognizerPinch);
                }
            }
            else if (recognizerPinch != null)
            {
                RemoveGestureRecognizer(recognizerPinch);
                recognizerPinch = null;
            }

            if ((enabledGestures & GestureType.Rotation) != 0)
            {
                if (recognizerRotation == null)
                {
                    recognizerRotation = new UIRotationGestureRecognizer(this, new Selector("RotationGestureRecognizer"));
                    AddGestureRecognizer(recognizerRotation);
                }
            }
            else if (recognizerRotation != null)
            {
                RemoveGestureRecognizer(recognizerRotation);
                recognizerRotation = null;
            }
        }
Beispiel #44
0
		private void HandlePinchGestureRecognizer(UIPinchGestureRecognizer sender)
		{
			if (sender.State == UIGestureRecognizerState.Began)
			{
				_initialZoom = Zoom;
				_initialContentOffset = WaveFormView.ContentOffset;
				UIView.Animate(0.2, () => _lblZoom.Alpha = 0.9f);
			}
			else if (sender.State == UIGestureRecognizerState.Ended)
			{
				UIView.Animate(0.2, 0.8, UIViewAnimationOptions.CurveEaseOut, () => _lblZoom.Alpha = 0, () => {});
			}

			var location = sender.LocationInView(this);
			float newZoom = _initialZoom * _pinchGesture.Scale;
			float deltaZoom = newZoom / Zoom;
			float originPointX = IsAutoScrollEnabled ? WaveFormView.ContentOffset.X + (Frame.Width / 2) : location.X + WaveFormView.ContentOffset.X;
			float distanceToOffsetX = originPointX - WaveFormView.ContentOffset.X;
			float contentOffsetX = (originPointX * deltaZoom) - distanceToOffsetX;
			Zoom = Math.Max(1, newZoom);
			SetContentOffsetX(contentOffsetX);
			_lblZoom.Text = (Zoom * 100).ToString("0") + "%";
			//Console.WriteLine("HandlePinchGestureRecognizer - initialZoom: {0} newZoom: {1}", _initialZoom, newZoom);
		}
Beispiel #45
0
 public void manageScaleInView(UIView view, float scale, UIPinchGestureRecognizer pinch)
 {
 }
		public iOS_PinchGestureEventArgs(PinchGestureRecognizer gestureRecognizer, UIPinchGestureRecognizer platformGestureRecognizer)
		{
			this.gestureRecognizer = gestureRecognizer;
			this.platformGestureRecognizer = platformGestureRecognizer;
		}
Beispiel #47
0
        void updateGestures(object sender, EventArgs e)
        {
            var enabledGestures = TouchPanel.EnabledGestures;

            if ((enabledGestures & GestureType.Hold) != 0)
            {
                if (recognizerLongPress == null)
                {
                    recognizerLongPress = new UILongPressGestureRecognizer(this, new Selector("LongPressGestureRecognizer"));
                    recognizerLongPress.MinimumPressDuration = 1.0;
                    AddGestureRecognizer(recognizerLongPress);
                }
            }
            else if (recognizerLongPress != null)
            {
                RemoveGestureRecognizer(recognizerLongPress);
                recognizerLongPress = null;
            }

            if ((enabledGestures & GestureType.Tap) != 0)
            {
                if (recognizerTap == null)
                {
                    recognizerTap = new UITapGestureRecognizer(this, new Selector("TapGestureRecognizer"));
                    recognizerTap.NumberOfTapsRequired = 1;
                    AddGestureRecognizer(recognizerTap);
                }
            }
            else if (recognizerTap != null)
            {
                RemoveGestureRecognizer(recognizerTap);
                recognizerTap = null;
            }

            if ((enabledGestures & GestureType.DoubleTap) != 0)
            {
                if (recognizerDoubleTap == null)
                {
                    recognizerDoubleTap = new UITapGestureRecognizer(this, new Selector("TapGestureRecognizer"));
                    recognizerDoubleTap.NumberOfTapsRequired = 2;
                    AddGestureRecognizer(recognizerDoubleTap);
                }
            }
            else if (recognizerDoubleTap != null)
            {
                RemoveGestureRecognizer(recognizerDoubleTap);
                recognizerDoubleTap = null;
            }

            if ((enabledGestures & GestureType.FreeDrag) != 0)
            {
                if (recognizerPan == null)
                {
                    recognizerPan = new UIPanGestureRecognizer(this, new Selector("PanGestureRecognizer"));
                    recognizerPan.CancelsTouchesInView = false;
                    AddGestureRecognizer(recognizerPan);
                }
            }
            else if (recognizerPan != null)
            {
                RemoveGestureRecognizer(recognizerPan);
                recognizerPan = null;
            }

            if ((enabledGestures & GestureType.Flick) != 0)
            {
                if (recognizerLeftRightSwipe == null)
                {
                    recognizerLeftRightSwipe           = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerLeftRightSwipe.Direction = UISwipeGestureRecognizerDirection.Down | UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
                    AddGestureRecognizer(recognizerLeftRightSwipe);
                }

                if (recognizerUpDownSwipe == null)
                {
                    recognizerUpDownSwipe           = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerUpDownSwipe.Direction = UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
                    AddGestureRecognizer(recognizerUpDownSwipe);
                }
            }
            else if (recognizerLeftRightSwipe != null)
            {
                RemoveGestureRecognizer(recognizerLeftRightSwipe);
                recognizerLeftRightSwipe = null;
            }

            if ((enabledGestures & GestureType.Flick) != 0)
            {
                if (recognizerUpDownSwipe == null)
                {
                    recognizerUpDownSwipe           = new UISwipeGestureRecognizer(this, new Selector("SwipeGestureRecognizer"));
                    recognizerUpDownSwipe.Direction = UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Down;
                    AddGestureRecognizer(recognizerUpDownSwipe);
                }
            }
            else if (recognizerUpDownSwipe != null)
            {
                RemoveGestureRecognizer(recognizerUpDownSwipe);
                recognizerUpDownSwipe = null;
            }

            if ((enabledGestures & GestureType.Pinch) != 0)
            {
                if (recognizerPinch == null)
                {
                    recognizerPinch = new UIPinchGestureRecognizer(this, new Selector("PinchGestureRecognizer"));
                    AddGestureRecognizer(recognizerPinch);
                }
            }
            else if (recognizerPinch != null)
            {
                RemoveGestureRecognizer(recognizerPinch);
                recognizerPinch = null;
            }

            if ((enabledGestures & GestureType.Rotation) != 0)
            {
                if (recognizerRotation == null)
                {
                    recognizerRotation = new UIRotationGestureRecognizer(this, new Selector("RotationGestureRecognizer"));
                    AddGestureRecognizer(recognizerRotation);
                }
            }
            else if (recognizerRotation != null)
            {
                RemoveGestureRecognizer(recognizerRotation);
                recognizerRotation = null;
            }
        }