public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            if (selectedPoint == null)
            {
                return;
            }

            UISnapBehavior snap = new UISnapBehavior(selectedPoint, originalPosition);

            snap.Damping = 0.2f;

            UIPushBehavior push = new UIPushBehavior(new IUIDynamicItem[] { selectedPoint }, UIPushBehaviorMode.Instantaneous);

            push.PushDirection = new CGVector(0.0f, -1.0f);
            push.Magnitude     = 0.001f;

            UIDynamicAnimator animator = new UIDynamicAnimator();

            animator.AddBehavior(snap);
            animator.AddBehavior(push);

            selectedPoint.Animator = animator;
        }
        protected void DynamicAnimatorDidPause(UIDynamicAnimator animator)
        {
            this.Animator.RemoveAllBehaviors();

            _collision = null;
            _topView   = null;
            _push      = null;
            _gravity   = null;
            _composite = null;
            _animator  = null;

            this.SlidingViewController.TopViewController.View.UserInteractionEnabled = true;

            UIViewController topController = this.SlidingViewController.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextTopViewControllerKey);

            if ((_panningRight && _positiveLeftToRight) || (!_panningRight && !_positiveLeftToRight))
            {
                topController.View.Frame = this.SlidingViewController.GetFinalFrameForViewController(topController);
                this.SlidingViewController.FinishInteractiveTransition();
            }
            else if ((_panningRight && !_positiveLeftToRight) || (!_panningRight && _positiveLeftToRight))
            {
                topController.View.Frame = this.SlidingViewController.GetInitialFrameForViewController(topController);
                this.SlidingViewController.CancelInteractiveTransition();
            }

            this.SlidingViewController.CompleteTransition(true);
        }
示例#3
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            TKChartVisualPoint[] points = chart.VisualPointsForSeries(chart.Series [0]);
            originalValues = new List <CGPoint> ();
            foreach (TKChartVisualPoint p in points)
            {
                originalValues.Add(p.CGPoint);
            }
            TKChartVisualPoint point = points[4];

            UISnapBehavior snap = new UISnapBehavior(point, point.Center);

            snap.Damping = 0.2f;

            UIPushBehavior push = new UIPushBehavior(new IUIDynamicItem[] { point }, UIPushBehaviorMode.Instantaneous);

            push.PushDirection = new CGVector(0.0f, -1.0f);
            push.Magnitude     = 0.003f;

            UIDynamicAnimator animator = new UIDynamicAnimator();

            animator.AddBehavior(snap);
            animator.AddBehavior(push);

            point.Animator = animator;
        }
示例#4
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            if (selectedPoint == null)
            {
                return;
            }

            UITouch touch      = (UITouch)touches.AnyObject;
            CGPoint touchPoint = touch.LocationInView(chart.PlotView);
            CGPoint delta      = new CGPoint(originalLocation.X, originalLocation.Y - touchPoint.Y);

            UISnapBehavior snap = new UISnapBehavior(selectedPoint, originalPosition);

            snap.Damping = 0.2f;

            UIPushBehavior push = new UIPushBehavior(new IUIDynamicItem[] { selectedPoint }, UIPushBehaviorMode.Instantaneous);

            push.PushDirection = new CGVector(0.0f, delta.Y > 0 ? -1.0f : -1.0f);
            push.Magnitude     = 0.001f;

            UIDynamicAnimator animator = new UIDynamicAnimator();

            animator.AddBehavior(snap);
            animator.AddBehavior(push);

            selectedPoint.Animator = animator;
        }
示例#5
0
        private void applyForce(CGVector direction, nfloat magnitude)
        {
            var force = new UIPushBehavior(UIPushBehaviorMode.Instantaneous, spiderView);

            force.PushDirection = direction;
            force.Magnitude     = magnitude;
            spiderAnimator.AddBehavior(force);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var collisionBehavior = new UICollisionBehavior(square)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            var pushBehavior = new UIPushBehavior(UIPushBehaviorMode.Instantaneous, square)
            {
                Angle     = 0.0f,
                Magnitude = 0.0f
            };

            Animator = new UIDynamicAnimator(View);
            Animator.AddBehaviors(collisionBehavior, pushBehavior);

            redSquare.Center            = new CGPoint(View.Bounds.GetMidX(), View.Bounds.GetMidY());
            redSquare.Layer.AnchorPoint = new CGPoint(0.0f, 0.5f);

            View.AddGestureRecognizer(new UITapGestureRecognizer((gesture) => {
                /*
                 * Tapping will change the angle and magnitude of the impulse.
                 * To visually show the impulse vector on screen, a red line representing
                 * the angle and magnitude of this vector is briefly drawn.
                 */
                CGPoint p      = gesture.LocationInView(View);
                CGPoint o      = new CGPoint(View.Bounds.GetMidX(), View.Bounds.GetMidY());
                float distance = (float)Math.Sqrt((p.X - o.X) * (p.X - o.X) + (p.Y - o.Y) * (p.Y - o.Y));
                float angle    = (float)Math.Atan2(p.Y - o.Y, p.X - o.X);
                distance       = Math.Min(distance, 100.0f);

                redSquare.Bounds    = new CGRect(0.0f, 0.0f, distance, 5.0f);
                redSquare.Transform = CGAffineTransform.MakeRotation(angle);
                redSquare.Alpha     = 1.0f;

                UIView.Animate(1.0f, () => {
                    redSquare.Alpha = 0.0f;
                });

                pushBehavior.Magnitude = distance / 100.0f;
                pushBehavior.Angle     = angle;
                pushBehavior.Active    = true;
            }));
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var collisionBehavior = new UICollisionBehavior (square) {
			    TranslatesReferenceBoundsIntoBoundary = true
			};

			var pushBehavior = new UIPushBehavior (UIPushBehaviorMode.Instantaneous, square) {
				Angle = 0.0f,
				Magnitude = 0.0f
			};

			Animator = new UIDynamicAnimator (View);
			Animator.AddBehaviors (collisionBehavior, pushBehavior);

			redSquare.Center = new PointF (View.Bounds.GetMidX (), View.Bounds.GetMidY ());
			redSquare.Layer.AnchorPoint = new PointF (0.0f, 0.5f);

			View.AddGestureRecognizer (new UITapGestureRecognizer ((gesture) => {
				/*
	    		 Tapping will change the angle and magnitude of the impulse. 
    			 To visually show the impulse vector on screen, a red line representing 
    			 the angle and magnitude of this vector is briefly drawn.
    			 */
				PointF p = gesture.LocationInView (View);
				PointF o = new PointF (View.Bounds.GetMidX (), View.Bounds.GetMidY ());
				float distance = (float)Math.Sqrt ((p.X - o.X) * (p.X - o.X) + (p.Y - o.Y) * (p.Y - o.Y));
				float angle = (float)Math.Atan2 (p.Y - o.Y, p.X - o.X);
				distance = Math.Min (distance, 100.0f);

				redSquare.Bounds = new RectangleF (0.0f, 0.0f, distance, 5.0f);
				redSquare.Transform = CGAffineTransform.MakeRotation (angle);
				redSquare.Alpha = 1.0f;

				UIView.Animate (1.0f, () => {
					redSquare.Alpha = 0.0f;
				});

				pushBehavior.Magnitude = distance / 100.0f;
				pushBehavior.Angle = angle;
				pushBehavior.Active = true;
			}));
		}
示例#8
0
		public override void TouchesEnded (NSSet touches, UIEvent evt)
		{
			base.TouchesEnded (touches, evt);

			if (selectedPoint == null) {
				return;
			}

			UISnapBehavior snap = new UISnapBehavior(selectedPoint, originalPosition);
			snap.Damping = 0.2f;

			UIPushBehavior push = new UIPushBehavior(new IUIDynamicItem[] { selectedPoint }, UIPushBehaviorMode.Instantaneous);
			push.PushDirection = new CGVector(0.0f, -1.0f);
			push.Magnitude = 0.001f;

			UIDynamicAnimator animator = new UIDynamicAnimator();
			animator.AddBehavior(snap);
			animator.AddBehavior(push);

			selectedPoint.Animator = animator;
		}
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear (animated);

            TKChartVisualPoint[] points = chart.VisualPointsForSeries (chart.Series [0]);
            originalValues = new List<CGPoint> ();
            foreach (TKChartVisualPoint p in points) {
                originalValues.Add (p.CGPoint);
            }
            TKChartVisualPoint point = points[4];

            UISnapBehavior snap = new UISnapBehavior (point, point.Center);
            snap.Damping = 0.2f;

            UIPushBehavior push = new UIPushBehavior (new IUIDynamicItem[] { point }, UIPushBehaviorMode.Instantaneous);
            push.PushDirection = new CGVector (0.0f, -1.0f);
            push.Magnitude = 0.003f;

            UIDynamicAnimator animator = new UIDynamicAnimator();
            animator.AddBehavior(snap);
            animator.AddBehavior(push);

            point.Animator = animator;
        }
示例#10
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded (touches, evt);

            if (selectedPoint == null) {
                return;
            }

            UITouch touch = (UITouch)touches.AnyObject;
            CGPoint touchPoint = touch.LocationInView(chart.PlotView);
            CGPoint delta = new CGPoint(originalLocation.X, originalLocation.Y - touchPoint.Y);

            UISnapBehavior snap = new UISnapBehavior(selectedPoint, originalPosition);
            snap.Damping = 0.2f;

            UIPushBehavior push = new UIPushBehavior(new IUIDynamicItem[] { selectedPoint }, UIPushBehaviorMode.Instantaneous);
            push.PushDirection = new CGVector(0.0f, delta.Y > 0 ? -1.0f : -1.0f);
            push.Magnitude = 0.001f;

            UIDynamicAnimator animator = new UIDynamicAnimator();
            animator.AddBehavior(snap);
            animator.AddBehavior(push);

            selectedPoint.Animator = animator;
        }
        protected void DynamicAnimatorDidPause(UIDynamicAnimator animator)
        {
            this.Animator.RemoveAllBehaviors();

            _collision = null;
            _topView   = null;
            _push      = null;
            _gravity   = null;
            _composite = null;
            _animator  = null;

            this.SlidingViewController.TopViewController.View.UserInteractionEnabled = true;

            UIViewController topController = this.SlidingViewController.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextTopViewControllerKey);
            if ((_panningRight && _positiveLeftToRight) || (!_panningRight && !_positiveLeftToRight))
            {
                topController.View.Frame = this.SlidingViewController.GetFinalFrameForViewController(topController);
                this.SlidingViewController.FinishInteractiveTransition();
            }
            else if ((_panningRight && !_positiveLeftToRight) || (!_panningRight && _positiveLeftToRight))
            {
                topController.View.Frame = this.SlidingViewController.GetInitialFrameForViewController(topController);
                this.SlidingViewController.CancelInteractiveTransition();
            }

            this.SlidingViewController.CompleteTransition(true);
        }
        private void DismissImageWithFlick(PointF velocity) // COMPLETE
        {
            Flags.ImageIsFlickingAwayForDismissal = true;
            UIPushBehavior push = new UIPushBehavior (new IUIDynamicItem[] { ImageView }, UIPushBehaviorMode.Instantaneous);

            push.PushDirection = new CGVector ((float)(velocity.X * 0.12), (float)(velocity.Y * 0.12));
            push.SetTargetOffset (ImageDragOffsetFromImageCenter, ImageView);
            push.Action = () => {
                if (ImageViewIsOffscreen()) {
                    Animator.RemoveAllBehaviors();
                    AttachmentBehavior = null;
                    ImageView.RemoveFromSuperview();
                    Dismiss(true);
                }
            };
            Animator.RemoveBehavior (AttachmentBehavior);
            Animator.AddBehavior (push);
        }