Beispiel #1
0
        private void HandleOnGestureRecognizer(UIPanGestureRecognizer gestureRecognizer)
        {
            // The translation of the pan gesture in the coordinate system of the specified view.
            var xTranslation = gestureRecognizer.TranslationInView(this).X;
            var yTranslation = gestureRecognizer.TranslationInView(this).Y;

            if (gestureRecognizer.State.Equals(UIGestureRecognizerState.Began))
            {
                _startingPoint = Center;
            }
            else if (gestureRecognizer.State.Equals(UIGestureRecognizerState.Changed))
            {
                var rotationStrength = Math.Min(xTranslation / RotationStrength, 1);
                var rotationAngle    = (nfloat)(2 * Math.PI * rotationStrength / 17);
                var scaleStrength    = 1 - Math.Abs(rotationStrength) / 4;
                var scale            = (nfloat)Math.Max(scaleStrength, ScaleStrength);
                var transform        = CGAffineTransform.MakeRotation(rotationAngle);

                Center    = new CGPoint(_startingPoint.X + xTranslation, _startingPoint.Y + yTranslation);
                Transform = CGAffineTransform.Scale(transform, scale, scale);
            }
            else if (gestureRecognizer.State.Equals(UIGestureRecognizerState.Ended))
            {
                DetermineSwipeAction(xTranslation);
                ResetView();
            }
        }
		void HandlePanGesture (UIPanGestureRecognizer gesture)
		{
			if (gesture.State == UIGestureRecognizerState.Began) {
				gestureStartingPoint = gesture.TranslationInView (textView);
				gestureStartingCenter = imageView.Center;
			}
			else if (gesture.State == UIGestureRecognizerState.Changed) {
				CGPoint currentPoint = gesture.TranslationInView(textView);
				nfloat distanceX = currentPoint.X - gestureStartingPoint.X;
				nfloat distanceY = currentPoint.Y - gestureStartingPoint.Y;

				CGPoint newCenter = gestureStartingCenter;

				newCenter.X += distanceX;
				newCenter.Y += distanceY;

				imageView.Center = newCenter;

				textView.TextContainer.ExclusionPaths = TranslatedBezierPath ();
			}
			else if (gesture.State == UIGestureRecognizerState.Ended) {
				gestureStartingPoint  = new CGPoint (0, 0);
				gestureStartingCenter = new CGPoint (0, 0);
			}
		}
Beispiel #3
0
        void HandlePanGesture(UIPanGestureRecognizer gesture)
        {
            if (gesture.State == UIGestureRecognizerState.Began)
            {
                gestureStartingPoint  = gesture.TranslationInView(textView);
                gestureStartingCenter = imageView.Center;
            }
            else if (gesture.State == UIGestureRecognizerState.Changed)
            {
                PointF currentPoint = gesture.TranslationInView(textView);
                float  distanceX    = currentPoint.X - gestureStartingPoint.X;
                float  distanceY    = currentPoint.Y - gestureStartingPoint.Y;

                PointF newCenter = gestureStartingCenter;

                newCenter.X += distanceX;
                newCenter.Y += distanceY;

                imageView.Center = newCenter;

                textView.TextContainer.ExclusionPaths = TranslatedBezierPath();
            }
            else if (gesture.State == UIGestureRecognizerState.Ended)
            {
                gestureStartingPoint  = new PointF(0, 0);
                gestureStartingCenter = new PointF(0, 0);
            }
        }
        private void OnPanningGesture (UIPanGestureRecognizer gesture)
        {
            switch (gesture.State) {
            case UIGestureRecognizerState.Began:
                panStart = gesture.TranslationInView (actualContentView);
                panLockInHorizDirection = false;
                break;
            case UIGestureRecognizerState.Changed:
                var currentPoint = gesture.TranslationInView (actualContentView);
                panDeltaX = panStart.X - currentPoint.X;

                if (panDeltaX > 0) {
                    panDeltaX = 0;
                    return;
                }

                if (!panLockInHorizDirection) {
                    if (Math.Abs (panDeltaX) > 30) {
                        // User is swiping the cell, lock them into this direction
                        panLockInHorizDirection = true;
                    } else if (Math.Abs (panStart.Y - currentPoint.Y) > 5) {
                        // User is starting to move upwards, let them scroll
                        gesture.Enabled = false;
                    }
                }

                if (-SwipeWidth > panDeltaX) {
                    panDeltaX = -SwipeWidth;
                }

                UIView.AnimateNotify (0.1, 0, UIViewAnimationOptions.CurveEaseOut, LayoutActualContentView, null);
                break;
            case UIGestureRecognizerState.Ended:
                if (Editing) {
                    break;
                }

                if (!gesture.Enabled) {
                    gesture.Enabled = true;
                }

                var velocityX = gesture.VelocityInView (gesture.View).X;
                var absolutePanDeltaX = Math.Abs (panDeltaX);
                var duration = Math.Max (MinDuration, Math.Min (MaxDuration, (absolutePanDeltaX) / velocityX));

                UIView.AnimateNotify (duration, () => LayoutActualContentView (0), isFinished => {
                    if (isFinished && absolutePanDeltaX > SwipeWidth - 5) {
                        OnContinueGestureFinished ();
                    }
                });

                break;
            case UIGestureRecognizerState.Cancelled:
                UIView.AnimateNotify (0.3, () => LayoutActualContentView (0), isFinished => gesture.Enabled = isFinished);
                break;
            }

        }
Beispiel #5
0
        private void PanGesture(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(View);
            var y           = View.Frame.GetMinY();

            View.Frame = new CGRect(0, y + translation.Y, View.Frame.Width, View.Frame.Height);
            recognizer.SetTranslation(CGPoint.Empty, View);

            var velocity = recognizer.VelocityInView(View);

            if ((y + translation.Y >= fullView) & (y + translation.Y <= partialView))
            {
                View.Frame = new CGRect(0, y + translation.Y, View.Frame.Width, View.Frame.Height);
                recognizer.SetTranslation(CGPoint.Empty, View);
            }

            if (recognizer.State == UIGestureRecognizerState.Ended)
            {
                var duration = velocity.Y < 0 ? ((y - fullView) / -velocity.Y) : ((partialView - y) / velocity.Y);
                duration = duration > 1.3 ? 1 : duration;

                UIView.Animate(duration, 0.0, UIViewAnimationOptions.AllowUserInteraction, () =>
                {
                    if (velocity.Y >= 0)
                    {
                        View.Frame = new CGRect(0, partialView, View.Frame.Width, View.Frame.Height);
                    }
                    else
                    {
                        View.Frame = new CGRect(0, fullView, View.Frame.Width, View.Frame.Height);
                    }
                }, null);
            }
        }
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        void HandlePanAction()
        {
            if (panGesture.State == UIGestureRecognizerState.Began)
            {
                initialPanTimeStart = timeStart;
            }
            else if (panGesture.State == UIGestureRecognizerState.Ended)
            {
                readyToDataUpdate = true;
            }

            nfloat diffX     = panGesture.TranslationInView(this).X;
            double relativeX = diffX / Frame.Size.Width;

            double frame = (timeEnd - timeStart).TotalSeconds;

            timeStart = initialPanTimeStart.AddSeconds(-frame * relativeX);

            if (timeStart < DataManager.unixEpoch)
            {
                timeStart = DataManager.unixEpoch;
            }

            timeEnd = timeStart.AddSeconds(frame);

            SetNeedsDisplay();

            //Console.WriteLine("pan state: " + panGesture.State + ", timeStart: " + timeStart);
        }
Beispiel #7
0
        private void HandlePanGesture(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(recognizer.View);
            //distance of pan gestire from start position
            var distance = translation.X / UIScreen.MainScreen.Bounds.Width * -1;

            switch (recognizer.State)
            {
            case UIGestureRecognizerState.Began:
                _panGestureIsActive = true;
                MainViewController.DismissViewController(true, null);
                break;

            case UIGestureRecognizerState.Changed:
                var update = Math.Max(Math.Min((float)distance, 1.0f), 0.0f);
                UpdateInteractiveTransition(update);
                break;

            default:
                _panGestureIsActive = false;
                var velocity = recognizer.VelocityInView(recognizer.View).X * -1;
                if (velocity >= 100 || velocity >= -50 && distance >= 0.5)
                {
                    FinishInteractiveTransition();
                }
                else
                {
                    CancelInteractiveTransition();
                }
                break;
            }
        }
        private void HandlePanFrom(UIPanGestureRecognizer recognizer)
        {
            if (recognizer.State == UIGestureRecognizerState.Began)
            {
                PointF touchLocation = recognizer.LocationInView(recognizer.View);
                touchLocation = this.ConvertPointFromView(touchLocation);
                this.SelectNodeForTouch(touchLocation);
            }
            else if (recognizer.State == UIGestureRecognizerState.Changed)
            {
                PointF translation = recognizer.TranslationInView(recognizer.View);
                translation = new PointF(translation.X, -translation.Y);
                this.PanForTranslation(translation);
                recognizer.SetTranslation(new PointF(0, 0), recognizer.View);
            }
            else if (recognizer.State == UIGestureRecognizerState.Ended)
            {
                float scrollDuration = 0.2f;

                if (this.SelectedNode.Name != ANIMAL_NODE_NAME)
                {
                    PointF velocity = recognizer.VelocityInView(recognizer.View);
                    PointF p        = mult(velocity, scrollDuration);

                    PointF position = this.SelectedNode.Position;
                    PointF newPos   = new PointF(position.X + p.X, position.Y + p.Y);
                    newPos = this.BoundLayerPosition(newPos);
                    this.SelectedNode.RemoveAllActions();

                    SKAction moveTo = SKAction.MoveTo(newPos, scrollDuration);
                    moveTo.TimingMode = SKActionTimingMode.EaseOut;
                    this.SelectedNode.RunAction(moveTo);
                }
            }
        }
Beispiel #9
0
 private void SwipeHandler(UIPanGestureRecognizer recognizer)
 {
     if (recognizer.State == UIGestureRecognizerState.Began)
     {
         _originalCenter = Center;
     }
     else if (recognizer.State == UIGestureRecognizerState.Changed)
     {
         var translation = recognizer.TranslationInView(this);
         var x           = Math.Min(_originalCenter.X + translation.X, _originalCenter.X);
         Center = new CGPoint(x, Center.Y);
     }
     else if (recognizer.State == UIGestureRecognizerState.Ended)
     {
         if (Center.X > _originalCenter.X * DeleteThreshold)
         {
             Animate(0.2, () =>
             {
                 Center = _originalCenter;
             });
         }
         else
         {
             AnimateAsync(0.2, () =>
             {
                 Center = new CGPoint(-Frame.Width, Center.Y);
             }).ContinueWith(_ => ViewModel.Delete());
         }
     }
 }
Beispiel #10
0
        void DetectPan()
        {
            var dragView = Element as DraggableView;

            if (panGesture.State == UIGestureRecognizerState.Began)
            {
                dragView.DragStarted();
                if (firstTime)
                {
                    originalPosition = Center;
                    firstTime        = false;
                }

                CGPoint translation    = panGesture.TranslationInView(Superview);
                var     currentCenterX = Center.X;
                var     currentCenterY = Center.Y;
                currentCenterX = lastLocation.X + translation.X;

                currentCenterY = lastLocation.Y + translation.Y;

                Center = new CGPoint(currentCenterX, currentCenterY);

                if (panGesture.State == UIGestureRecognizerState.Ended)
                {
                    dragView.DragEnded(new Point {
                        X = Center.X, Y = Center.Y
                    });
                }
            }
        }
Beispiel #11
0
        private void detectPan(UIPanGestureRecognizer gesture)
        {
            this.Superview.BringSubviewToFront(this);

            if (gesture.State == UIGestureRecognizerState.Began)
            {
                _originalFrame = this.Frame;
            }
            else if (gesture.State == UIGestureRecognizerState.Changed)
            {
                var translate = gesture.TranslationInView(gesture.View);

                var newFrame = _originalFrame;

                newFrame.X += translate.X;
                newFrame.Y += translate.Y;

                gesture.View.Frame = newFrame;
            }
            else if (gesture.State == UIGestureRecognizerState.Ended || gesture.State == UIGestureRecognizerState.Cancelled)
            {
                var newFrame = gesture.View.Frame;

                //prevent the circle from going outside of the screen bounds
                newFrame.X = Math.Max(newFrame.X, 0.0f);
                newFrame.X = Math.Min(newFrame.X, gesture.View.Superview.Bounds.Size.Width - newFrame.Size.Width);

                newFrame.Y = Math.Max(newFrame.Y, 0.0f);
                newFrame.Y = Math.Min(newFrame.Y, gesture.View.Superview.Bounds.Size.Height - newFrame.Size.Height);

                UIView.Animate(0.5, () => gesture.View.Frame = newFrame);
            }
        }
Beispiel #12
0
        void BeginInteractiveTransitionIfPossible(UIPanGestureRecognizer sender)
        {
            var translation = sender.TranslationInView(tabBarController.View);

            if (translation.X > 0f && tabBarController.SelectedIndex > 0)
            {
                tabBarController.SelectedIndex--;
            }
            else if (translation.X < 0f && (tabBarController.SelectedIndex + 1) < tabBarController.ViewControllers.Length)
            {
                tabBarController.SelectedIndex++;
            }
            else if (!(Math.Abs(translation.X) < nfloat.Epsilon && Math.Abs(translation.Y) < nfloat.Epsilon))
            {
                sender.Enabled = false;
                sender.Enabled = true;
            }

            var cooordinator = tabBarController.GetTransitionCoordinator();

            if (cooordinator == null)
            {
                return;
            }

            // TODO nullable first argument?
            cooordinator.AnimateAlongsideTransition((_) => { }, (context) => {
                if (context.IsCancelled && sender.State == UIGestureRecognizerState.Changed)
                {
                    BeginInteractiveTransitionIfPossible(sender);
                }
            });
        }
Beispiel #13
0
        void Pan(UIPanGestureRecognizer gesture)
        {
            var viewToSlide    = ContentView;
            var menuShouldOpen = viewToSlide.Frame.X > View.Frame.Width / 4;

            if (gesture.State == UIGestureRecognizerState.Began)
            {
                ContentView.DrawShadow = true;
                PanOrigin = viewToSlide.Frame.Location;
                View.SendSubviewToBack(CloseMenuTapDetectView);
            }

            var movement = gesture.TranslationInView(View);

            viewToSlide.Frame = viewToSlide.Frame.With(X: PanOrigin.X + movement.X);

            if (gesture.State == UIGestureRecognizerState.Ended)
            {
                var destination = PointF.Empty;

                if (menuShouldOpen)
                {
                    destination = new PointF(View.Frame.Width / 2, 0);
                }

                UIView.Animate(0.3, () => {
                    viewToSlide.Frame = viewToSlide.Frame.With(Location: destination);
                }, () => {
                    (menuShouldOpen ? MenuOpened : MenuClosed).Raise();
                });
            }
        }
Beispiel #14
0
        private void panOffsetUpdated()
        {
            CGPoint translation = panGestureRecognizer.TranslationInView(view);

            Vector2 delta;

            switch (panGestureRecognizer.State)
            {
            case UIGestureRecognizerState.Began:
                // consume initial value.
                delta = new Vector2((float)translation.X, (float)translation.Y);
                break;

            default:
                // only consider relative change from previous value.
                delta = new Vector2((float)(translation.X - lastScrollTranslation.X), (float)(translation.Y - lastScrollTranslation.Y));
                break;
            }

            lastScrollTranslation = translation;

            PendingInputs.Enqueue(new MouseScrollRelativeInput
            {
                IsPrecise = true,
                Delta     = delta * scroll_rate_adjust
            });
        }
Beispiel #15
0
        void HandlePanGesture(UIPanGestureRecognizer pan)
        {
            var    translation  = pan.TranslationInView(View).X;
            double openProgress = 0;
            double openLimit    = Flyout.ViewController.View.Frame.Width;

            if (IsOpen)
            {
                openProgress = 1 - (-translation / openLimit);
            }
            else
            {
                openProgress = translation / openLimit;
            }

            openProgress = Math.Min(Math.Max(openProgress, 0.0), 1.0);
            var openPixels = openLimit * openProgress;

            switch (pan.State)
            {
            case UIGestureRecognizerState.Changed:
                _gestureActive = true;

                if (TapoffView == null)
                {
                    AddTapoffView();
                }

                if (_flyoutAnimation != null)
                {
                    TapoffView.Layer.RemoveAllAnimations();
                    _flyoutAnimation?.StopAnimation(true);
                    _flyoutAnimation = null;
                }

                TapoffView.Layer.Opacity = (float)openProgress;

                FlyoutTransition.LayoutViews(View.Bounds, (nfloat)openProgress, Flyout.ViewController.View, Detail.View, _flyoutBehavior);
                break;

            case UIGestureRecognizerState.Ended:
                _gestureActive = false;
                if (IsOpen)
                {
                    if (openProgress < .8)
                    {
                        IsOpen = false;
                    }
                }
                else
                {
                    if (openProgress > 0.2)
                    {
                        IsOpen = true;
                    }
                }
                LayoutSidebar(true);
                break;
            }
        }
Beispiel #16
0
        private void panGestureRecognizerHandlerChanged(UIPanGestureRecognizer gesture)
        {
            CGPoint translation = gesture.TranslationInView(ContentView);

            ContentView_LayoutCenterY.Constant += translation.Y;
            gesture.SetTranslation(new CGPoint(0.0, 0.0), ContentView);
        }
 private void PanGesture(UIPanGestureRecognizer pPan)
 {
     if (pPan.State == UIGestureRecognizerState.Ended)
     {
         if (Math.Abs(_PanStartOffset.X) < 0.001)
         {
             if (pPan.VelocityInView(this).X > 1000)
             {
                 ChangeGraph(-1);
             }
             else if (pPan.VelocityInView(this).X < -1000)
             {
                 ChangeGraph(1);
             }
         }
     }
     else if (pPan.State == UIGestureRecognizerState.Began)
     {
         _PanStartOffset = _Offset;
     }
     else if (pPan.State == UIGestureRecognizerState.Changed)
     {
         _Offset = pPan.TranslationInView(null).ToSKPoint() + _PanStartOffset;
         if (_Offset.X > 0)
         {
             _Offset = new SKPoint(0, _Offset.Y);
         }
         if (_Offset.Y > 0)
         {
             _Offset = new SKPoint(_Offset.X, 0);
         }
         SetNeedsDisplay();
     }
     //pPan.
 }
        partial void DidPan(UIPanGestureRecognizer gesture)
        {
            if (this.virtualObject != null)
            {
                switch (gesture.State)
                {
                case UIGestureRecognizerState.Changed:
                    var translation = gesture.TranslationInView(this.sceneView);

                    var previousPosition = this.lastPanTouchPosition ?? CGPointExtensions.Create(this.sceneView.ProjectPoint(this.virtualObject.Position));
                    // Calculate the new touch position
                    var currentPosition = new CGPoint(previousPosition.X + translation.X, previousPosition.Y + translation.Y);
                    using (var hitTestResult = this.sceneView.SmartHitTest(currentPosition))
                    {
                        if (hitTestResult != null)
                        {
                            this.virtualObject.Position = hitTestResult.WorldTransform.GetTranslation();
                            // Refresh the probe as the object keeps moving
                            this.requiresProbeRefresh = true;
                        }
                    }

                    this.lastPanTouchPosition = currentPosition;
                    // reset the gesture's translation
                    gesture.SetTranslation(CGPoint.Empty, this.sceneView);
                    break;

                default:
                    // Clear the current position tracking.
                    this.lastPanTouchPosition = null;
                    break;
                }
            }
        }
Beispiel #19
0
        public void DragContentView(UIPanGestureRecognizer panGesture)
        {
            var translation = panGesture.TranslationInView(View).X;
//				if (panGesture.State == UIGestureRecognizerState.Changed) {
//					if (IsOpen) {
//						if (translation > 0.0f) {
//							_contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
//							self.sidebarShowing = YES;
//						} else if (translation < -kGHRevealSidebarWidth) {
//							_contentView.frame = _contentView.bounds;
//							self.sidebarShowing = NO;
//						} else {
//							_contentView.frame = CGRectOffset(_contentView.bounds, (kGHRevealSidebarWidth + translation), 0.0f);
//						}
//					} else {
//						if (translation < 0.0f) {
//							_contentView.frame = _contentView.bounds;
//							self.sidebarShowing = NO;
//						} else if (translation > kGHRevealSidebarWidth) {
//							_contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
//							self.sidebarShowing = YES;
//						} else {
//							_contentView.frame = CGRectOffset(_contentView.bounds, translation, 0.0f);
//						}
//					}
//				} else if (panGesture.state == UIGestureRecognizerStateEnded) {
//					CGFloat velocity = [panGesture velocityInView:self.view].x;
//					BOOL show = (fabs(velocity) > kGHRevealSidebarFlickVelocity)
//						? (velocity > 0)
//							: (translation > (kGHRevealSidebarWidth / 2));
//					[self toggleSidebar:show duration:kGHRevealSidebarDefaultAnimationDuration];
//
//				}
        }
Beispiel #20
0
        void HandlePanSplitter(UIPanGestureRecognizer pan)
        {
            try {
                var t = pan.TranslationInView(View);

                if (pan.State == UIGestureRecognizerState.Began)
                {
                    panStartRatio     = Ratio;
                    Splitter.Touching = true;
                }
                else if (pan.State == UIGestureRecognizerState.Changed)
                {
                    var w  = View.Bounds.Width;
                    var rr = panStartRatio + t.X / w;
                    Ratio = rr;
                    containerView.BackgroundColor = First.View.BackgroundColor;
                    containerView.SetNeedsLayout();
                }
                else
                {
                    Splitter.Touching = false;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
        private async void handleSwipe(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(recognizer.View);
            var height      = FrameOfPresentedViewInContainerView.Size.Height - keyboardHeight;
            var percent     = (nfloat)Max(0, translation.Y / height);

            switch (recognizer.State)
            {
            case UIGestureRecognizerState.Began:
                originalCenter = recognizer.View.Center;
                feedbackGenerator.Prepare();
                break;

            case UIGestureRecognizerState.Changed:
                var center = new CGPoint(originalCenter.X, Max(originalCenter.Y, originalCenter.Y + translation.Y));
                recognizer.View.Center = center;
                dimmingView.Alpha      = backgroundAlpha * (1 - percent);
                break;

            case UIGestureRecognizerState.Ended:
            case UIGestureRecognizerState.Cancelled:
                if (percent > impactThreshold && await dismiss())
                {
                    feedbackGenerator.ImpactOccurred();
                }
                else
                {
                    resetPosition(recognizer);
                }
                break;
            }
        }
Beispiel #22
0
        private void handleGesture(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(recognizer.View.Superview);
            var percent     = translation.Y / recognizer.View.Superview.Bounds.Size.Height;

            switch (recognizer.State)
            {
            case Began:
                InteractionInProgress = true;
                viewController.DismissViewController(true, null);
                break;

            case Changed:
                shouldCompleteTransition = percent > 0.2;
                UpdateInteractiveTransition(percent);
                break;

            case Cancelled:
                InteractionInProgress = false;
                CancelInteractiveTransition();
                break;

            case Ended:
                InteractionInProgress = false;
                if (!shouldCompleteTransition)
                {
                    CancelInteractiveTransition();
                    return;
                }

                FinishInteractiveTransition();
                break;
            }
        }
Beispiel #23
0
        protected void HandlePan(UIPanGestureRecognizer gesture)
        {
            // Prepare values
            UIView topView      = this.TopViewController.View;
            float  translationX = gesture.TranslationInView(this.View).X;
            float  velocityX    = gesture.VelocityInView(this.View).X;

            // Handle gesture
            switch (gesture.State)
            {
            case UIGestureRecognizerState.Began:
            {
                this.SlidingTransition.PanBegan(this, topView, translationX, velocityX);
                break;
            }

            case UIGestureRecognizerState.Changed:
            {
                this.SlidingTransition.PanChanged(this, topView, translationX, velocityX);
                break;
            }

            case UIGestureRecognizerState.Ended:
            case UIGestureRecognizerState.Cancelled:
            {
                this.SlidingTransition.PanEnded(this, topView, translationX, velocityX);
                break;
            }
            }
        }
Beispiel #24
0
        private void HandlePan(UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView(this);

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

            StopDeceleration();

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

                panGestureLastTranslation = recognizer.TranslationInView(this);

                ViewPort.Offset(panGestureLastTranslation);

                break;

            case UIGestureRecognizerState.Changed:

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

                ViewPort.Offset(translationOffset);

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

                panGestureLastTranslation = translation;

                break;

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

                var velocity = recognizer.VelocityInView(this);

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

                InitDeceleration(velocity);

                break;

            default:
                break;
            }

            SetNeedsDisplay();
        }
Beispiel #25
0
        /// <summary>
        /// Adjusts the size of the view when the user pans (if <see cref="AllowsManualResize"/> is <value>true</value>).
        /// </summary>
        /// <param name="recognizer">Gesture recognizer that is handling user interaction.</param>
        private void HandleMoveView(UIPanGestureRecognizer recognizer)
        {
            // Do nothing if user resize isn't enabled
            if (!AllowsManualResize)
            {
                return;
            }

            // Get the distance moved
            var translation = recognizer.TranslationInView(View);

            // In compact width scrolling up (negative translation) increases height as the card moves up
            if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular)
            {
                // translate height constraint
                _heightConstraint.Constant += translation.Y;
            }
            else
            {
                // translate height constraint
                _heightConstraint.Constant -= translation.Y;
            }

            // Prevent making the view too large
            if (_heightConstraint.Constant > MaxHeightConstraint)
            {
                _heightConstraint.Constant = MaxHeightConstraint;
            }

            // Prevent making the view too small
            if (_heightConstraint.Constant < MinimumHeight)
            {
                _heightConstraint.Constant = MinimumHeight;
            }

            // Enables 'flick' gesture to switch between states
            if (recognizer.State == UIGestureRecognizerState.Ended)
            {
                if (Math.Abs(recognizer.VelocityInView(View).Y) > 0)
                {
                    HandleFlick(recognizer);
                }

                if (_heightConstraint.Constant == MinimumHeight && AllowsMinimizedState)
                {
                    _currentState = BottomSheetState.Minimized;
                }
                else if (_heightConstraint.Constant == MaxHeightConstraint)
                {
                    _currentState = BottomSheetState.Full;
                }
                else
                {
                    _currentState = BottomSheetState.Partial;
                }
            }

            recognizer.SetTranslation(new CoreGraphics.CGPoint(0, 0), View);
        }
        void OnMenuPan(UIPanGestureRecognizer panGestureRecognizer)
        {
            var translationX = panGestureRecognizer.TranslationInView(View).X;
            var menuView     = menuViewController.View;

            switch (panGestureRecognizer.State)
            {
            case UIGestureRecognizerState.Began:
            {
                menuAnimator?.StopAnimation(true);
            }
            break;

            case UIGestureRecognizerState.Changed:
            {
                var potentialNewX     = menuView.Frame.X + translationX;
                var translationFactor = GetMenuTranslationFactor(potentialNewX);
                var newX             = menuView.Frame.X + (translationX * translationFactor);
                var totalXDistance   = UIScreen.MainScreen.Bounds.Width - Constants.MenuRightMargin;
                var percentMaximized = (newX + UIScreen.MainScreen.Bounds.Width) / totalXDistance;

                menuView.Frame = new CGRect
                {
                    Location = new CGPoint
                    {
                        X = newX,
                        Y = menuView.Frame.Y,
                    },
                    Size = menuView.Frame.Size,
                };

                menuViewController.SetPercentMaximized((float)percentMaximized);
                menuBackgroundView.Alpha = percentMaximized;
                panGestureRecognizer.SetTranslation(CGPoint.Empty, View);
            }
            break;

            case UIGestureRecognizerState.Ended:
            {
                var x                        = menuView.Frame.X;
                var velocityX                = panGestureRecognizer.VelocityInView(View).X;
                var totalXDistance           = UIScreen.MainScreen.Bounds.Width - Constants.MenuRightMargin;
                var shouldMaximizeByLocation = (x + UIScreen.MainScreen.Bounds.Width) >= totalXDistance / 3f;

                var shouldMaximizeByVelocity = velocityX > Constants.PulloutVelocityThreshold;
                var shouldMinimizeByVelocity = -velocityX > Constants.PulloutVelocityThreshold;
                var shouldMaximize           = !shouldMinimizeByVelocity && (shouldMaximizeByLocation || shouldMaximizeByVelocity);

                var DEST_X            = shouldMaximize ? -Constants.MenuRightMargin : -UIScreen.MainScreen.Bounds.Width;
                var remainingDistance = Math.Abs(x - DEST_X);

                var initialVelocity = MenuIsExceedingBoundaries(menuView.Frame) ? 0f : (nfloat)Math.Abs(velocityX / remainingDistance);
                AnimateMenu(shouldMaximize ? MenuState.Open : MenuState.Closed, (float)initialVelocity);
            }
            break;
            }
        }
        private void InfoPanGesture(UIPanGestureRecognizer recognizer)
        {
            if (_height < 0)
            {
                _height = _infoBlockView.Bounds.Height + IPHONE_X_OFFSET;
            }

            _maxInfoBlockTop = base.View.Bounds.Height - _height;

            var translation = recognizer.TranslationInView(_infoBlockView);
            var velocity    = recognizer.VelocityInView(_infoBlockView);

            if (Math.Abs(velocity.X) > Math.Abs(velocity.Y))
            {
                return;
            }

            var y = _infoBlockView.Frame.GetMinY();

            if (recognizer.State == UIGestureRecognizerState.Changed)
            {
                if ((y + translation.Y >= _maxInfoBlockTop) && (y + translation.Y <= _minInfoBlockTop))
                {
                    _infoBlockView.Frame = new CGRect(0, y + translation.Y, _infoBlockView.Bounds.Width, _height);
                }
                else
                {
                    _infoBlockView.Frame = new CGRect(0, (translation.Y >= 0) ? _minInfoBlockTop : _maxInfoBlockTop,
                                                      _infoBlockView.Bounds.Width, _height);
                    _titleLabel.Alpha    = (translation.Y >= 0) ? 0 : 1;
                    _addressLabel.Alpha  = (translation.Y >= 0) ? 0 : 1;
                    _distanceView.Alpha  = (translation.Y >= 0) ? 0 : 1;
                    _workTimeLabel.Alpha = (translation.Y >= 0) ? 0 : 1;
                    _infoLabel.Alpha     = (translation.Y >= 0) ? 0 : 1;
                }

                recognizer.SetTranslation(CGPoint.Empty, _infoBlockView);
            }
            else if (recognizer.State == UIGestureRecognizerState.Ended)
            {
                var duration = velocity.Y < 0 ? (y - _maxInfoBlockTop) / -velocity.Y : (_minInfoBlockTop - y) / velocity.Y;
                duration = duration > 1 ? (nfloat)0.8 : duration;

                UIView.Animate(duration, 0, UIViewAnimationOptions.AllowUserInteraction, () =>
                {
                    _infoBlockView.Frame = new CGRect(0, (velocity.Y >= 0) ? _minInfoBlockTop : _maxInfoBlockTop,
                                                      _infoBlockView.Bounds.Width, _height);

                    _titleLabel.Alpha    = (velocity.Y >= 0) ? 0 : 1;
                    _addressLabel.Alpha  = (velocity.Y >= 0) ? 0 : 1;
                    _distanceView.Alpha  = (velocity.Y >= 0) ? 0 : 1;
                    _workTimeLabel.Alpha = (velocity.Y >= 0) ? 0 : 1;
                    _infoLabel.Alpha     = (velocity.Y >= 0) ? 0 : 1;
                }, null);
            }
        }
Beispiel #28
0
        void DetectPan()
        {
            var dragView = Element as eliteElements.eliteVideo;
            var ne       = Xamarin.Forms.Platform.iOS.Platform.GetRenderer(Element).NativeView;

            if (longPress || dragView.DragMode == eliteElements.eliteVideo.DragMod.Touch)
            {
                if (panGesture.State == UIGestureRecognizerState.Began)
                {
                    dragView.DragStarted();
                    if (firstTime)
                    {
                        originalPosition = Center;
                        firstTime        = false;
                    }
                }

                CGPoint translation    = panGesture.TranslationInView(Superview);
                var     currentCenterX = Center.X;
                var     currentCenterY = Center.Y;
                if (dragView.DragDirection == eliteElements.eliteVideo.DragDirectionType.All || dragView.DragDirection == eliteElements.eliteVideo.DragDirectionType.Horizontal)
                {
                    currentCenterX = lastLocation.X + translation.X;
                }

                if (dragView.DragDirection == eliteElements.eliteVideo.DragDirectionType.All || dragView.DragDirection == eliteElements.eliteVideo.DragDirectionType.Vertical)
                {
                    currentCenterY = lastLocation.Y + translation.Y;
                }
                if (((currentCenterX >= 30 && currentCenterX <= sW - 30)) && ((currentCenterY >= 30 && currentCenterY <= sH - 30)))
                {
                    Center = new CGPoint(currentCenterX, currentCenterY);
                }

                if (panGesture.State == UIGestureRecognizerState.Ended)
                {
                    dragView.DragEnded();
                    longPress    = false;
                    lastLocation = Center;
                }
            }
        }
        private void SlideToOpenMasterViewController(UIPanGestureRecognizer panGestureRecognizer)
        {
            var translation = panGestureRecognizer.TranslationInView(View);
            var progress    = MenuHelper.CalculateProgress(translation, View.Bounds, Direction.Rigth);

            MenuHelper.MapGestureStateToInteractor(
                panGestureRecognizer.State,
                progress,
                _interactor,
                OpenMasterViewController);
        }
        private void SlideToCloseActionHandler(UIPanGestureRecognizer panGestureRecognizer)
        {
            var translation = panGestureRecognizer.TranslationInView(_masterRootView);
            var progress    = MenuHelper.CalculateProgress(translation, _masterRootView.Bounds, Direction.Left);

            MenuHelper.MapGestureStateToInteractor(
                panGestureRecognizer.State,
                progress,
                _interactor,
                _closeMasterAction);
        }
Beispiel #31
0
        public void Null()
        {
            using (var pgr = new UIPanGestureRecognizer(Null)) {
                pgr.SetTranslation(CGPoint.Empty, null);

                var pt = pgr.TranslationInView(null);
                Assert.That(pt, Is.EqualTo(CGPoint.Empty), "TranslationInView");

                pt = pgr.VelocityInView(null);
                Assert.That(pt, Is.EqualTo(CGPoint.Empty), "VelocityInView");
            }
        }
Beispiel #32
0
        private void OnPanGesture(UIPanGestureRecognizer recognizer)
        {
            if (!MenuEnabled)
            {
                return;
            }

            var translation = recognizer.TranslationInView(recognizer.View);
            var movement    = translation.X - draggingPoint.X;

            switch (recognizer.State)
            {
            case UIGestureRecognizerState.Began:
                draggingPoint = translation;
                break;

            case UIGestureRecognizerState.Changed:
                var newX = CurrentX;
                newX += movement;
                if (newX > MinDraggingX && newX < MaxDraggingX)
                {
                    MoveToLocation(newX);
                }
                draggingPoint = translation;
                break;

            case UIGestureRecognizerState.Ended:
                if (Math.Abs(translation.X) >= velocityTreshold)
                {
                    if (translation.X < 0)
                    {
                        CloseMenu();
                    }
                    else
                    {
                        OpenMenu();
                    }
                }
                else
                {
                    if (Math.Abs(CurrentX) < (Width - menuOffset) / 2)
                    {
                        CloseMenu();
                    }
                    else
                    {
                        OpenMenu();
                    }
                }
                break;
            }
        }
		private void HandleOnGestureRecognizer (UIPanGestureRecognizer gestureRecognizer)
		{
			// The translation of the pan gesture in the coordinate system of the specified view.
			var xTranslation = gestureRecognizer.TranslationInView (this).X;
			var yTranslation = gestureRecognizer.TranslationInView (this).Y;

			if (gestureRecognizer.State.Equals (UIGestureRecognizerState.Began)) {
				_startingPoint = Center;
			} 
			else if (gestureRecognizer.State.Equals (UIGestureRecognizerState.Changed)) {
				var rotationStrength = Math.Min (xTranslation / RotationStrength, 1);
				var rotationAngle = (nfloat)(2 * Math.PI * rotationStrength / 17);
				var scaleStrength = 1 - Math.Abs (rotationStrength) / 4;
				var scale = (nfloat)Math.Max (scaleStrength, ScaleStrength);
				var transform = CGAffineTransform.MakeRotation (rotationAngle);

				Center = new CGPoint (_startingPoint.X + xTranslation, _startingPoint.Y + yTranslation);
				Transform = CGAffineTransform.Scale (transform, scale, scale);
			} 
			else if (gestureRecognizer.State.Equals (UIGestureRecognizerState.Ended)) {
				DetermineSwipeAction (xTranslation);
				ResetView ();
			}
		}
        protected void HandleDrag(UIPanGestureRecognizer recognizer)
        {
            // if it's just began, cache the location of the image
            if (recognizer.State == UIGestureRecognizerState.Began)
                originalImageFrame = imgDragMe.Frame;

            if (recognizer.State != (UIGestureRecognizerState.Cancelled | UIGestureRecognizerState.Failed
                | UIGestureRecognizerState.Possible)) {

                // move the shape by adding the offset to the object's frame
                System.Drawing.PointF offset = recognizer.TranslationInView (imgDragMe);
                System.Drawing.RectangleF newFrame = originalImageFrame;
                newFrame.Offset (offset.X, offset.Y);
                imgDragMe.Frame = newFrame;
            }
        }
        public void HandleGesture(UIPanGestureRecognizer panGestureRecognizer)
        {
            PointF translation = panGestureRecognizer.TranslationInView (panGestureRecognizer.View.Superview);

            switch (gestureRecognizer.State) {
            case UIGestureRecognizerState.Began:
                TrackGestureBegan (translation);
                break;
            case UIGestureRecognizerState.Changed:
                TrackGestureChaged (translation);
                break;
            case UIGestureRecognizerState.Ended:
            case UIGestureRecognizerState.Cancelled:
                TrackGestureEnded (panGestureRecognizer.State);
                break;
            }
        }
		private void HandleDrag(UIPanGestureRecognizer recognizer)
		{
			// If it's just began, cache the location of the image
			if (recognizer.State == UIGestureRecognizerState.Began)
			{
				originalImageFrame = DragImage.Frame;
			}

			// Move the image if the gesture is valid
			if (recognizer.State != (UIGestureRecognizerState.Cancelled | UIGestureRecognizerState.Failed
				| UIGestureRecognizerState.Possible))
			{
				// Move the image by adding the offset to the object's frame
				CGPoint offset = recognizer.TranslationInView(DragImage);
				CGRect newFrame = originalImageFrame;
				newFrame.Offset(offset.X, offset.Y);
				DragImage.Frame = newFrame;
			}
		}
        //TODO: Step 11b - Provide the handler drag event
        private void HandleDrag(UIPanGestureRecognizer recognizer)
        {
            switch (recognizer.State)
            {
                case UIGestureRecognizerState.Began:
                    // if it's just began, cache the location of the image
                    originalImageFrame = imgDragMe.Frame;
                    break;

                case UIGestureRecognizerState.Possible:
                case UIGestureRecognizerState.Cancelled:
                case UIGestureRecognizerState.Failed:
                    return;
            }

            // move the shape by adding the offset to the object's frame
            PointF offset = recognizer.TranslationInView(imgDragMe);
            var newFrame = originalImageFrame;
            newFrame.Offset(offset.X, offset.Y);
            imgDragMe.Frame = newFrame;
        }
        public void HandleGesture(UIPanGestureRecognizer gestureRecognizer)
        {
            CGPoint translation = gestureRecognizer.TranslationInView (gestureRecognizer.View.Superview);

            switch (gestureRecognizer.State) {
            case UIGestureRecognizerState.Began:
                bool topToBottomSwipe = translation.Y > 0f;
                if (operation == CEInteractionOperation.Pop) {
                    if (topToBottomSwipe) {
                        InteractionInProgress = true;
                        viewController.NavigationController.PopViewController (true);
                    }
                } else {
                    InteractionInProgress = true;
                    viewController.DismissViewController (true, null);
                }
                break;
            case UIGestureRecognizerState.Changed:
                if (InteractionInProgress) {
                    // compute the current position
                    float fraction = (float)translation.Y / 200f;
                    fraction = Math.Min (Math.Max (fraction, 0f), 1f);
                    shouldCompleteTransition = (fraction > 0.5f);

                    UpdateInteractiveTransition (fraction);
                }
                break;
            case UIGestureRecognizerState.Ended:
            case UIGestureRecognizerState.Cancelled:
                if (InteractionInProgress) {
                    InteractionInProgress = false;
                    if (!shouldCompleteTransition || gestureRecognizer.State == UIGestureRecognizerState.Cancelled) {
                        CancelInteractiveTransition ();
                    } else {
                        FinishInteractiveTransition ();
                    }
                }
                break;
            }
        }
Beispiel #39
0
        void PanGestureRecognized(UIPanGestureRecognizer recognizer)
        {
            //          if ([self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:didRecognizePanGesture:)])
            //              [self.delegate sideMenu:self didRecognizePanGesture:recognizer];

            if (!_panGestureEnabled) {
                return;
            }

            PointF point = recognizer.TranslationInView(View);

            if (recognizer.State == UIGestureRecognizerState.Began) {
                UpdateContentViewShadow();

                _originalPoint = new PointF((float)(_contentViewContainer.Center.X - _contentViewContainer.Bounds.Width / 2.0),
                    (float)(_contentViewContainer.Center.Y - _contentViewContainer.Bounds.Height / 2.0));
                _menuViewContainer.Transform = CGAffineTransform.MakeIdentity();
                if (_scaleBackgroundImageView) {
                    _backgroundImageView.Transform = CGAffineTransform.MakeIdentity();
                    _backgroundImageView.Frame = View.Bounds;
                }
                _menuViewContainer.Frame = View.Bounds;
                AddContentButton();
                View.Window.EndEditing(true);
                _didNotifyDelegate = false;
            }

            if (recognizer.State == UIGestureRecognizerState.Changed) {
                float delta = 0;
                if (Visible) {
                    delta = _originalPoint.X != 0 ? (point.X + _originalPoint.X) / _originalPoint.X : 0;
                } else {
                    delta = point.X / View.Frame.Size.Width;
                }
                delta = Math.Min(Math.Abs(delta), 1.6F);

                float contentViewScale = _scaleContentView ? 1 - ((1 - _contentViewScaleValue) * delta) : 1;

                float backgroundViewScale = 1.7f - (0.7f * delta);
                float menuViewScale = 1.5f - (0.5f * delta);

                if (!_bouncesHorizontally) {
                    contentViewScale = Math.Max(contentViewScale, _contentViewScaleValue);
                    backgroundViewScale = Math.Max(backgroundViewScale, 1.0F);
                    menuViewScale = Math.Max(menuViewScale, 1.0F);
                }

                _menuViewContainer.Alpha = delta;

                if (_scaleBackgroundImageView) {
                    _backgroundImageView.Transform = CGAffineTransform.MakeScale(backgroundViewScale, backgroundViewScale);
                }

                if (_scaleMenuView) {
                    _menuViewContainer.Transform = CGAffineTransform.MakeScale(menuViewScale, menuViewScale);
                }

                if (_scaleBackgroundImageView) {
                    if (backgroundViewScale < 1) {
                        _backgroundImageView.Transform = CGAffineTransform.MakeIdentity();
                    }
                }

                if (!_bouncesHorizontally && Visible) {
                    if (_contentViewContainer.Frame.Location.X > _contentViewContainer.Frame.Size.Width / 2.0)
                        point.X = Math.Min(0.0F, point.X);

                    if (_contentViewContainer.Frame.Location.X < -(_contentViewContainer.Frame.Size.Width / 2.0))
                        point.X = Math.Max(0.0F, point.X);
                }

                // Limit size
                //
                if (point.X < 0) {
                    point.X = Math.Max(point.X, - UIScreen.MainScreen.Bounds.Size.Height);
                } else {
                    point.X = Math.Min(point.X, UIScreen.MainScreen.Bounds.Size.Height);
                }
                recognizer.SetTranslation (point, View);

                if (!_didNotifyDelegate) {
                    if (point.X > 0) {
                        //                      if (!Visible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willShowMenuViewController:)]) {
                        //                          [self.delegate sideMenu:self willShowMenuViewController:self.leftMenuViewController];
                        //                      }
                    }
                    if (point.X < 0) {

                        //                      if (!self.visible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willShowMenuViewController:)]) {
                        //                          //[self.delegate sideMenu:self willShowMenuViewController:self.rightMenuViewController];
                        //                      }
                    }
                    _didNotifyDelegate = true;
                }

                if (contentViewScale > 1) {
                    float oppositeScale = (1 - (contentViewScale - 1));
                    _contentViewContainer.Transform = CGAffineTransform.MakeScale(oppositeScale, oppositeScale);
                    _contentViewContainer.Transform = CGAffineTransform.Translate(_contentViewContainer.Transform, point.X, 0);
                } else {
                    _contentViewContainer.Transform = CGAffineTransform.MakeScale(contentViewScale, contentViewScale);
                    _contentViewContainer.Transform = CGAffineTransform.Translate(_contentViewContainer.Transform, point.X, 0);
                }

                if (_leftMenuViewController != null)
                    _leftMenuViewController.View.Hidden = _contentViewContainer.Frame.Location.X < 0;
                if (_rightMenuViewController != null)
                    _rightMenuViewController.View.Hidden = _contentViewContainer.Frame.Location.X > 0;

                if (_leftMenuViewController == null && _contentViewContainer.Frame.Location.X > 0) {
                    _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                    _contentViewContainer.Frame = View.Bounds;
                    Visible = false;
                    _leftMenuVisible = false;
                } else  if (_rightMenuViewController == null && _contentViewContainer.Frame.Location.X < 0) {
                    _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                    _contentViewContainer.Frame = View.Bounds;
                    Visible = false;
                    _rightMenuVisible = false;
                }

                StatusBarNeedsAppearanceUpdate ();
            }

            if (recognizer.State == UIGestureRecognizerState.Ended) {
                _didNotifyDelegate = false;

                if (_leftMenuViewController != null)
                    _leftMenuViewController.View.Hidden = false;
                if (_rightMenuViewController != null)
                    _rightMenuViewController.View.Hidden = false;

                if (_panMinimumOpenThreshold > 0 && (
                    (_contentViewContainer.Frame.Location.X < 0 && _contentViewContainer.Frame.Location.X > -((int)_panMinimumOpenThreshold)) ||
                    (_contentViewContainer.Frame.Location.X > 0 && _contentViewContainer.Frame.Location.X < _panMinimumOpenThreshold))
                ) {
                    HideMenuViewController (this, null);
                }
                else if (_contentViewContainer.Frame.Location.X == 0) {
                    HideMenuViewControllerAnimated(false);
                }
                else {
                    if (recognizer.VelocityInView(View).X > 0) {
                        if (_contentViewContainer.Frame.Location.X < 0) {
                            HideMenuViewController (this, null);
                        } else {
                            if (_leftMenuViewController != null) {
                                ShowLeftMenuViewController ();
                            }
                        }
                    } else {
                        if (_contentViewContainer.Frame.Location.X < 20) {
                            if (_rightMenuViewController != null) {
                                ShowRightMenuViewController ();
                            }
                        } else {
                            HideMenuViewController (this, null);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Handles the pan gesture.
        /// </summary>
        void HandlePan(UIPanGestureRecognizer panGest)
        {
            var view = this.contentContainerView;

            if(!this.EnablePanGesture)
            {
                return;
            }

            if (panGest.State == UIGestureRecognizerState.Began)
            {
                this.panStartX = panGest.LocationInView(view).X;
            }
            else if (panGest.State == UIGestureRecognizerState.Changed && panStartX < PAN_GESTURE_REC_WIDTH)
            {
                float currentX = panGest.TranslationInView(view).X;
                if (currentX < PAN_GESTURE_THRESHOLD)
                {
                    if (currentX >= 0)
                    {
                        this.RevealMenu(currentX);
                        this.ShowDimView(true, currentX / WIDTH);
                    }
                }
                else
                {
                    // If dragged past threshold, fully show the menu.
                    this.ShowMenu(true);
                }
            }
            else if (panGest.State == UIGestureRecognizerState.Cancelled || panGest.State == UIGestureRecognizerState.Ended || panGest.State == UIGestureRecognizerState.Failed)
            {
                panStartX = 0f;
                if (!this.IsMenuVisible)
                {
                    // Hide if not panned past threshold.
                    this.ShowMenu(false);
                }
            }
        }
        private void HandlePanEnded(UIPanGestureRecognizer gesture)
        {
            var translation = gesture.TranslationInView(_canvasView);

            foreach (var view in _selectedElements)
            {
                var center = view.Center;
                center.X += translation.X;
                center.Y += translation.Y;

                view.Center = center;
            }
        }
Beispiel #42
0
        /// <summary>
        /// Pan the specified some.
        /// </summary>
        /// <param name="some">Some.</param>
        private void Pan(UIPanGestureRecognizer pan)
        {
            CGRect rect = this.Frame;
            if (this.MapAllowPan &&
                rect.Width > 0 && this.Map != null)
            {
                this.StopCurrentAnimation();
                CGPoint offset = pan.TranslationInView(this);
                if (pan.State == UIGestureRecognizerState.Ended)
                {
                    this.NotifyMovementByInvoke();

                    // raise map touched event.
                    this.RaiseMapTouched();
                    this.RaiseMapTouchedUp();
                }
                else if (pan.State == UIGestureRecognizerState.Began)
                {
                    _prevOffset = new CGPoint(0, 0);
                    this.RaiseMapTouchedDown();
                }
                else if (pan.State == UIGestureRecognizerState.Changed)
                {
                    View2D view = this.CreateView(rect);
                    double centerXPixels = rect.Width / 2.0f - (offset.X - _prevOffset.X);
                    double centerYPixels = rect.Height / 2.0f - (offset.Y - _prevOffset.Y);

                    _prevOffset = offset;

                    double[] sceneCenter = view.FromViewPort(rect.Width, rect.Height,
                        centerXPixels, centerYPixels);

                    this.MapCenter = this.Map.Projection.ToGeoCoordinates(
                        sceneCenter[0], sceneCenter[1]);

                    this.NotifyMovementByInvoke();

                    // raise map move event.
                    this.RaiseMapMove();
                }
            }
        }
		void HandlePanSplitter (UIPanGestureRecognizer pan)
		{
			try {
				
				var t = pan.TranslationInView (View);

				if (pan.State == UIGestureRecognizerState.Began) {
					panStartRatio = Ratio;
					Splitter.Touching = true;
				}
				else if (pan.State == UIGestureRecognizerState.Changed) {
					var w = View.Bounds.Width;
					var rr = panStartRatio + t.X / w;
					Ratio = rr;
					containerView.BackgroundColor = First.View.BackgroundColor;
					containerView.SetNeedsLayout ();
				}
				else {
					Splitter.Touching = false;
				}

			} catch (Exception ex) {
				Console.WriteLine (ex);
			}
		}
		void PanGestureMoveAround (UIPanGestureRecognizer gesture)
		{
			
			UIView piece = gesture.View;

			AdjustAnchorPointForGestureRecognizer (gesture);

			if (gesture.State == UIGestureRecognizerState.Began || gesture.State == UIGestureRecognizerState.Changed) {

				PointF translation = gesture.TranslationInView (piece.Superview);

				piece.Center = new PointF (piece.Center.X, piece.Center.Y + translation.Y);
				 
				gesture.SetTranslation (new PointF (0, 0), piece.Superview);

			} else if (gesture.State == UIGestureRecognizerState.Ended) {
				SlideAndFix (gesture);
			} 		
		}
        public void DragContentView(UIPanGestureRecognizer panGesture)
        {
            if (ShouldStayOpen || mainView == null)
                return;
            RectangleF frame = mainView.Frame;
            float translation = panGesture.TranslationInView(View).X;
            //Console.WriteLine (translation);

            if (panGesture.State == UIGestureRecognizerState.Began)
            {
                startX = frame.X;
            }
            else if (panGesture.State == UIGestureRecognizerState.Changed)
            {
                frame.X = translation + startX;
                if (frame.X < 0)
                    frame.X = 0;
                else if (frame.X > frame.Width)
                    frame.X = menuWidth;
                SetLocation(frame);
            }
            else if (panGesture.State == UIGestureRecognizerState.Ended)
            {
                float velocity = panGesture.VelocityInView(View).X;
                //Console.WriteLine (velocity);
                float newX = translation + startX;
                Console.WriteLine(translation + startX);
                bool show = (Math.Abs(velocity) > sidebarFlickVelocity)
                                ? (velocity > 0)
                                : startX < menuWidth ? (newX > (menuWidth/2)) : newX > menuWidth;
                if (show)
                    ShowMenu();
                else
                    HideMenu();
            }
        }
        private void Panned(UIPanGestureRecognizer gestureRecognizer)
        {
            if (this.items.Count < 2 || this.contentWidth <= this.View.Bounds.Width)
            {
                return;
            }

            // quick hack for nested panoramas
            if (this.presentedController is UIPanoramaViewController)
            {
                return;
            }

            var panLocation = gestureRecognizer.TranslationInView(this.ContentView);

            var offset = this.currentScrolledOffset - panLocation.X;

            // this is the total amount that we've scrolled away from zero
            this.LayoutContent(this.LimitOffset(offset));

            if (gestureRecognizer.State != UIGestureRecognizerState.Ended)
            {
                return;
            }

            var velocity = gestureRecognizer.VelocityInView(this.View).X;

            if (Math.Abs(velocity) < 700)
            {
                this.currentScrolledOffset = this.CalculatePannedLocation(offset, panLocation.X);
                this.ScrollContent(currentScrolledOffset);
            }
            else
            {
                if (panLocation.X < 0)
                {
                    var proposedOffset = this.GetNextOffset(offset);

                    this.currentScrolledOffset = proposedOffset;
                }
                else
                {
                    var proposedOffset = this.GetPriorOffset(offset);

                    this.currentScrolledOffset = proposedOffset;
                }

                this.ScrollContent(this.currentScrolledOffset);
            }

            gestureRecognizer.SetTranslation(PointF.Empty, this.View);
        }
        private void OnPanGesture (UIPanGestureRecognizer recognizer)
        {
            var translation = recognizer.TranslationInView (recognizer.View);
            var movement = translation.X - draggingPoint.X;
            var main = window.RootViewController as MainViewController;
            var currentX = main.View.Frame.X;

            switch (recognizer.State) {
            case UIGestureRecognizerState.Began:
                draggingPoint = translation;
                break;

            case UIGestureRecognizerState.Changed:
                var newX = currentX;
                newX += movement;
                if (newX > MinDraggingX && newX < MaxDraggingX) {
                    main.MoveToLocation (newX);
                }
                draggingPoint = translation;
                break;

            case UIGestureRecognizerState.Ended:
                if (Math.Abs (translation.X) >= velocityTreshold) {
                    if (translation.X < 0) {
                        main.CloseMenu ();
                    } else {
                        main.OpenMenu ();
                    }
                } else {
                    if (Math.Abs (currentX) < (View.Frame.Width - menuOffset) / 2) {
                        main.CloseMenu ();
                    } else {
                        main.OpenMenu ();
                    }
                }
                break;
            }
        }
 public void DragContentView(UIPanGestureRecognizer panGesture)
 {
     if (ShouldStayOpen || mainView == null)
         return;
     if (!HideShadow)
         View.InsertSubviewBelow(shadowView, mainView);
     navigation.View.Hidden = false;
     RectangleF frame = mainView.Frame;
     shadowView.Frame = frame;
     float translation = panGesture.TranslationInView(View).X;
     if (panGesture.State == UIGestureRecognizerState.Began)
     {
         startX = frame.X;
     }
     else if (panGesture.State == UIGestureRecognizerState.Changed)
     {
         frame.X = translation + startX;
         if (Position == FlyOutNavigationPosition.Left)
         {
             if (frame.X < 0)
                 frame.X = 0;
             else if (frame.X > menuWidth)
                 frame.X = menuWidth;
         }
         else
         {
             if (frame.X > 0)
                 frame.X = 0;
             else if (frame.X < -menuWidth)
                 frame.X = -menuWidth;
         }
         SetLocation(frame);
     }
     else if (panGesture.State == UIGestureRecognizerState.Ended)
     {
         float velocity = panGesture.VelocityInView(View).X;
         float newX = translation + startX;
         bool show = Math.Abs (velocity) > sidebarFlickVelocity ? velocity > 0 : newX > (menuWidth / 2);
         if (Position == FlyOutNavigationPosition.Right) {
             show = Math.Abs(velocity) > sidebarFlickVelocity ? velocity < 0 : newX < -(menuWidth / 2);
         }
         if (show) {
             ShowMenu ();
         } else {
             HideMenu ();
         }
     }
 }
Beispiel #49
0
        /// <summary>
        /// Pan the specified some.
        /// </summary>
        /// <param name="some">Some.</param>
        private void Pan(UIPanGestureRecognizer pan)
        {
            OsmSharp.Logging.Log.TraceEvent("MapView", TraceEventType.Error,
                string.Format("{0} ", pan.State.ToString()));

            //RectangleF2D rect = _rect;
            RectangleF rect = this.Frame;
            if (this.MapAllowPan &&
                rect.Width > 0)
            {
                this.StopCurrentAnimation();
                PointF offset = pan.TranslationInView(this);
                if (pan.State == UIGestureRecognizerState.Ended)
                {
                    _beforePan = null;

                    this.Change(true); // notifies change.
                }
                else if (pan.State == UIGestureRecognizerState.Began)
                {
                    _beforePan = this.MapCenter;
                }
                else if (pan.State == UIGestureRecognizerState.Cancelled ||
                         pan.State == UIGestureRecognizerState.Failed)
                {
                    _beforePan = null;
                }
                else if (pan.State == UIGestureRecognizerState.Changed)
                {
                    _mapCenter = _beforePan;

                    View2D view = this.CreateView(rect);
                    double centerXPixels = rect.Width / 2.0f - offset.X;
                    double centerYPixels = rect.Height / 2.0f - offset.Y;

                    double[] sceneCenter = view.FromViewPort(rect.Width, rect.Height,
                                               centerXPixels, centerYPixels);

                    _mapCenter = this.Map.Projection.ToGeoCoordinates(
                        sceneCenter[0], sceneCenter[1]);

                    this.InvokeOnMainThread(InvalidateMap);
                }
            }
        }
        public void DragContentView(UIPanGestureRecognizer panGesture)
        {
            if (ShouldStayOpen)
                return;
            var translation = panGesture.TranslationInView (View).X;
            var frame = mainView.Bounds;
            if (panGesture.State == UIGestureRecognizerState.Changed) {
                if (IsOpen) {
                    if (translation > 0.0f) {
                        ShowMenu();
                    } else if (translation < - menuWidth) {
                        HideMenu();
                    } else {
                        frame.X = menuWidth + translation;
                        SetLocation(frame);
                    }
                } else {
                    if (translation < 0.0f) {
                        HideMenu();
                    } else if (translation > menuWidth) {
                        ShowMenu();
                    } else {
                        frame.X = translation;
                        SetLocation(frame);
                    }
                }
            } else if (panGesture.State == UIGestureRecognizerState.Ended) {
                var velocity = panGesture.VelocityInView(View).X;
                bool show = (Math.Abs(velocity) > sidebarFlickVelocity)
                    ? (velocity > 0)
                        : (translation > (menuWidth / 2));
                if(show)
                    ShowMenu();
                else
                    HideMenu();

            }
        }
Beispiel #51
0
        void HandleDrag(UIPanGestureRecognizer sender)
        {
            switch (sender.State)
            {
                case UIGestureRecognizerState.Began:
                    startPos = this.Center;
                // Determines if the view can be pulled in the x or y axis
                    verticalAxis = closedCenter.X == openedCenter.X;
                // Finds the minimum and maximum points in the axis
                    if (verticalAxis)
                    {
                        minPos = closedCenter.Y < openedCenter.Y ? closedCenter : openedCenter;
                        maxPos = closedCenter.Y > openedCenter.Y ? closedCenter : openedCenter;
                    }
                    else
                    {
                        minPos = closedCenter.X < openedCenter.X ? closedCenter : openedCenter;
                        maxPos = closedCenter.X > openedCenter.X ? closedCenter : openedCenter;
                    }
                    break;
                case UIGestureRecognizerState.Changed:
                    PointF translate = sender.TranslationInView(this.Superview);
                    PointF newPos;
                // Moves the view, keeping it constrained between openedCenter and closedCenter
                    if (verticalAxis)
                    {
                        newPos = new PointF(startPos.X, startPos.Y + translate.Y);
                        if (newPos.Y < minPos.Y)
                        {
                            newPos.Y = minPos.Y;
                            translate = new PointF(0, newPos.Y - startPos.Y);
                        }

                        if (newPos.Y > maxPos.Y)
                        {
                            newPos.Y = maxPos.Y;
                            translate = new PointF(0, newPos.Y - startPos.Y);
                        }

                    }
                    else
                    {
                        newPos = new PointF(startPos.X + translate.X, startPos.Y);
                        if (newPos.X < minPos.X)
                        {
                            newPos.X = minPos.X;
                            translate = new PointF(newPos.X - startPos.X, 0);
                        }

                        if (newPos.X > maxPos.X)
                        {
                            newPos.X = maxPos.X;
                            translate = new PointF(newPos.X - startPos.X, 0);
                        }
                    }

                    sender.SetTranslation(translate, this.Superview);
                    this.Center = newPos;
                    break;
                case UIGestureRecognizerState.Ended:
                    PointF vectorVelocity = sender.VelocityInView(this.Superview);
                    float axisVelocity = verticalAxis ? vectorVelocity.Y : vectorVelocity.X;
                    PointF target = axisVelocity < 0 ? minPos : maxPos;
                    bool op = target == openedCenter ? true : false;
                    this.SetOpenedAnimated(op, animate);
                    break;
            }
        }
Beispiel #52
0
        void moveLine(UIPanGestureRecognizer gr)
        {
            // if no line selected, do nothing
            if (selectedLine == null)
                return;

            // When the pan gesture recognizer changes its position...
            if (gr.State == UIGestureRecognizerState.Changed) {
                // How far has the pan moved?
                CGPoint translation = gr.TranslationInView(this);

                // Add the translation to the current begin and end points of the line
                CGPoint begin = selectedLine.begin;
                CGPoint end = selectedLine.end;
                begin.X += translation.X;
                begin.Y += translation.Y;
                end.X += translation.X;
                end.Y += translation.Y;

                // Set the new beginning and end points of the line
                selectedLine.begin = begin;
                selectedLine.end = end;

                LineStore.updateCompletedLine(selectedLine);

                this.SetNeedsDisplay();

                gr.SetTranslation(new CGPoint(0,0),this);
            } else if (gr.State == UIGestureRecognizerState.Ended) {
                selectedLine = null;
            }
        }
Beispiel #53
0
        /// <summary>
        /// Pan the specified some.
        /// </summary>
        /// <param name="some">Some.</param>
        private void Pan(UIPanGestureRecognizer pan)
        {
            RectangleF rect = this.Frame;
            if (this.MapAllowPan &&
                rect.Width > 0)
            {
                this.StopCurrentAnimation();
                PointF offset = pan.TranslationInView(this);
                if (pan.State == UIGestureRecognizerState.Ended)
                {
                    _beforePan = null;

                    this.NotifyMovementByInvoke();
                }
                else if (pan.State == UIGestureRecognizerState.Began)
                {
                    _beforePan = this.MapCenter;
                }
                else if (pan.State == UIGestureRecognizerState.Cancelled ||
                         pan.State == UIGestureRecognizerState.Failed)
                {
                    _beforePan = null;
                }
                else if (pan.State == UIGestureRecognizerState.Changed)
                {
                    _mapCenter = _beforePan;

                    View2D view = this.CreateView(rect);
                    double centerXPixels = rect.Width / 2.0f - offset.X;
                    double centerYPixels = rect.Height / 2.0f - offset.Y;

                    double[] sceneCenter = view.FromViewPort(rect.Width, rect.Height,
                                               centerXPixels, centerYPixels);

                    _mapCenter = this.Map.Projection.ToGeoCoordinates(
                        sceneCenter[0], sceneCenter[1]);

                    this.NotifyMovementByInvoke();
                }
            }
        }
Beispiel #54
0
 public void PanGestureRecognizer(UIPanGestureRecognizer sender)
 {
     if (sender.State==UIGestureRecognizerState.Ended || sender.State==UIGestureRecognizerState.Cancelled || sender.State==UIGestureRecognizerState.Failed)
         TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.DragComplete, new TimeSpan(_nowUpdate.Ticks), translatedTouchPosition, new Vector2(0,0), new Vector2 (sender.TranslationInView(sender.View)), new Vector2(0,0)));
     else
         TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.FreeDrag, new TimeSpan(_nowUpdate.Ticks), translatedTouchPosition, new Vector2(0,0), new Vector2 (sender.TranslationInView(sender.View)), new Vector2(0,0)));
 }
		void HandlePanGesture (UIPanGestureRecognizer pan)
		{
			switch (pan.State) {
			case UIGestureRecognizerState.Changed:
				CGPoint translation = pan.TranslationInView(View);
				var center = new CGPoint (triggerCenter.X + translation.X, triggerCenter.Y + translation.Y);
				if (triggerBounds.Contains(center)) {
					Trigger.Center = center;
				}

				return;
			case UIGestureRecognizerState.Began:
				triggerCenter = Trigger.Center;
				return;
			case UIGestureRecognizerState.Ended:
				triggerCenter = CGPoint.Empty;
				return;
			}
		}
		void ResizeRegionOfInterestWithGestureRecognizer (UIPanGestureRecognizer pan)
		{
			var touchLocation = pan.LocationInView (pan.View);
			var oldRegionOfInterest = RegionOfInterest;

			switch (pan.State) {
			case UIGestureRecognizerState.Began:
				// When the gesture begins, save the corner that is closes to
				// the resize region of interest gesture recognizer's touch location.
				currentControlCorner = CornerOfRect (oldRegionOfInterest, touchLocation);
				break;


			case UIGestureRecognizerState.Changed:
				var newRegionOfInterest = oldRegionOfInterest;

				switch (currentControlCorner) {
				case ControlCorner.None:
					// Update the new region of interest with the gesture recognizer's translation.
					var translation = pan.TranslationInView (pan.View);
					// Move the region of interest with the gesture recognizer's translation.
					if (RegionOfInterest.Contains (touchLocation)) {
						newRegionOfInterest.X += translation.X;
						newRegionOfInterest.Y += translation.Y;
					}

					// If the touch location goes outside the preview layer,
					// we will only translate the region of interest in the
					// plane that is not out of bounds.
					var normalizedRect = new CGRect (0, 0, 1, 1);
					if (!normalizedRect.Contains (VideoPreviewLayer.PointForCaptureDevicePointOfInterest (touchLocation))) {
						if (touchLocation.X < RegionOfInterest.GetMinX () || touchLocation.X > RegionOfInterest.GetMaxX ()) {
							newRegionOfInterest.Y += translation.Y;
						} else if (touchLocation.Y < RegionOfInterest.GetMinY () || touchLocation.Y > RegionOfInterest.GetMaxY ()) {
							newRegionOfInterest.X += translation.X;
						}
					}

					// Set the translation to be zero so that the new gesture
					// recognizer's translation is in respect to the region of
					// interest's new position.
					pan.SetTranslation (CGPoint.Empty, pan.View);
					break;

				case ControlCorner.TopLeft:
					newRegionOfInterest = new CGRect (touchLocation.X, touchLocation.Y,
													 oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
													 oldRegionOfInterest.Height + oldRegionOfInterest.Y - touchLocation.Y);
					break;

				case ControlCorner.TopRight:
					newRegionOfInterest = new CGRect (newRegionOfInterest.X,
												 touchLocation.Y,
												 touchLocation.X - newRegionOfInterest.X,
												 oldRegionOfInterest.Height + newRegionOfInterest.Y - touchLocation.Y);
					break;


				case ControlCorner.BottomLeft:
					newRegionOfInterest = new CGRect (touchLocation.X, oldRegionOfInterest.Y,
												 oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
												 touchLocation.Y - oldRegionOfInterest.Y);
					break;

				case ControlCorner.BottomRight:
					newRegionOfInterest = new CGRect (oldRegionOfInterest.X, oldRegionOfInterest.Y,
												 touchLocation.X - oldRegionOfInterest.X,
												 touchLocation.Y - oldRegionOfInterest.Y);
					break;
				}

				// Update the region of intresest with a valid CGRect.
				SetRegionOfInterestWithProposedRegionOfInterest (newRegionOfInterest);
				break;

			case UIGestureRecognizerState.Ended:
				RegionOfInterestDidChange?.Invoke (this, EventArgs.Empty);

				// Reset the current corner reference to none now that the resize.
				// gesture recognizer has ended.
				currentControlCorner = ControlCorner.None;
				break;

			default:
				return;
			}
		}
Beispiel #57
0
		private void HandlePanGestureRecognizer(UIPanGestureRecognizer sender)
		{
			var ptPan = sender.TranslationInView(this);

			if(sender.State == UIGestureRecognizerState.Began)
				_initialContentOffset = WaveFormView.ContentOffset;

			SetContentOffsetX(_initialContentOffset.X - ptPan.X); // invert pan direction

//			if (sender.State == UIGestureRecognizerState.Ended)
//			{
//				var velocity = sender.VelocityInView(this);
//				float velocityX = velocity.X * 0.2f;
//				float finalX = ptTranslated.X + velocityX;
//				float finalY = _initialContentOffset.Y;
//				float animationDuration = (Math.Abs(velocityX) * 0.0002f) + 0.2f;
//				Console.WriteLine("HandlePanGestureRecognizer - velocityX: {0} animationDuration: {1} finalX: {2}", velocityX, animationDuration, finalX);
//			}
			//Console.WriteLine("HandlePanGestureRecognizer - state: {0} initialContentOffset: {1} ptPan: {2}", _panGesture.State, _initialContentOffset, ptPan);
		}
        private void HandlePanChanged(UIPanGestureRecognizer gesture)
        {
            var translation = gesture.TranslationInView(_canvasView);
            var transform = CGAffineTransform.MakeTranslation(translation.X, translation.Y);

            foreach (var view in _selectedElements)
            {
                view.Transform = transform;
            }
        }
		public void DragContentView(UIPanGestureRecognizer panGesture)
		{
			var translation = panGesture.TranslationInView (View).X;
			//				if (panGesture.State == UIGestureRecognizerState.Changed) {
			//					if (IsOpen) {
			//						if (translation > 0.0f) {
			//							_contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
			//							self.sidebarShowing = YES;
			//						} else if (translation < -kGHRevealSidebarWidth) {
			//							_contentView.frame = _contentView.bounds;
			//							self.sidebarShowing = NO;
			//						} else {
			//							_contentView.frame = CGRectOffset(_contentView.bounds, (kGHRevealSidebarWidth + translation), 0.0f);
			//						}
			//					} else {
			//						if (translation < 0.0f) {
			//							_contentView.frame = _contentView.bounds;
			//							self.sidebarShowing = NO;
			//						} else if (translation > kGHRevealSidebarWidth) {
			//							_contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
			//							self.sidebarShowing = YES;
			//						} else {
			//							_contentView.frame = CGRectOffset(_contentView.bounds, translation, 0.0f);
			//						}
			//					}
			//				} else if (panGesture.state == UIGestureRecognizerStateEnded) {
			//					CGFloat velocity = [panGesture velocityInView:self.view].x;
			//					BOOL show = (fabs(velocity) > kGHRevealSidebarFlickVelocity)
			//						? (velocity > 0)
			//							: (translation > (kGHRevealSidebarWidth / 2));
			//					[self toggleSidebar:show duration:kGHRevealSidebarDefaultAnimationDuration];
			//					
			//				}
		}
		// Shift the image's center by the pan amount
		void PanImage (UIPanGestureRecognizer gestureRecognizer)
		{
			AdjustAnchorPointForGestureRecognizer (gestureRecognizer);
			var image = gestureRecognizer.View;
			if (gestureRecognizer.State == UIGestureRecognizerState.Began || gestureRecognizer.State == UIGestureRecognizerState.Changed) {
				var translation = gestureRecognizer.TranslationInView (View);
				image.Center = new PointF (image.Center.X + translation.X, image.Center.Y + translation.Y);
				// Reset the gesture recognizer's translation to {0, 0} - the next callback will get a delta from the current position.
				gestureRecognizer.SetTranslation (PointF.Empty, image);
			}
		}