Esempio n. 1
0
        public void applyGravity(object sender, EventArgs e)
        {
            animator = new UIDynamicAnimator(chart.PlotView);

            TKChartVisualPoint[] points = chart.VisualPointsForSeries(chart.Series [0]);

            for (int i = 0; i < points.Length; i++)
            {
                TKChartVisualPoint point  = points [i];
                CGPoint            center = originalValues [i];
                if (point.Animator != null)
                {
                    point.Animator.RemoveAllBehaviors();
                    point.Animator = null;
                }
                point.Center = center;
            }

            UICollisionBehavior collision = new UICollisionBehavior(points);

            collision.TranslatesReferenceBoundsIntoBoundary = true;

            UIGravityBehavior gravity = new UIGravityBehavior(points);

            gravity.GravityDirection = new CGVector(0.0f, 2.0f);

            UIDynamicItemBehavior dynamic = new UIDynamicItemBehavior(points);

            dynamic.Elasticity = 0.5f;

            animator.AddBehavior(dynamic);
            animator.AddBehavior(gravity);
            animator.AddBehavior(collision);
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			using (image = UIImage.FromFile ("monkeys.jpg")) {

				imageView = new UIImageView (new CGRect (new CGPoint (View.Center.X - image.Size.Width / 2, 0), image.Size)) {
					Image =  image
				};

				View.AddSubview (imageView);

				// 1. create the dynamic animator
				dynAnimator = new UIDynamicAnimator (this.View);

				// 2. create behavior(s)
				var dynItems = new IUIDynamicItem[] { imageView };
				var gravity = new UIGravityBehavior (dynItems);
				var collision = new UICollisionBehavior (dynItems) {
					TranslatesReferenceBoundsIntoBoundary = true
				};
				var dynBehavior = new UIDynamicItemBehavior (dynItems) {
					Elasticity = 0.7f
				};

				// 3. add behaviors(s) to the dynamic animator
				dynAnimator.AddBehavior (gravity);
				dynAnimator.AddBehavior (collision);
				dynAnimator.AddBehavior (dynBehavior);
			}
		}
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            using (image = UIImage.FromFile("monkeys.jpg")) {
                imageView = new UIImageView(new CGRect(new CGPoint(View.Center.X - image.Size.Width / 2, 0), image.Size))
                {
                    Image = image
                };

                View.AddSubview(imageView);

                // 1. create the dynamic animator
                dynAnimator = new UIDynamicAnimator(this.View);

                // 2. create behavior(s)
                var dynItems  = new IUIDynamicItem[] { imageView };
                var gravity   = new UIGravityBehavior(dynItems);
                var collision = new UICollisionBehavior(dynItems)
                {
                    TranslatesReferenceBoundsIntoBoundary = true
                };
                var dynBehavior = new UIDynamicItemBehavior(dynItems)
                {
                    Elasticity = 0.7f
                };

                // 3. add behaviors(s) to the dynamic animator
                dynAnimator.AddBehavior(gravity);
                dynAnimator.AddBehavior(collision);
                dynAnimator.AddBehavior(dynBehavior);
            }
        }
        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;
        }
Esempio n. 5
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;
        }
        public void applyGravity(object sender, EventArgs e)
        {
            animator = new UIDynamicAnimator (chart.PlotView);

            TKChartVisualPoint[] points = chart.VisualPointsForSeries (chart.Series [0]);

            for (int i=0; i<points.Length; i++) {
                TKChartVisualPoint point = points [i];
                CGPoint center = originalValues [i];
                if (point.Animator != null) {
                    point.Animator.RemoveAllBehaviors();
                    point.Animator = null;
                }
                point.Center = center;
            }

            UICollisionBehavior collision = new UICollisionBehavior (points);
            collision.TranslatesReferenceBoundsIntoBoundary = true;

            UIGravityBehavior gravity = new UIGravityBehavior (points);
            gravity.GravityDirection = new CGVector (0.0f, 2.0f);

            UIDynamicItemBehavior dynamic = new UIDynamicItemBehavior (points);
            dynamic.Elasticity = 0.5f;

            animator.AddBehavior(dynamic);
            animator.AddBehavior(gravity);
            animator.AddBehavior(collision);
        }
Esempio n. 7
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;
        }
        public void applyGravity()
        {
            if (firstTime)
            {
                firstTime = false;

                TKChartVisualPoint[] points1 = chart.VisualPointsForSeries(chart.Series [0]);
                originalValues = new List <CGPoint> ();
                foreach (TKChartVisualPoint p in points1)
                {
                    originalValues.Add(p.CGPoint);
                }
                TKChartVisualPoint point1 = points1 [4];
                originalLocation = point1.Center;
            }
            // >> chart-anim-gravity-cs
            animator = new UIDynamicAnimator(chart.PlotView);
            TKChartVisualPoint[] points = chart.VisualPointsForSeries(chart.Series [0]);
            TKChartVisualPoint   point  = points [4];

            for (int i = 0; i < originalValues.Count; i++)
            {
                TKChartVisualPoint pt = points [i];
                if (pt.Animator != null)
                {
                    pt.Animator.RemoveAllBehaviors();
                    pt.Animator = null;
                }
                pt.Center = ((CGPoint)originalValues[i]);
            }

            point.Center = new CGPoint(originalLocation.X, 0);

            UICollisionBehavior collision = new UICollisionBehavior(points);

            collision.TranslatesReferenceBoundsIntoBoundary = true;

            UIGravityBehavior gravity = new UIGravityBehavior(points);

            gravity.GravityDirection = new CGVector(0.0f, 2.0f);

            UIDynamicItemBehavior dynamic = new UIDynamicItemBehavior(points);

            dynamic.Elasticity = 0.5f;

            animator.AddBehavior(dynamic);
            animator.AddBehavior(gravity);
            animator.AddBehavior(collision);
            // << chart-anim-gravity-cs
        }
Esempio n. 9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //se crea un punto con base a la vista
            //var squareCenterPoint = new CGPoint (square.Center.X, square.Center.Y - 100.0f);

            var squareCenterPoint = new CGPoint(llanta.Center.X, llanta.Center.Y - 100.0f);

            //Representa un desplazamiento de posición. Los valores positivos están a la derecha y abajo.
            var attachmentOffset = new UIOffset(-25.0f, -25.0f);

            /*
             * By default, an attachment behavior uses the center of a view. By using a small offset,
             * we get a more interesting effect which will cause the view to have rotation movement
             * when dragging the attachment.
             */
            //var attachmentBehavior = new UIAttachmentBehavior (square, attachmentOffset, squareCenterPoint);
            var attachmentBehavior = new UIAttachmentBehavior(llanta, attachmentOffset, squareCenterPoint);

            // Muestra los puntos de fijacion
            redSquare.Center  = attachmentBehavior.AnchorPoint;
            blueSquare.Center = new CGPoint(25.0f, 25.0f);

            //se agrega la vista al dynamicAnimator donde gestiona todos los compatamientos de los objetos
            Animator = new UIDynamicAnimator(View);
            Animator.AddBehavior(attachmentBehavior);


            //Este gesto es de arrastrar
            View.AddGestureRecognizer(new UIPanGestureRecognizer((gesture) => {
                attachmentBehavior.AnchorPoint = gesture.LocationInView(View);
                redSquare.Center = attachmentBehavior.AnchorPoint;
            }));
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var collisionBehavior = new UICollisionBehavior (square);
			collisionBehavior.TranslatesReferenceBoundsIntoBoundary = true;

			var squareCenterPoint = new PointF (square.Center.X, square.Center.Y - 100);
			var attachmentOffset = new UIOffset (-25.0f, -25.0f);

			/*
    		 By default, an attachment behavior uses the center of a view. By using a small offset, 
    		 we get a more interesting effect which will cause the view to have rotation movement 
    		 when dragging the attachment.
    		*/
			var attachmentBehavior = new UIAttachmentBehavior (square, attachmentOffset, squareCenterPoint);

			// Show visually the attachment points
			redSquare.Center = attachmentBehavior.AnchorPoint;
			blueSquare.Center = new PointF (25.0f, 25.0f);

			Animator = new UIDynamicAnimator (View);
			Animator.AddBehavior (attachmentBehavior);

			View.AddGestureRecognizer (new UIPanGestureRecognizer ((gesture) => {
				attachmentBehavior.AnchorPoint = gesture.LocationInView (View);
				redSquare.Center = attachmentBehavior.AnchorPoint;
			}));
		}
Esempio n. 11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var screenBounds = UIScreen.MainScreen.Bounds;
            var length       = Math.Floor(0.1 * Math.Max(screenBounds.Width, screenBounds.Height));

            itemView = new UIView(new CGRect(0.0, 0.0, length, Math.Floor(length / ItemAspectRatio)))
            {
                AutoresizingMask = UIViewAutoresizing.None,
                BackgroundColor  = UIColor.Red
            };

            var panGestureRecognizer = new UIPanGestureRecognizer(Pan);

            itemView.AddGestureRecognizer(panGestureRecognizer);
            View.AddSubview(itemView);

            var longPressGestureRecognizer = new UILongPressGestureRecognizer(LongPress);

            View.AddGestureRecognizer(longPressGestureRecognizer);

            animator       = new UIDynamicAnimator(View);
            stickyBehavior = new StickyCornersBehavior(itemView, (float)length * 0.5f);
            animator.AddBehavior(stickyBehavior);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            var squareCenterPoint = new CGPoint(square.Center.X, square.Center.Y - 100.0f);
            var attachmentOffset  = new UIOffset(-25.0f, -25.0f);

            /*
             * By default, an attachment behavior uses the center of a view. By using a small offset,
             * we get a more interesting effect which will cause the view to have rotation movement
             * when dragging the attachment.
             */
            var attachmentBehavior = new UIAttachmentBehavior(square, attachmentOffset, squareCenterPoint);

            // Show visually the attachment points
            redSquare.Center  = attachmentBehavior.AnchorPoint;
            blueSquare.Center = new CGPoint(25.0f, 25.0f);

            Animator = new UIDynamicAnimator(View);
            Animator.AddBehavior(attachmentBehavior);

            View.AddGestureRecognizer(new UIPanGestureRecognizer((gesture) => {
                attachmentBehavior.AnchorPoint = gesture.LocationInView(View);
                redSquare.Center = attachmentBehavior.AnchorPoint;
            }));
        }
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     Animator = new UIDynamicAnimator(View);
     //agrega un comportammiento al UIView  en este caso se aplica la animacion de gravedad
     Animator.AddBehavior(new UIGravityBehavior(square));
 }
Esempio n. 14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Animador = new UIDynamicAnimator(View);               //Se asigna a la vista actual.

            Animador.AddBehavior(new UIGravityBehavior(Imagen1)); //Se agrega un comportamiento
        }
Esempio n. 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.AddGestureRecognizer(new UITapGestureRecognizer((gesture) => {
                Animator = new UIDynamicAnimator(View);
                Animator.AddBehavior(new UISnapBehavior(square, gesture.LocationInView(View)));
            }));
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			View.AddGestureRecognizer (new UITapGestureRecognizer ((gesture) => {
				Animator = new UIDynamicAnimator (View);
				Animator.AddBehavior (new UISnapBehavior (square, gesture.LocationInView (View)));
			}));
		}
Esempio n. 17
0
		public void applyGravity()
		{
			if (firstTime) {
				firstTime = false;

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

			animator = new UIDynamicAnimator (chart.PlotView);
			TKChartVisualPoint[] points = chart.VisualPointsForSeries (chart.Series [0]);
			TKChartVisualPoint point = points [4];

			for (int i=0; i<originalValues.Count; i++) {
				TKChartVisualPoint pt = points [i];
				if (pt.Animator != null) {
					pt.Animator.RemoveAllBehaviors();
					pt.Animator = null;
				}
				pt.Center = ((CGPoint)originalValues[i]);
			}

			point.Center = new CGPoint (originalLocation.X, 0);

			UICollisionBehavior collision = new UICollisionBehavior (points);
			collision.TranslatesReferenceBoundsIntoBoundary = true;

			UIGravityBehavior gravity = new UIGravityBehavior (points);
			gravity.GravityDirection = new CGVector (0.0f, 2.0f);

			UIDynamicItemBehavior dynamic = new UIDynamicItemBehavior (points);
			dynamic.Elasticity = 0.5f;

			animator.AddBehavior(dynamic);
			animator.AddBehavior(gravity);
			animator.AddBehavior(collision);
		}
Esempio n. 18
0
        private UIView[] createRope()
        {
            var    chain    = new List <UIView>();
            UIView lastLink = null;

            for (int i = 0; i < chainLength; i++)
            {
                var chainLink = createChainLink(i * chainLinkHeight, lastLink);
                chain.Add(chainLink);
                lastLink = chainLink;
            }

            var spiderAttachment = new UIAttachmentBehavior(spiderView, UIOffset.Zero, lastLink, UIOffset.Zero);

            spiderAttachment.Length = spiderAttachmentLength;
            spiderAnimator.AddBehavior(spiderAttachment);

            chain.Add(spiderView);

            return(chain.ToArray());
        }
Esempio n. 19
0
        private void preparePhysics()
        {
            spiderView.Center            = new CGPoint(Center.X, -height - spiderImage.Size.Height);
            spiderView.Layer.AnchorPoint = new CGPoint(0.5, 0);

            spiderAnimator = new UIDynamicAnimator(this);

            var spider = new UIDynamicItemBehavior(spiderView);

            spider.Action     = () => SetNeedsDisplay();
            spider.Resistance = spiderResistance;
            spiderAnimator.AddBehavior(spider);

            links = createRope();

            gravity = new UIGravityBehavior(links);
            spiderAnimator.AddBehavior(gravity);

            motionManager?.Dispose();
            motionManager = new CMMotionManager();
            motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, processAccelerometerData);
        }
        void SnapImageIntoPlace(PointF touchPoint)
        {
            if (snapRect.Contains(touchPoint))
            {
                if (snap != null)
                {
                    animator.RemoveBehavior(snap);
                }

                snap = new UISnapBehavior(imageView, snapPoint);
                animator.AddBehavior(snap);
            }
        }
Esempio n. 21
0
        private void preparePhysics()
        {
            spiderRadius = Math.Sqrt(Math.Pow(spiderImage.Size.Width / 2, 2) + Math.Pow(spiderImage.Size.Height / 2, 2));
            double height = (UIScreen.MainScreen.ApplicationFrame.Size.Width / 2) - 1.5 * spiderRadius;

            spiderAnimator = new UIDynamicAnimator(this);

            var spider = new UIDynamicItemBehavior(spiderView);

            spider.Action         = () => SetNeedsDisplay();
            spider.Resistance     = spiderResistance;
            spider.AllowsRotation = true;
            spiderAnimator.AddBehavior(spider);

            links = createRope(height);

            gravity = new UIGravityBehavior(links);
            spiderAnimator.AddBehavior(gravity);

            motionManager?.Dispose();
            motionManager = new CMMotionManager();
            motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, processAccelerometerData);
        }
Esempio n. 22
0
        private void snapTo(NSSet touches)
        {
            if (spiderView == null)
            {
                return;
            }

            var touch = (UITouch)touches.First();

            lock (spiderAnimator)
            {
                if (dragging != null)
                {
                    spiderAnimator.RemoveBehavior(dragging);
                }

                var position = touch.LocationInView(this);
                dragging = new UISnapBehavior(spiderView, position);

                spiderAnimator.RemoveBehavior(gravity);
                spiderAnimator.AddBehavior(dragging);
            }
        }
Esempio n. 23
0
 public override void PrepareLayout()
 {
     base.PrepareLayout();
     if (this.dynamicAnimator.Behaviors.Count() == 0)
     {
         var s   = this.CollectionViewContentSize;
         var rec = new RectangleF(0, 0, s.Width, s.Height);
         foreach (var item in base.LayoutAttributesForElementsInRect(rec))
         {
             UIAttachmentBehavior behaviour = new UIAttachmentBehavior(item, item.Center);
             behaviour.Length    = 0.0f;
             behaviour.Damping   = 0.8f;
             behaviour.Frequency = 1.0f;
             dynamicAnimator.AddBehavior(behaviour);
         }
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            animator = new UIDynamicAnimator(View);
            gravity = new UIGravityBehavior();
            animator.AddBehavior(gravity);

            // Tap to add new item.
            View.AddGestureRecognizer(new UITapGestureRecognizer((gesture) => {
                PointF tapLocation = gesture.LocationInView(View);
                var item = new UIView(new RectangleF(PointF.Empty, sizeInitial)) {
                    BackgroundColor = ColorHelpers.GetRandomColor(),
                    Center = tapLocation,
                };
                items.Enqueue(item);
                View.Add(item);
                gravity.AddItem(item);

                // Clean up old items so things don't get too leaky.
                if (items.Count > 20) {
                    var oldItem = items.Dequeue();
                    oldItem.RemoveFromSuperview();
                    gravity.RemoveItem(oldItem);
                    oldItem.Dispose();
                }
            }));

            // Swipe to change gravity direction.
            View.AddGestureRecognizer(new UISwipeGestureRecognizer((gesture) => {
                gravity.GravityDirection = new CGVector(1, 0);
            }) { Direction = UISwipeGestureRecognizerDirection.Right, });
            View.AddGestureRecognizer(new UISwipeGestureRecognizer((gesture) => {
                gravity.GravityDirection = new CGVector(-1, 0);
            }) { Direction = UISwipeGestureRecognizerDirection.Left, });
            View.AddGestureRecognizer(new UISwipeGestureRecognizer((gesture) => {
                gravity.GravityDirection = new CGVector(0, -1);
            }) { Direction = UISwipeGestureRecognizerDirection.Up, });
            View.AddGestureRecognizer(new UISwipeGestureRecognizer((gesture) => {
                gravity.GravityDirection = new CGVector(0, 1);
            }) { Direction = UISwipeGestureRecognizerDirection.Down, });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            animator = new UIDynamicAnimator(View);

            item = new UIView(new RectangleF(new PointF(50f, 0f), new SizeF(50f, 50f))) {
                BackgroundColor = UIColor.Blue,
            };
            View.Add(item);
            UIGravityBehavior gravity = new UIGravityBehavior(item);
            animator.AddBehavior(gravity);

            // Tap to bring item back.
            View.AddGestureRecognizer(new UITapGestureRecognizer((gesture) => {
                PointF tapLocation = gesture.LocationInView(View);
                // Must remove from gravity first or it will only flash to location
                // then continue animated from where it was.
                gravity.RemoveItem(item);
                item.Center = tapLocation;
                gravity.AddItem(item);
            }));
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var screenBounds = UIScreen.MainScreen.Bounds;
			var length = Math.Floor (0.1 * Math.Max (screenBounds.Width, screenBounds.Height));

			itemView = new UIView (new CGRect (0.0, 0.0, length, Math.Floor (length / ItemAspectRatio))) {
				AutoresizingMask = UIViewAutoresizing.None,
				BackgroundColor = UIColor.Red
			};

			var panGestureRecognizer = new UIPanGestureRecognizer (Pan);
			itemView.AddGestureRecognizer (panGestureRecognizer);
			View.AddSubview (itemView);

			var longPressGestureRecognizer = new UILongPressGestureRecognizer (LongPress);
			View.AddGestureRecognizer (longPressGestureRecognizer);

			animator = new UIDynamicAnimator (View);
			stickyBehavior = new StickyCornersBehavior (itemView, (float)length * 0.5f);
			animator.AddBehavior (stickyBehavior);
		}
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     Animator = new UIDynamicAnimator(View);
     Animator.AddBehavior(new UIGravityBehavior(square));
 }
Esempio n. 28
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 ViewDidLoad ()
		{
			base.ViewDidLoad ();
			Animator = new UIDynamicAnimator (View);
			Animator.AddBehavior (new UIGravityBehavior (square));
		}
Esempio n. 30
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;
        }
Esempio n. 31
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;
        }