Exemplo n.º 1
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)
            {
                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 ();

			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 void SetTransitionProgress (float transitionProgress)
		{
			base.TransitionProgress = transitionProgress;
			float offsetH = GetValueForAnimatedKey ("offsetH");
			float offsetV = GetValueForAnimatedKey ("offsetV");
			Offset = new UIOffset (offsetH, offsetV);
		}
Exemplo n.º 5
0
        public void SetTransitionProgress(float transitionProgress)
        {
            base.TransitionProgress = transitionProgress;
            float offsetH = (float)GetValueForAnimatedKey("offsetH");
            float offsetV = (float)GetValueForAnimatedKey("offsetV");

            Offset = new UIOffset(offsetH, offsetV);
        }
 public static void Center(this UIView view, UIView inView, UIOffset offset)
 {
     view.TranslatesAutoresizingMaskIntoConstraints = false;
     NSLayoutConstraint.ActivateConstraints(new [] {
         view.CenterXAnchor.ConstraintEqualTo(inView.CenterXAnchor, offset.Horizontal),
         view.CenterYAnchor.ConstraintEqualTo(inView.CenterYAnchor, offset.Vertical)
     });
 }
Exemplo n.º 7
0
 /// <summary>
 /// Center in superview by constraining centerX and centerY to superview, respectively.
 /// </summary>
 public static T AnchorCenter <T>(this T view, UIOffset offset = default, CGSize size = default, LayoutConstraints constraints = default) where T : UIView
 {
     return(view.ActivateConstaints()
            .ConstraintCentreXEqualTo(view.Superview.CenterXAnchor, offset.Horizontal, constraints)
            .ConstraintCentreYEqualTo(view.Superview.CenterYAnchor, offset.Vertical, constraints)
            .ConstraintWidthEqualTo(size.Width, constraints)
            .ConstraintHeightEqualTo(size.Height, constraints));
 }
		void Update (float progress, UIOffset offset)
		{
			if (context != null && // we must have a valid context for updates
				((progress != transitionLayout.TransitionProgress) || (offset != transitionLayout.Offset))) {
				transitionLayout.SetOffset (offset);
				transitionLayout.SetTransitionProgress (progress);
				transitionLayout.InvalidateLayout ();
				context.UpdateInteractiveTransition (progress);
			}
		}
Exemplo n.º 9
0
 void Update(float progress, UIOffset offset)
 {
     if (context != null &&             // we must have a valid context for updates
         ((progress != transitionLayout.TransitionProgress) || (offset != transitionLayout.Offset)))
     {
         transitionLayout.SetOffset(offset);
         transitionLayout.SetTransitionProgress(progress);
         transitionLayout.InvalidateLayout();
         context.UpdateInteractiveTransition(progress);
     }
 }
		void Update (float progress, UIOffset offset)
		{
			if (context == null)
				return;

			if ((progress != transitionLayout.TransitionProgress) || (offset != transitionLayout.Offset)) {
				transitionLayout.SetOffset (offset);
				transitionLayout.SetTransitionProgress (progress);
				transitionLayout.InvalidateLayout ();
				context.UpdateInteractiveTransition (progress);
			}
		}
        void Update(float progress, UIOffset offset)
        {
            if (context == null)
            {
                return;
            }

            if ((progress != transitionLayout.TransitionProgress) || (offset != transitionLayout.Offset))
            {
                transitionLayout.SetOffset(offset);
                transitionLayout.SetTransitionProgress(progress);
                transitionLayout.InvalidateLayout();
                context.UpdateInteractiveTransition(progress);
            }
        }
Exemplo n.º 12
0
 public static CGSize AsSize(this UIOffset offset)
 {
     return(new CGSize(offset.Horizontal, offset.Vertical));
 }
        private void dismissingPanGestureRecognizerPanned(UIPanGestureRecognizer panner)
        {
            if (Flags.ScrollViewIsAnimatingAZoom || Flags.IsAnimatingAPresentationOrDismissal) 
                return;

            PointF translation = panner.TranslationInView (panner.View);
            PointF locationInView = panner.LocationInView (panner.View);
            PointF velocity = panner.VelocityInView (panner.View);
            float vectorDistance = (float)Math.Sqrt (Math.Pow (velocity.X, 2) + Math.Pow (velocity.Y, 2));

            if (panner.State == UIGestureRecognizerState.Began) {
                Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
                if (Flags.IsDraggingImage)
                    StartImageDragging (locationInView, new UIOffset ());
            } else if (panner.State == UIGestureRecognizerState.Changed) {
                if (Flags.IsDraggingImage) {
                    PointF newAnchor = ImageDragStartingPoint;
                    newAnchor.X += translation.X + ImageDragOffsetFromActualTranslation.Horizontal;
                    newAnchor.Y += translation.Y + ImageDragOffsetFromActualTranslation.Vertical;
                    AttachmentBehavior.AnchorPoint = newAnchor;
                } else {
                    Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
                    if (Flags.IsDraggingImage) {
                        UIOffset translationOffset = new UIOffset (-1 * translation.X, -1 * translation.Y);
                        StartImageDragging (locationInView, translationOffset);
                    }
                }
            } else {
                if (vectorDistance > JTSImageViewController.JTSImageViewController_MinimumFlickDismissalVelocity) {
                    if (Flags.IsDraggingImage) {
                        DismissImageWithFlick (velocity);
                    } else {
                        Dismiss (true);
                    }
                } else {
                    CancelCurrentImageDrag (true);
                }
            }
        }
 // Dynamic Image Dragging Methods
 private void StartImageDragging(PointF panGestureLocationInView, UIOffset translationOffset)
 {
     ImageDragStartingPoint = panGestureLocationInView;
     ImageDragOffsetFromActualTranslation = translationOffset;
     PointF anchor = ImageDragStartingPoint;
     PointF imageCenter = ImageView.Center;
     UIOffset offset = new UIOffset (panGestureLocationInView.X - imageCenter.X, panGestureLocationInView.Y - imageCenter.Y);
     ImageDragOffsetFromImageCenter = offset;
     AttachmentBehavior = new UIAttachmentBehavior (ImageView, offset, anchor);
     Animator.AddBehavior (AttachmentBehavior);
     UIDynamicItemBehavior modifier = new UIDynamicItemBehavior(new IUIDynamicItem[] { ImageView });
     modifier.AngularResistance = AppropriateAngularResistanceForView (ImageView);
     Animator.AddBehavior (modifier);
 }
Exemplo n.º 15
0
 public void SetOffset(UIOffset offset)
 {
     UpdateValue(offset.Horizontal, "offsetH");
     UpdateValue(offset.Vertical, "offsetV");
     Offset = offset;
 }
Exemplo n.º 16
0
 public virtual void EncodeUIOffset(UIOffset offset, [Unwrapped] string forKey)
 {
 }
Exemplo n.º 17
0
 public Depth(UIOffset offset = default(UIOffset), float opacity = 0, nfloat radius = default(nfloat))
 {
     Offset  = offset;
     Opacity = opacity;
     Radius  = radius;
 }
Exemplo n.º 18
0
		public void SetOffset (UIOffset offset)
		{
			UpdateValue (offset.Horizontal, "offsetH");
			UpdateValue (offset.Vertical, "offsetV");
			Offset = offset;
		}
Exemplo n.º 19
0
        private void SetupUserInterface()
        {
            var centerButtonX = View.Bounds.GetMidX() - 35f;
            var topLeftX      = View.Bounds.X + 25;
            var topRightX     = View.Bounds.Right - 65;
            var bottomButtonY = View.Bounds.Bottom - 150;
            var topButtonY    = View.Bounds.Top + 15;

            var buttonWidth  = 70;
            var buttonHeight = 70;

            var buttonX = View.Bounds.Width - 70;
            var buttonY = View.Bounds.Height / 3;

            search       = new UISearchBar();
            search.Frame = new CGRect(0, 0, View.Bounds.Width, 70);
            UIOffset offset = new UIOffset();

            offset.Horizontal = 0;
            offset.Vertical   = 10;

            search.SearchFieldBackgroundPositionAdjustment = offset;
            search.KeyboardType     = UIKeyboardType.NumberPad;
            search.BackgroundColor  = Color.FromHex(Constants.ColorPrimary).ToUIColor();
            search.SearchBarStyle   = UISearchBarStyle.Minimal;
            search.Placeholder      = "Truy vấn mã sản phẩm";
            search.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            search.BarTintColor     = UIColor.White;//Color.FromHex(Constants.ColorSecondary).ToUIColor();
            //search.color

            UIToolbar toolbar    = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f));
            var       doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
            {
                search.ResignFirstResponder();
                if (search.Text.Length != 0)
                {
                    System.Diagnostics.Debug.WriteLine("text: " + search.Text);
                    var newResultPage = new ResultPage(search.Text);
                    Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(newResultPage);
                }
            });

            toolbar.Items = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                doneButton
            };
            search.InputAccessoryView = toolbar;

            ScanButton = new UIButton();
            ScanButton = UIButton.FromType(UIButtonType.Custom);
            System.Diagnostics.Debug.WriteLine(centerButtonX + "|" + bottomButtonY + "|" + buttonWidth + "|" + buttonHeight);
            ScanButton.SetImage(UIImage.FromFile("ic_scan_button_1.png"), UIControlState.Normal);
            ScanButton.Frame = new CGRect(buttonX, buttonY, buttonWidth, buttonHeight);

            tabControl = new TabController();
            tabControl.View.TintColor = Color.FromHex(Constants.ColorPrimary).ToUIColor();
            var napphsi = App.AppHSI.Count;

            Device.StartTimer(TimeSpan.FromSeconds(0.3), () =>
            {
                if (App.AppHSI.Count != napphsi)
                {
                    tabControl.reloaddata();
                    napphsi = App.AppHSI.Count;
                }
                return(true); // True = Repeat again, False = Stop the timer
            });

            /*
             * var application = UIApplication.SharedApplication;
             * var statusBarView = application.ValueForKey(new NSString("statusBar")) as UIView;
             * var foregroundView = statusBarView.ValueForKey(new NSString("foregroundView")) as UIView;
             *
             * UIView dataNetworkItemView = null;
             * foreach (UIView subview in foregroundView.Subviews)
             * {
             *  System.Diagnostics.Debug.WriteLine(subview.Class.Name+"\n");
             *  if ("UIStatusBarSignalStrengthItemView" == subview.Class.Name)
             *  {
             *      dataNetworkItemView = subview;
             *      break;
             *  }
             * }
             * if (null == dataNetworkItemView)
             *  System.Diagnostics.Debug.WriteLine(" return false; //NO SERVICE");
             * int bars2 = ((NSNumber)dataNetworkItemView.ValueForUndefinedKey(new NSString("signalStrengthBars"))).Int32Value;
             * int bars = ((NSNumber)dataNetworkItemView.ValueForKey(new NSString("signalStrengthBars"))).Int32Value;
             * System.Diagnostics.Debug.WriteLine("datanetwork "+ bars + " "+bars2);*/

            tabControl.View.Frame = new CGRect(0, 70, View.Bounds.Width, View.Bounds.Height - 70);
            View.Add(tabControl.View);
            View.Add(search);
            View.AddSubview(ScanButton);
        }