Exemplo n.º 1
0
        public void EllipseFromRect()
        {
            var rect   = new CGRect(0, 0, 15, 15);
            var matrix = CGAffineTransform.MakeIdentity();

            using (CGPath p = CGPath.EllipseFromRect(rect, matrix)) {
                Assert.IsNotNull(p, "non-null");
            }
        }
Exemplo n.º 2
0
        partial void OnDetachedFromViewPartial(UIView view)
        {
            view.Transform = CGAffineTransform.MakeIdentity();

            if (view is FrameworkElement fe)
            {
                fe.SizeChanged -= Fe_SizeChanged;
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            UIView.AnimateNotify(0.4f, 0.0f, 0.9f, 0.1f, UIViewAnimationOptions.CurveEaseInOut, () =>
            {
                ButtonStackView.Transform = CGAffineTransform.MakeIdentity();
            }, (finished) => { });
        }
Exemplo n.º 4
0
        void ShowRightMenuViewController()
        {
            if (_rightMenuViewController == null)
            {
                return;
            }
            if (_leftMenuViewController != null)
            {
                _leftMenuViewController.View.Hidden = true;
            }
            _rightMenuViewController.View.Hidden = false;
            View.Window.EndEditing(true);
            AddContentButton();
            UpdateContentViewShadow();

            UIApplication.SharedApplication.BeginIgnoringInteractionEvents();

            UIView.Animate(_animationDuration, () => {
                if (_scaleContentView)
                {
                    _contentViewContainer.Transform =
                        CGAffineTransform.MakeScale(_contentViewScaleValue, _contentViewScaleValue);
                }
                else
                {
                    _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                }

                bool landscape = UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft ||
                                 UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight;

                _contentViewContainer.Center
                    = new PointF(landscape ? -_contentViewInLandscapeOffsetCenterX : -_contentViewInPortraitOffsetCenterX,
                                 _contentViewContainer.Center.Y);

                _menuViewContainer.Alpha     = 1.0f;
                _menuViewContainer.Transform = CGAffineTransform.MakeIdentity();
                if (_scaleBackgroundImageView)
                {
                    _backgroundImageView.Transform = CGAffineTransform.MakeIdentity();
                }
            }, () => {
                //                if (!_rightMenuVisible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:didShowMenuViewController:)]) {
                //                    [self.delegate sideMenu:self didShowMenuViewController:self.rightMenuViewController];
                //                }

                Visible = !(_contentViewContainer.Frame.Size.Width == View.Bounds.Size.Width &&
                            _contentViewContainer.Frame.Size.Height == View.Bounds.Size.Height &&
                            _contentViewContainer.Frame.Location.X == 0 &&
                            _contentViewContainer.Frame.Location.Y == 0);
                _rightMenuVisible = Visible;
                UIApplication.SharedApplication.EndIgnoringInteractionEvents();
                AddContentViewControllerMotionEffects();
            });

            StatusBarNeedsAppearanceUpdate();
        }
Exemplo n.º 5
0
        internal override CGAffineTransform ToNativeTransform(CGSize size, bool withCenter = true)
        {
            var skew = CGAffineTransform.MakeIdentity();

            skew.yx = (float)Math.Tan(ToRadians(AngleY));
            skew.xy = (float)Math.Tan(ToRadians(AngleX));

            return(skew);
        }
Exemplo n.º 6
0
 private void StartDragging()
 {
     UIView.Animate(duration: 0.3, animation: () =>
     {
         Layer.Opacity = 0.8f;
         Transform     = CGAffineTransform.MakeIdentity();
         Transform.Scale((nfloat)3, (nfloat)3);
     }, completion: null);
 }
Exemplo n.º 7
0
        void Reset()
        {
            Layer.Transform = CATransform3D.Identity;

            foreach (var view in levels.SelectMany(x => x.Value).ToList())
            {
                view.Transform = CGAffineTransform.MakeIdentity();
            }
        }
Exemplo n.º 8
0
        private void ResetContentViewScale()
        {
            var    t     = _contentViewContainer.Transform;
            var    scale = Math.Sqrt(t.xx * t.xx + t.xy * t.xy);
            CGRect Frame = _contentViewContainer.Frame;

            _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
            _contentViewContainer.Transform = CGAffineTransform.MakeScale((nfloat)scale, (nfloat)scale);
            _contentViewContainer.Frame     = Frame;
        }
Exemplo n.º 9
0
 internal override CGAffineTransform ToNativeTransform(CGSize size, bool withCenter = true)
 {
     return(Children
            .Safe()
            .Select(transform => transform.ToNativeTransform(size, withCenter))
            .Aggregate(
                CGAffineTransform.MakeIdentity(),
                (transform, final) => final * transform                  // * is used to concatenate transformations
                ));
 }
Exemplo n.º 10
0
 public override void ViewDidAppear(bool animated)
 {
     base.ViewDidAppear(animated);
     UIView.Animate(0.3, 0, UIViewAnimationOptions.CurveEaseOut, () =>
     {
         this.View.BackgroundColor = OverlayColor;
         ContainerView.Transform   = CGAffineTransform.MakeIdentity();
         _actualContainerSize      = SheetSize.Fixed((float)ContainerView.Frame.Height);
     }, null);
 }
 private void FadeAnimation(UIView view, double duration = 1.0)
 {
     view.Alpha     = 0.0f;
     view.Transform = CGAffineTransform.MakeIdentity();
     UIView.Animate(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () =>
     {
         view.Alpha = 1.0f;
     },
                    null
                    );
 }
Exemplo n.º 12
0
        public void animateToShowItems(float duration)
        {
            UIView.Animate(duration: duration,
                           animation: () =>
            {
                for (int i = 1; i < itemsVector.Count; i++)
                {
                    var image = itemsVector [i];
                    //tmp represents the center of the first item in stack (the center is fixed)
                    var tmp = new CGPoint(95.5f, 128);

                    image.Transform = CGAffineTransform.MakeIdentity();

                    tmp.X       += ((Constants.ItemFrameWidth + Constants.ItemSeparation) * (i));
                    image.Center = tmp;

                    if (i == itemsVector.Count - 1)
                    {
                        var fullItemWidth        = (Constants.ItemFrameWidth + Constants.ItemSeparation);
                        var PrevCenterOfLastItem = fullItemWidth / 2.0f;
                        var LastCenterOfLastItem = (NumberOfItems * fullItemWidth) - (fullItemWidth / 2.0f);

                        if (isStack)
                        {
                            StackViewsDidFinish(this, StackNumber, PrevCenterOfLastItem - LastCenterOfLastItem, true);
                        }
                        else
                        {
                            StackViewsDidFinish(this, StackNumber, PrevCenterOfLastItem - LastCenterOfLastItem, false);
                        }
                    }
                }

                foreach (var image in itemsVector)
                {
                    image.UserInteractionEnabled = true;
                }
            },
                           completion: () =>
            {
                //showInfo
                foreach (var item in itemsVector)
                {
                    item.showInfo();
                }
            });

            var newFrame = Frame;

            newFrame.Width = (Constants.ItemFrameWidth + Constants.ItemSeparation) * NumberOfItems;
            Frame          = newFrame;

            isStack = false;
        }
Exemplo n.º 13
0
        public static void FadeAnimation(UIView view, bool isIn, double duration = 0.3, Action onFinished = null)
        {
            var minAlpha = (nfloat)0.0f;
            var maxAlpha = (nfloat)1.0f;

            view.Alpha     = isIn ? minAlpha : maxAlpha;
            view.Transform = CGAffineTransform.MakeIdentity();
            UIView.Animate(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
                view.Alpha = isIn ? maxAlpha : minAlpha;
            }, onFinished);
        }
Exemplo n.º 14
0
        void HideMenuViewControllerAnimated(bool animated)
        {
            bool rightMenuVisible = _rightMenuVisible;

            //            if ([self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willHideMenuViewController:)]) {
            //                [self.delegate sideMenu:self willHideMenuViewController:rightMenuVisible ? self.rightMenuViewController : self.leftMenuViewController];
            //            }

            Visible           = false;
            _leftMenuVisible  = false;
            _rightMenuVisible = false;
            _contentButton.RemoveFromSuperview();

            NSAction animationBlock = () => {
                _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                _contentViewContainer.Frame     = View.Bounds;
                if (_scaleMenuView)
                {
                    _menuViewContainer.Transform = _menuViewControllerTransformation;
                }
                _menuViewContainer.Alpha = 0;
                if (_scaleBackgroundImageView)
                {
                    _backgroundImageView.Transform = CGAffineTransform.MakeScale(1.7f, 1.7f);
                }
                if (_parallaxEnabled)
                {
                    if (_ios7)
                    {
                        foreach (UIMotionEffect effect in _contentViewContainer.MotionEffects)
                        {
                            _contentViewContainer.RemoveMotionEffect(effect);
                        }
                    }
                }
            };
            NSAction completionBlock = () => {
                //                if (!Visible && [strongSelf.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [strongSelf.delegate respondsToSelector:@selector(sideMenu:didHideMenuViewController:)]) {
                //                    [strongSelf.delegate sideMenu:strongSelf didHideMenuViewController:rightMenuVisible ? strongSelf.rightMenuViewController : strongSelf.leftMenuViewController];
                //                }
            };

            if (animated)
            {
                //UIApplication.SharedApplication.BeginIgnoringInteractionEvents ();
                UIView.Animate(_animationDuration, animationBlock, completionBlock);
            }
            else
            {
                //animationBlock();
                //completionBlock();
            }
            StatusBarNeedsAppearanceUpdate();
        }
Exemplo n.º 15
0
 private void SlideInSlideNavigationView()
 {
     UIView.Animate(kLWSlideAnimationDuration, 0, UIViewAnimationOptions.CurveEaseInOut | UIViewAnimationOptions.BeginFromCurrentState,
                    delegate {
         slideNavigationController.View.Transform = CGAffineTransform.MakeIdentity();
     }, delegate {
         slideNavigationController.TopViewController.View.UserInteractionEnabled = true;
         slideInTapGestureRecognizer.Enabled = false;
         slideState = LWSlideViewControllerState.Normal;
     });
 }
Exemplo n.º 16
0
 private void EndDragging()
 {
     Transform = CGAffineTransform.MakeIdentity();
     Transform.Scale((nfloat)3, (nfloat)3);
     UIView.Animate(duration: 0.3, animation: () =>
     {
         Layer.Opacity = 0.8f;
         Transform.Scale((nfloat)1, (nfloat)1);
     }, completion: null);
     DragFinished.Invoke(this, null);
 }
 /// <summary>
 /// Fades the view over time.
 /// </summary>
 /// <param name="view">View.</param>
 /// <param name="transition">Transition.</param>
 /// <param name="duration">Duration.</param>
 /// <param name="onFinished">On finished.</param>
 public static void Fade(this UIView view, AnimationTransition transition, double duration = AnimationConstants.DefaultDuration, Action onFinished = null)
 {
     view.Alpha     = transition == AnimationTransition.In ? (nfloat)AnimationConstants.MinAlpha : (nfloat)AnimationConstants.MaxAlpha;
     view.Transform = CGAffineTransform.MakeIdentity();
     UIView.Animate(duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                    () =>
     {
         view.Alpha = transition == AnimationTransition.In ? (nfloat)AnimationConstants.MaxAlpha : (nfloat)AnimationConstants.MinAlpha;
     },
                    onFinished
                    );
 }
Exemplo n.º 18
0
        /// <summary>
        /// Rotates the image.
        /// </summary>
        /// <param name="image">Image.</param>
        private void RotateImage(ref UIImage image)
        {
            CGImage           imgRef    = image.CGImage;
            CGAffineTransform transform = CGAffineTransform.MakeIdentity();

            var imgHeight = imgRef.Height * _imgScale;
            var imgWidth  = imgRef.Width * _imgScale;

            CGRect             bounds    = new CGRect(0, 0, imgWidth, imgHeight);
            CGSize             imageSize = new CGSize(imgWidth, imgHeight);
            UIImageOrientation orient    = image.Orientation;

            switch (orient)
            {
            case UIImageOrientation.Up:
                transform = CGAffineTransform.MakeIdentity();
                break;

            case UIImageOrientation.Down:
                transform = CGAffineTransform.MakeTranslation(imageSize.Width, imageSize.Height);
                transform = CGAffineTransform.Rotate(transform, (float)Math.PI);
                break;

            case UIImageOrientation.Right:
                bounds.Size = new CGSize(bounds.Size.Height, bounds.Size.Width);
                transform   = CGAffineTransform.MakeTranslation(imageSize.Height, 0);
                transform   = CGAffineTransform.Rotate(transform, (float)Math.PI / 2.0f);
                break;

            default:
                throw new Exception("Invalid image orientation");
            }

            UIGraphics.BeginImageContext(bounds.Size);
            CGContext context = UIGraphics.GetCurrentContext();

            if (orient == UIImageOrientation.Right)
            {
                context.ScaleCTM(-1, 1);
                context.TranslateCTM(-imgHeight, 0);
            }
            else
            {
                context.ScaleCTM(1, -1);
                context.TranslateCTM(0, -imgHeight);
            }

            context.ConcatCTM(transform);

            context.DrawImage(new CGRect(0, 0, imgWidth, imgHeight), imgRef);
            image = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
        }
Exemplo n.º 19
0
        void ShowLeftMenuViewController()
        {
            if (_leftMenuViewController == null)
            {
                return;
            }
            if (_rightMenuViewController != null)
            {
                _rightMenuViewController.View.Hidden = true;
            }
            View.Window.EndEditing(true);
            AddContentButton();
            UpdateContentViewShadow();

            UIView.Animate(_animationDuration, () => {
                if (_scaleContentView)
                {
                    _contentViewContainer.Transform = CGAffineTransform.MakeScale(_contentViewScaleValue, _contentViewScaleValue);
                }
                else
                {
                    _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                }
                var landscape = UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeLeft ||
                                UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeRight;

                float pointAddX = View.Frame.Width;
                if (landscape)
                {
                    pointAddX = View.Frame.Height;
                }

                _contentViewContainer.Center = new PointF(_contentViewInLandscapeOffsetCenterX + pointAddX, _contentViewContainer.Center.Y);

                _menuViewContainer.Alpha     = 1.0f;
                _menuViewContainer.Transform = CGAffineTransform.MakeIdentity();
                if (_scaleBackgroundImageView)
                {
                    _backgroundImageView.Transform = CGAffineTransform.MakeIdentity();
                }
            }, () => {
                AddContentViewControllerMotionEffects();

                //                if (!Visible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:didShowMenuViewController:)]) {
                //                    [self.delegate sideMenu:self didShowMenuViewController:self.leftMenuViewController];
                //                }

                Visible          = true;
                _leftMenuVisible = true;
            });

            StatusBarNeedsAppearanceUpdate();
        }
Exemplo n.º 20
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var containerView      = transitionContext.ContainerView;
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            toViewController.View.Frame = fromViewController.View.Frame;

            if (IsPresenting)
            {
                var presentedControllerView = toViewController.View;
                var originalCenter          = presentedControllerView.Center;
                var originalSize            = presentedControllerView.Frame.Size;

                presentedControllerView.Center    = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                presentedControllerView.Transform = CGAffineTransform.MakeScale(0.001f, 0.001f);
                containerView.AddSubview(presentedControllerView);

                UIView.Animate(Duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                               () =>
                {
                    presentedControllerView.Transform = CGAffineTransform.MakeIdentity();
                    presentedControllerView.Center    = originalCenter;
                }, () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
            else
            {
                var returningControllerView = fromViewController.View;
                var originalSize            = returningControllerView.Frame.Size;

                containerView.AddSubview(toViewController.View);

                UIView.Animate(Duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                               () =>
                {
                    returningControllerView.Transform = CGAffineTransform.MakeScale(0.001f, 0.001f);
                    returningControllerView.Center    = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                    returningControllerView.Alpha     = .5f;
                    containerView.InsertSubview(returningControllerView, 1);
                }, () =>
                {
                    returningControllerView.Center = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                    returningControllerView.RemoveFromSuperview();

                    transitionContext.CompleteTransition(true);
                }
                               );
            }
        }
Exemplo n.º 21
0
        void UpdateTransform()
        {
            var transform = CGAffineTransform.MakeIdentity();

            transform.Rotate(rotation);

            transform.Scale(scale, scale);

            transform.Translate(translate.X, translate.Y);

            imgLogo.Transform = transform;
        }
Exemplo n.º 22
0
        void ResetImage(UIMenuController controller)
        {
            var mid = new CGPoint((imageForReset.Bounds.Left + imageForReset.Bounds.Right) / 2, (imageForReset.Bounds.Top + imageForReset.Bounds.Bottom) / 2);
            var locationInSuperview = imageForReset.ConvertPointToView(mid, imageForReset.Superview);

            imageForReset.Layer.AnchorPoint = new CGPoint(0.5f, 0.5f);
            imageForReset.Center            = locationInSuperview;

            UIView.BeginAnimations(null, IntPtr.Zero);
            imageForReset.Transform = CGAffineTransform.MakeIdentity();
            UIView.CommitAnimations();
        }
Exemplo n.º 23
0
 public void Reset()
 {
     dog.Transform           = CGAffineTransform.MakeIdentity();
     dog.Frame               = new RectangleF(100, 100, 200, 230);
     dog.Alpha               = 1.0f;
     dog.Center              = new PointF(dog.Frame.GetMidX(), dog.Frame.GetMidY());
     dog.Layer.ShadowOffset  = new SizeF(0, 20);
     dog.Layer.ShadowRadius  = 10;
     dog.Layer.ShadowColor   = new CGColor(0, 0, 0);
     dog.Layer.ShadowOpacity = 1.0f;
     View.BackgroundColor    = UIColor.DarkGray;
 }
        void UpdateTransform()
        {
            // Create a CGAffineTransform which we'll apply to our target image
            var transform = CGAffineTransform.MakeIdentity();

            // Call the translate method of the transform passing in our translation
            transform.Translate(translate.X, translate.Y);

            // Set the Transform property on our image to our new CGAffineTransform
            // This won't have any effect yet
            imgLogo.Transform = transform;
        }
Exemplo n.º 25
0
        public void MoveToPoint()
        {
            var matrix = CGAffineTransform.MakeIdentity();

            using (CGPath p1 = new CGPath())
                using (CGPath p2 = new CGPath()) {
                    Assert.IsTrue(p1.IsEmpty, "IsEmpty-1");
                    p1.MoveToPoint(0, 0);
                    p2.MoveToPoint(matrix, 0, 0);
                    Assert.IsFalse(p1.IsEmpty, "IsEmpty-2");
                    Assert.That(p1, Is.EqualTo(p2), "CGPathEqualToPath");
                }
        }
Exemplo n.º 26
0
        public void AddArc()
        {
            var matrix = CGAffineTransform.MakeIdentity();

            using (CGPath p1 = new CGPath())
                using (CGPath p2 = new CGPath()) {
                    Assert.IsTrue(p1.IsEmpty, "IsEmpty-1");
                    p1.AddArc(0, 0, 10, 0, 90, true);
                    p2.AddArc(matrix, 0, 0, 10, 0, 90, true);
                    Assert.IsFalse(p1.IsEmpty, "IsEmpty-2");
                    Assert.That(p1, Is.EqualTo(p2), "CGPathEqualToPath");
                }
        }
Exemplo n.º 27
0
        public void AddLines()
        {
            var matrix = CGAffineTransform.MakeIdentity();

            using (CGPath p1 = new CGPath())
                using (CGPath p2 = new CGPath()) {
                    Assert.IsTrue(p1.IsEmpty, "IsEmpty-1");
                    p1.AddLines(new [] { PointF.Empty });
                    p2.AddLines(matrix, new [] { PointF.Empty });
                    Assert.IsFalse(p1.IsEmpty, "IsEmpty-2");
                    Assert.That(p1, Is.EqualTo(p2), "CGPathEqualToPath");
                }
        }
Exemplo n.º 28
0
        partial void OnDetachedFromViewPartial(_View view)
        {
#if __IOS__
            view.Transform = CGAffineTransform.MakeIdentity();
#elif __MACOS__
            view.Layer.Transform = CATransform3D.Identity;
#endif

            if (view is FrameworkElement fe)
            {
                fe.SizeChanged -= Fe_SizeChanged;
            }
        }
        void UpdateImage(UIImage image, NSData imageData)
        {
            var imageToUse = (image != null) ? image : UIImage.LoadFromData(imageData);

            ImageView.Transform = CGAffineTransform.MakeIdentity();
            ImageView.Image     = imageToUse;

            ImageView.Frame = new CGRect(0, 0, imageToUse.Size.Width, imageToUse.Size.Height);
            ContentSize     = imageToUse.Size;

            UpdateZoomScale();
            CenterScrollViewContents();
        }
Exemplo n.º 30
0
        public void MakeIdentity()
        {
            var transform = CGAffineTransform.MakeIdentity();

            Assert.AreEqual((nfloat)1, transform.xx, "xx");
            Assert.AreEqual((nfloat)0, transform.yx, "yx");
            Assert.AreEqual((nfloat)0, transform.xy, "xy");
            Assert.AreEqual((nfloat)1, transform.yy, "yy");
            Assert.AreEqual((nfloat)0, transform.x0, "x0");
            Assert.AreEqual((nfloat)0, transform.y0, "y0");

            Assert.IsTrue(transform.IsIdentity, "identity");
        }