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 ();
			
			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 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 ();

			var gravityBehavior = new UIGravityBehavior (square);

			var collisionBehavior = new UICollisionBehavior (square) {
				TranslatesReferenceBoundsIntoBoundary = true
			};
			collisionBehavior.BeganBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
			};
			collisionBehavior.EndedBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
			};

			var squareCenterPoint = new CGPoint (square.Center.X, square.Center.Y - 100);

			var attachmentBehavior = new UIAttachmentBehavior (square, squareCenterPoint) {
				Frequency = 1.0f,
				Damping = 0.1f
			};

			redSquare.Center = attachmentBehavior.AnchorPoint;
			blueSquare.Center = new CGPoint (50.0f, 50.0f);

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

			View.AddGestureRecognizer (new UIPanGestureRecognizer ((gesture) => {
				attachmentBehavior.AnchorPoint = gesture.LocationInView (View);
				redSquare.Center = attachmentBehavior.AnchorPoint;
			}));
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			/*
     			We want to show collisions between views and boundaries with different 
     			elasticities, we thus associate the two views to gravity and collision 
     			behaviors. We will only change the restitution parameter for one of 
     			these views.
     		*/
			var gravityBehavior = new UIGravityBehavior (square1, square2);

			var collisionBehavior = new UICollisionBehavior (square1, square2) {
				TranslatesReferenceBoundsIntoBoundary = true
			};
			collisionBehavior.BeganBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
			};
			collisionBehavior.EndedBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
			};

			var propertiesBehavior = new UIDynamicItemBehavior (square2) {
				Elasticity = 0.5f
			};
	
			Animator = new UIDynamicAnimator (View);
			Animator.AddBehaviors (gravityBehavior, collisionBehavior, propertiesBehavior);
		}
        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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var Gravedad = new UIGravityBehavior(Imagen1);//Se agrega gravedad a uno de los objectos.
            var Colision = new UICollisionBehavior(Imagen2)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            var PuntoCentral = new CGPoint(Imagen1.Center.X,
                                           Imagen1.Center.Y -
                                           100);

            var Anclaje = new UIAttachmentBehavior(Imagen1, PuntoCentral) //Se conecta la imagen al punto centra
            {
                Frequency = 1.0f,
                Damping   = 0.1f //forma en la que esta haciendo el rebote.
            };

            Imagen2.Center = Anclaje.AnchorPoint;
            Imagen2.Center = new CGPoint(50.0f, 50.0f);
            Animador       = new UIDynamicAnimator(View);
            Animador.AddBehaviors(Anclaje, Gravedad, Colision);
            View.AddGestureRecognizer(new UIPanGestureRecognizer((gesto) =>
            {
                Anclaje.AnchorPoint = gesto.LocationInView(View);
                Imagen2.Center      = Anclaje.AnchorPoint;
            }));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            /*
             * We want to show collisions between views and boundaries with different
             * elasticities, we thus associate the two views to gravity and collision
             * behaviors. We will only change the restitution parameter for one of
             * these views.
             */
            var gravityBehavior = new UIGravityBehavior(square1, square2);

            var collisionBehavior = new UICollisionBehavior(square1, square2)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            collisionBehavior.BeganBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
            };
            collisionBehavior.EndedBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
            };

            var propertiesBehavior = new UIDynamicItemBehavior(square2)
            {
                Elasticity = 0.5f
            };

            Animator = new UIDynamicAnimator(View);
            Animator.AddBehaviors(gravityBehavior, collisionBehavior, propertiesBehavior);
        }
		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;
			}));
		}
        public StickyCornersBehavior(IUIDynamicItem stickyCornerItem, float stickyCornerInset)
        {
            item        = stickyCornerItem;
            cornerInset = stickyCornerInset;

            fieldBehaviors = new List <UIFieldBehavior> ();

            collisionBehavior = new UICollisionBehavior(item)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            itemBehavior = new UIDynamicItemBehavior(item)
            {
                Density        = 0.01f,
                Resistance     = 10f,
                Friction       = 0f,
                AllowsRotation = false
            };

            AddChildBehavior(collisionBehavior);
            AddChildBehavior(itemBehavior);

            for (int i = 0; i <= 3; i++)
            {
                var fieldBehavior = UIFieldBehavior.CreateSpringField();
                fieldBehavior.AddItem(item);
                fieldBehaviors.Add(fieldBehavior);
                AddChildBehavior(fieldBehavior);
            }
        }
        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. 14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //agrega el UIVIew para aplicar el comportamiento de la animacion
            var gravityBehavior = new UIGravityBehavior(square);

            var gravityBehavior2 = new UIGravityBehavior(Balon);

            //limite sobre la collision
            var collisionBehavior = new UICollisionBehavior(square)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };


            var collisionBehavior2 = new UICollisionBehavior(Balon)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };


            //cuando tenga contacto sos los metodo de comenzar y finalizar
            collisionBehavior.BeganBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
            };
            collisionBehavior.EndedBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
            };

            // Another style of creating the UIDynamicAnimator
            Animator = new UIDynamicAnimator(View)
            {
                gravityBehavior, collisionBehavior
            };

            Animator = new UIDynamicAnimator(View)
            {
                gravityBehavior2, collisionBehavior2
            };

            UIDynamicItemBehavior ball = new UIDynamicItemBehavior(Balon);

            ball.Elasticity = 0.75f;
            Animator.Add(ball);
        }
        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;
            }));
        }
Esempio n. 16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var Gravedad = new UIGravityBehavior(Imagen1, Imagen2);//Se agrega gravedad a uno de los objectos.
            var Colision = new UICollisionBehavior(Imagen1, Imagen2)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            var Rebote = new UIDynamicItemBehavior(Imagen2)
            {
                Elasticity = 1f
            };

            Animador = new UIDynamicAnimator(View);
            Animador.AddBehaviors(Gravedad, Colision, Rebote);
        }
		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;
			}));
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
		
			var gravityBehavior = new UIGravityBehavior (square);

			var collisionBehavior = new UICollisionBehavior (square) {
				TranslatesReferenceBoundsIntoBoundary = true
			};
			collisionBehavior.BeganBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
			};
			collisionBehavior.EndedBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
			};

			// Another style of creating the UIDynamicAnimator
			Animator = new UIDynamicAnimator (View) { gravityBehavior, collisionBehavior };
		}
Esempio n. 19
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. 20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var gravityBehavior = new UIGravityBehavior(square);

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

            collisionBehavior.BeganBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
            };
            collisionBehavior.EndedBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
            };

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

            var attachmentBehavior = new UIAttachmentBehavior(square, squareCenterPoint)
            {
                Frequency = 1.0f,
                Damping   = 0.1f
            };

            redSquare.Center  = attachmentBehavior.AnchorPoint;
            blueSquare.Center = new PointF(50.0f, 50.0f);

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

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

            var gravityBehavior = new UIGravityBehavior(square);

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

            collisionBehavior.BeganBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
            };
            collisionBehavior.EndedBoundaryContact += (sender, e) => {
                ((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
            };

            // Another style of creating the UIDynamicAnimator
            Animator = new UIDynamicAnimator(View)
            {
                gravityBehavior, collisionBehavior
            };
        }
        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);
        }
Esempio n. 23
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            var verifica = new LAContext();
            var autoriza = await verifica.EvaluatePolicyAsync
                               (LAPolicy.DeviceOwnerAuthenticationWithBiometrics,
                               "Autenticación FaceID");

            if (autoriza.Item1)
            {
                var voz = new AVSpeechUtterance("Está usted autorizado en la Aplicación, sea Bienvenido");
                voz.Voice = AVSpeechSynthesisVoice.FromLanguage("es-MX");
                habla.SpeakUtterance(voz);
                lblEstatus.Text = "Autorizado";
            }
            else
            {
                lblEstatus.Text = "No Autorizado";

                var Gravedad = new UIGravityBehavior(Imagen, btnConfirmar, btnGuardar, lblEstatus);
                var Colision = new UICollisionBehavior(Imagen, btnConfirmar, btnGuardar, lblEstatus)
                {
                    TranslatesReferenceBoundsIntoBoundary = false
                };
                var Rebote = new UIDynamicItemBehavior(btnConfirmar)
                {
                    Elasticity = 1f
                };
                Animador = new UIDynamicAnimator(View);
                Animador.AddBehaviors(Gravedad, Colision, Rebote);
                System.Threading.Thread.CurrentThread.Abort();
            }
            var Firma = new SignaturePadView(View.Frame)
            {
                StrokeWidth     = 3f,
                StrokeColor     = UIColor.Black,
                BackgroundColor = UIColor.White,
            };

            Firma.Frame                     = new CGRect(10, 500, 350, 200);
            Firma.Layer.BorderWidth         = 1f;
            Firma.SignaturePrompt.TextColor = UIColor.Blue;
            Firma.Caption.TextColor         = UIColor.White;
            Firma.Caption.Text              = "Firmar en esta zona";
            View.AddSubview(Firma);

            btnConfirmar.TouchUpInside += delegate
            {
                Imagen.Image = Firma.GetImage();
            };
            btnGuardar.TouchUpInside += delegate
            {
                var imagenfirma = Firma.GetImage();
                try
                {
                    imagenfirma.SaveToPhotosAlbum(delegate
                                                  (UIImage imagen, NSError error)
                                                  { });
                    lblEstatus.Text = "Guardado en biblioteca";
                }
                catch (Exception ex)
                {
                    lblEstatus.Text = ex.Message;
                }
            };
        }