예제 #1
0
        internal void StateChanged(ProgressButtonState state, string customtext, CGColor animationColor, bool reDrawOptimized = true)
        {
            if (StateUpdated != null)
            {
                StateUpdated();
            }

            if (State != state)
            {
                _colorAnimationRing.RemoveAllAnimations();
            }
            _progressButtonLayer.CurText = customtext;
            _progressButtonLayer.State   = state;
            if (state == ProgressButtonState.Cleaned)
            {
                _colorAnimationRing.AddAnimation(DrawAnimationWithColor(ProgressButtonColors.CleanedStateProgress.AsResourceCgColor()), PARAMs.Animation);
            }
            else if (animationColor != null && state != ProgressButtonState.Disabled && (state != State || !reDrawOptimized))
            {
                _colorAnimationRing.AddAnimation(DrawAnimationWithColor(animationColor), PARAMs.Animation);
            }
            if (state == ProgressButtonState.Active && _animationColor != animationColor)
            {
                _colorAnimationRing.RemoveAllAnimations();
                _colorAnimationRing.AddAnimation(DrawAnimationWithColor(animationColor), PARAMs.Animation);
            }
            _state          = state;
            _animationColor = animationColor;
        }
 private void AnimateRipple()
 {
     UIView.Animate(0.3, () =>
     {
         _rippleLayer.AddAnimation(_rippleAnimation, "rippleAnimation");
         _rippleLayer.AddAnimation(_fadeAnimation, "rippleFadeAnim");
     });
 }
예제 #3
0
 private void AnimateRipple()
 {
     Animate(0.5, () =>
     {
         _rippleLayer.AddAnimation(_rippleAnimation, "rippleAnimation");
         _rippleLayer.AddAnimation(_fadeAnimation, "rippleFadeAnim");
     }, () =>
     {
         System.Diagnostics.Debug.WriteLine("Animation Completed");
     });
 }
예제 #4
0
        void BurstTapCircle()
        {
            nfloat tapCircleFinalDiameter = CalculateTapCircleFinalDiameter();

            tapCircleFinalDiameter += TapCircleBurstAmount;

            var endingRectSizerView = new UIView(new CGRect(0, 0, tapCircleFinalDiameter, tapCircleFinalDiameter));

            endingRectSizerView.Center = RippleFromTapLocation ? TapPoint : new CGPoint(Bounds.GetMidX(), Bounds.GetMidY());

            UIBezierPath endingCirclePath = UIBezierPath.FromRoundedRect(endingRectSizerView.Frame, tapCircleFinalDiameter / 2f);

            CAShapeLayer tapCircle = (RippleAnimationQueue.Count > 0) ? RippleAnimationQueue.GetItem <CAShapeLayer>(0) : null;

            if (tapCircle != null)
            {
                if (RippleAnimationQueue.Count > 0)
                {
                    RippleAnimationQueue.RemoveObject(0);
                }
                DeathRowForCircleLayers.AddObjects(new NSObject[] { tapCircle });

                CGPath startingPath    = tapCircle.Path;
                nfloat startingOpacity = tapCircle.Opacity;

                if (tapCircle.AnimationKeys != null && tapCircle.AnimationKeys.Length > 0)
                {
                    startingPath = tapCircle.Path;
                    if (tapCircle.PresentationLayer != null)
                    {
                        startingOpacity = tapCircle.PresentationLayer.Opacity;
                    }
                }

                CABasicAnimation tapCircleGrowthAnimation = CABasicAnimation.FromKeyPath("path");
                tapCircleGrowthAnimation.Duration       = TouchUpAnimationDuration;
                tapCircleGrowthAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);
                tapCircleGrowthAnimation.SetFrom(startingPath);
                tapCircleGrowthAnimation.SetTo(endingCirclePath.CGPath);
                tapCircleGrowthAnimation.FillMode            = CAFillMode.Forwards;
                tapCircleGrowthAnimation.RemovedOnCompletion = false;

                CABasicAnimation fadeOut = CABasicAnimation.FromKeyPath("opacity");
                fadeOut.SetValueForKey(new NSString("fadeCircleOut"), new NSString("id"));
                fadeOut.SetFrom(NSNumber.FromNFloat(startingOpacity));
                fadeOut.SetTo(NSNumber.FromNFloat(0f));
                fadeOut.Duration            = TouchUpAnimationDuration;
                fadeOut.FillMode            = CAFillMode.Forwards;
                fadeOut.RemovedOnCompletion = false;

                tapCircle.AddAnimation(tapCircleGrowthAnimation, "animatePath");
                tapCircle.AddAnimation(fadeOut, "opacityAnimation");
            }
        }
        /// <summary>
        /// Show blue circle which changing radius from button to View bounds
        /// </summary>
        private void ShowConnectedStatusAtimation()
        {
            if (__MainViewModel.ConnectionState != ServiceState.Connected)
            {
                return;
            }

            NSColor startCircleColor = Colors.ConnectiongAnimationCircleColor;
            NSColor endCircleColor   = NSColor.Clear;

            __animationLayer.FillColor = NSColor.Clear.CGColor;

            var frame       = GuiConnectButtonImage.Frame;
            var startCircle =
                CGPath.EllipseFromRect(
                    new CGRect(frame.X + 10,
                               frame.Y + 10,
                               frame.Width - 20,
                               frame.Height - 20)
                    );

            nfloat radiusOffset = View.Frame.Height / 2f - frame.Height / 2f;

            var endCircle = CGPath.EllipseFromRect(new CGRect(
                                                       frame.X - radiusOffset,
                                                       frame.Y - radiusOffset,
                                                       frame.Height + radiusOffset * 2,
                                                       frame.Width + radiusOffset * 2
                                                       ));

            CABasicAnimation circleRadiusAnimation = CABasicAnimation.FromKeyPath("path");

            circleRadiusAnimation.From = FromObject(startCircle);
            circleRadiusAnimation.To   = FromObject(endCircle);

            CABasicAnimation strokeColorAnimation = CABasicAnimation.FromKeyPath("strokeColor");

            strokeColorAnimation.From = FromObject(startCircleColor.CGColor);
            strokeColorAnimation.To   = FromObject(endCircleColor.CGColor);

            CABasicAnimation lineWidthAnimation = CABasicAnimation.FromKeyPath("lineWidth");

            lineWidthAnimation.From = FromObject(7);
            lineWidthAnimation.To   = FromObject(1);

            CAAnimationGroup animationGroup = new CAAnimationGroup();

            animationGroup.Animations  = new CAAnimation[] { circleRadiusAnimation, strokeColorAnimation, lineWidthAnimation };
            animationGroup.Duration    = 2.25f;
            animationGroup.RepeatCount = float.PositiveInfinity;

            __animationLayer.AddAnimation(animationGroup, null);
        }
        void ShowExpandingCircle(CGPoint position, UIView view)
        {
            var circleLayer   = new CAShapeLayer();
            var initialRadius = Constants.ShortTapInitialCircleRadius;
            var finalRadius   = Constants.ShortTapFinalCircleRadius;

            circleLayer.Position = new CGPoint(x: position.X - initialRadius, y: position.Y - initialRadius);

            var startPathRect = new CGRect(x: 0, y: 0, width: initialRadius * 2, height: initialRadius * 2);
            var startPath     = UIBezierPath.FromRoundedRect(rect: startPathRect, cornerRadius: initialRadius);

            var endPathOrigin = initialRadius - finalRadius;
            var endPathRect   = new CGRect(x: endPathOrigin, y: endPathOrigin, width: finalRadius * 2, height: finalRadius * 2);
            var endPath       = UIBezierPath.FromRoundedRect(rect: endPathRect, cornerRadius: finalRadius);

            circleLayer.Path        = startPath.CGPath;
            circleLayer.FillColor   = UIColor.Clear.CGColor;
            circleLayer.StrokeColor = new UIColor(red: 0.0f / 255f, green: 135.0f / 255f, blue: 244.0f / 255f, alpha: 0.8f).CGColor;
            circleLayer.LineWidth   = 2.0f;
            view.Layer.AddSublayer(circleLayer);

            CATransaction.Begin();
            CATransaction.CompletionBlock = () =>
            {
                circleLayer.RemoveFromSuperLayer();
            };

            // Expanding animation
            var expandingAnimation = CABasicAnimation.FromKeyPath("path");

            expandingAnimation.From           = startPath;
            expandingAnimation.To             = endPath;
            expandingAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
            expandingAnimation.Duration       = 0.4f;
            expandingAnimation.RepeatCount    = 1.0f;
            circleLayer.AddAnimation(expandingAnimation, key: "expandingAnimation");
            circleLayer.Path = endPath.CGPath;

            // Delayed fade out animation
            DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, TimeSpan.FromSeconds(0.20)), action: () =>
            {
                var fadingOutAnimation            = CABasicAnimation.FromKeyPath("opacity");
                fadingOutAnimation.From           = new NSNumber(1.0f);
                fadingOutAnimation.To             = new NSNumber(0.0f);
                fadingOutAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);
                fadingOutAnimation.Duration       = 0.15f;
                circleLayer.AddAnimation(fadingOutAnimation, key: "fadeOutAnimation");
                circleLayer.Opacity = 0.0f;
            });

            CATransaction.Commit();
        }
예제 #7
0
        public void AnimationSelected(bool selected, double duration, bool fillColor)
        {
            var toAlpha = select ? 1 : 0;

            ImageAlphaAnimation(toAlpha, duration);

            var currentRad = selected ? selectedCircleRadius : circleRadius;
            var scaleAnim  = CircleScaleAnimation(currentRad - lineWidth / 2, duration);
            var toColor    = fillColor ? itemColor : UIColor.Clear;
            var colorAnim  = CircleBackgroundAnimation(toColor, duration);

            circleLayer?.AddAnimation(scaleAnim, null);
            circleLayer?.AddAnimation(colorAnim, null);
        }
예제 #8
0
        private void DrawMarker(RectangleF rowRect, float position)
        {
            if (Layer.Sublayers != null)
            {
                Layer.Sublayers = new CALayer[0];
            }

            var visibleRect     = Layer.Bounds;
            var currentTimeRect = visibleRect;

            // The red band of the timeMaker will be 7 pixels wide
            currentTimeRect.X     = 0f;
            currentTimeRect.Width = 7f;

            var timeMarkerRedBandLayer = new CAShapeLayer();

            timeMarkerRedBandLayer.Frame    = currentTimeRect;
            timeMarkerRedBandLayer.Position = new PointF(rowRect.X, Bounds.Height / 2f);

            var linePath = CGPath.FromRect(currentTimeRect);

            timeMarkerRedBandLayer.FillColor = UIColor.FromRGBA(1.00f, 0.00f, 0.00f, 0.50f).CGColor;

            timeMarkerRedBandLayer.Path = linePath;

            currentTimeRect.X     = 0f;
            currentTimeRect.Width = 1f;

            CAShapeLayer timeMarkerWhiteLineLayer = new CAShapeLayer();

            timeMarkerWhiteLineLayer.Frame    = currentTimeRect;
            timeMarkerWhiteLineLayer.Position = new PointF(3f, Bounds.Height / 2f);

            CGPath whiteLinePath = CGPath.FromRect(currentTimeRect);

            timeMarkerWhiteLineLayer.FillColor = UIColor.FromRGBA(1.00f, 1.00f, 1.00f, 1.00f).CGColor;
            timeMarkerWhiteLineLayer.Path      = whiteLinePath;

            timeMarkerRedBandLayer.AddSublayer(timeMarkerWhiteLineLayer);
            CABasicAnimation scrubbingAnimation = new CABasicAnimation();

            scrubbingAnimation.KeyPath = "position.x";

            scrubbingAnimation.From = new NSNumber(HorizontalPositionForTime(CMTime.Zero));
            scrubbingAnimation.To   = new NSNumber(HorizontalPositionForTime(duration));
            scrubbingAnimation.RemovedOnCompletion = false;
            scrubbingAnimation.BeginTime           = 0.000000001;
            scrubbingAnimation.Duration            = duration.Seconds;
            scrubbingAnimation.FillMode            = CAFillMode.Both;
            timeMarkerRedBandLayer.AddAnimation(scrubbingAnimation, null);

            Console.WriteLine("Duration in  seconds - " + Player.CurrentItem.Asset.Duration.Seconds);
            var syncLayer = new AVSynchronizedLayer()
            {
                PlayerItem = Player.CurrentItem,
            };

            syncLayer.AddSublayer(timeMarkerRedBandLayer);
            Layer.AddSublayer(syncLayer);
        }
        public void animation2(Button button)
        {
            var scaleAnimation = CABasicAnimation.FromKeyPath("transform");

            scaleAnimation.From = NSValue.FromCATransform3D(CATransform3D.MakeScale(1, 1, 1));
            scaleAnimation.To   = NSValue.FromCATransform3D(CATransform3D.MakeScale(2, 2, 1));


            var opacityAnimation = CABasicAnimation.FromKeyPath("opacity");

            opacityAnimation.From = NSNumber.FromFloat(0.25f);
            opacityAnimation.To   = NSNumber.FromFloat(0.0f);

            var rippleAnimationGroup = new CAAnimationGroup
            {
                Duration            = 2.0f,
                TimeOffset          = -0.25f,
                RemovedOnCompletion = true,
                FillMode            = CAFillMode.Both,
                TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut),
                Animations          = new CAAnimation[] { scaleAnimation, opacityAnimation }
            };


            rippleCircleLayer.AddAnimation(rippleAnimationGroup, "rippleMyAnimations");
        }
예제 #10
0
        public void BounceAnimation(nfloat positionX, nfloat positionY)
        {
            waveLayer.Path = WavePath(0, 0);
            var bounce = CAKeyFrameAnimation.GetFromKeyPath("path");

            bounce.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseIn);
            var values = new[] {
                WavePath(positionX, positionY),
                WavePath(-(positionX * 0.7f), -(positionY * 0.7f)),
                WavePath(positionX * 0.4f, positionY * 0.4f),
                WavePath(-(positionX * 0.3f), -(positionY * 0.3f)),
                WavePath(positionX * 0.15f, positionY * 0.15f),
                WavePath(0f, 0f)
            };

            bounce.SetValues(values);
            bounce.Duration            = BounceDuration;
            bounce.RemovedOnCompletion = true;
            bounce.FillMode            = CAFillMode.Forwards;
            bounce.AnimationStopped   += delegate
            {
                waveLayer.Path = WavePath(0f, 0f);
            };
            waveLayer.AddAnimation(bounce, "return");
        }
예제 #11
0
        internal static void pulseContractAnimation(CALayer layer, CALayer visualLayer, Pulse pulse)
        {
            CAShapeLayer bLayer = null;

            try
            {
                bLayer = pulse.Layers.Dequeue();
            }
            catch (Exception) {
                return;
            }
            if (bLayer != null)
            {
                var test     = bLayer.ValueForKey(new NSString("animated")) as NSNumber;
                var animated = test.BoolValue;

                Animation.Delay(animated ? 0 : 0.15, () =>
                {
                    var pLayer = bLayer.Sublayers[0] as CAShapeLayer;
                    if (pLayer != null)
                    {
                        var duration = 0.3125;
                        switch (pulse.Animation)
                        {
                        case PulseAnimation.CenterWithBacking:
                        case PulseAnimation.Backing:
                        case PulseAnimation.AtPointWithBacking:
                            bLayer.AddAnimation(Animation.BackgroundColor(pulse.Color.ColorWithAlpha(0), 0.325), null);
                            break;

                        default:
                            break;
                        }

                        switch (pulse.Animation)
                        {
                        case PulseAnimation.Center:
                        case PulseAnimation.CenterWithBacking:
                        case PulseAnimation.CenterRadialBeyondBounds:
                        case PulseAnimation.AtPoint:
                        case PulseAnimation.AtPointWithBacking:
                            pLayer.AddAnimation(Animation.AnimationGroup(new CAAnimation[] {
                                Animation.Scale(pulse.Animation == PulseAnimation.Center ? 1f : 1.325f),
                                Animation.BackgroundColor(pulse.Color.ColorWithAlpha(0))
                            }, duration), null);
                            break;

                        default:
                            break;
                        }

                        Animation.Delay(duration, () =>
                        {
                            pLayer.RemoveFromSuperLayer();
                            bLayer.RemoveFromSuperLayer();
                        });
                    }
                });
            }
        }
        /// <summary>
        /// Opens all cells.
        /// </summary>
        public void Open()
        {
            // rotate plus icon
            plusLayer.AddAnimation(PlusKeyFrame(true), "plusRot");
            plusRotation = CoreGraphicsExtensions.PI * 0.25f; // 45 degree

            var cells = CellArray();

            foreach (var cell in cells)
            {
                InsertCell(cell);
            }

            baseView.Open(cells);
            SetNeedsDisplay();
        }
예제 #13
0
        private void TxtPath()
        {
            var          path  = ChartTool.GetStringPath("Object To evaluate.x");
            CAShapeLayer layer = new CAShapeLayer();

            layer.Frame       = new CGRect(new CGPoint(20, 20), path.CGPath.PathBoundingBox.Size);
            layer.Path        = path.CGPath;
            layer.StrokeColor = UIColor.Red.CGColor;
            layer.FillColor   = UIColor.Clear.CGColor;
            //layer.BackgroundColor = UIColor.White.CGColor;
            layer.GeometryFlipped = true;
            layer.LineWidth       = 2;
            Context.Layer.AddSublayer(layer);



            CABasicAnimation animation = CABasicAnimation.FromKeyPath("strokeEnd");

            animation.From = NSNumber.FromNInt(0);
            animation.To   = NSNumber.FromInt16(1);
            animation.RemovedOnCompletion = false;
            animation.FillMode            = CAFillMode.Forwards;
            animation.Duration            = 4;
            layer.AddAnimation(animation, "ma");
        }
예제 #14
0
        // set up an animation, but prevent it from running automatically
        // the animation progress will be adjusted manually
        public void SetAnimatedColors(UIColor[] animatedColors, NSNumber[] keyTimes)
        {
            var cgColors = new List <NSObject>();

            foreach (var col in animatedColors)
            {
                cgColors.Add(NSObject.FromObject(col.CGColor));
            }

            var colorAnim = CAKeyFrameAnimation.FromKeyPath(SliderFillColorAnim);

            colorAnim.KeyTimes     = keyTimes;
            colorAnim.Values       = cgColors.ToArray();
            colorAnim.FillMode     = CAFillMode.Both;
            colorAnim.Duration     = 1.0;
            colorAnim.WeakDelegate = this;

            // As the interpolated color values from the presentationLayer are needed immediately
            // the animation must be allowed to start to initialize _colorAnimLayer's presentationLayer
            // hence the speed is set to min value - then set to zero in 'animationDidStart:' delegate method
            colorAnimLayer.Speed = 1.175494351e-38F;              // FLT_MIN
            //colorAnimLayer.Speed = 0.0000000000000000000000000000000000000117549435f;
            colorAnimLayer.TimeOffset = 0.0;

            colorAnimLayer.AddAnimation(colorAnim, SliderFillColorAnim);
        }
예제 #15
0
        public static async Task <bool> BasicAnimationAsync(
            CAShapeLayer layer,
            string path,
            float duration,
            NSObject from,
            NSObject to,
            NSString timingFunction = null,
            string animationName    = null
            )
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            using (var drawAnimation = CABasicAnimation.FromKeyPath(path))
            {
                drawAnimation.Duration    = duration;
                drawAnimation.RepeatCount = 1;

                drawAnimation.From = @from;
                drawAnimation.To   = to;

                if (timingFunction != null)
                {
                    drawAnimation.TimingFunction = CAMediaTimingFunction.FromName(timingFunction);
                }

                drawAnimation.AnimationStopped += (sender, args) => { taskCompletionSource.TrySetResult(args.Finished); };

                SetShapeLayerEndState(layer, drawAnimation);
                var key = animationName ?? Guid.NewGuid().ToString();
                layer.AddAnimation(drawAnimation, key);

                return(await taskCompletionSource.Task);
            }
        }
예제 #16
0
        private float curProgress = 0.0f;         //from 0 to 1

        public CircularProgressView(CGRect frame)
        {
            Frame           = frame;
            BackgroundColor = UIColor.Clear;

            UIBezierPath outerCirclePath = UIBezierPath.FromOval(frame);

            outerCircleLayer             = new CAShapeLayer();
            outerCircleLayer.Bounds      = Bounds;
            outerCircleLayer.Position    = Center;
            outerCircleLayer.Path        = outerCirclePath.CGPath;
            outerCircleLayer.FillColor   = UIColor.Clear.CGColor;
            outerCircleLayer.LineWidth   = 1.0f;
            outerCircleLayer.StrokeColor = UIColor.White.CGColor;
            outerCircleLayer.StrokeStart = 0.05f;
            outerCircleLayer.StrokeEnd   = 1.0f;
            Layer.AddSublayer(outerCircleLayer);

            CABasicAnimation rotationAnimation = CABasicAnimation.FromKeyPath("transform.rotation.z");

            rotationAnimation.To             = NSNumber.FromDouble(Math.PI * 2.0);
            rotationAnimation.Duration       = 1;
            rotationAnimation.Cumulative     = true;
            rotationAnimation.RepeatDuration = 3600;
            outerCircleLayer.AddAnimation(rotationAnimation, "rotationAnimation");
        }
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			_transitionContext = transitionContext;

			var containerView = transitionContext.ContainerView;

			FlashCardViewController toViewController;
			UIViewController fromViewController;

			if (Presenting) {
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as UIViewController;
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as FlashCardViewController;
			} else {
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as FlashCardViewController;
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as UIViewController;
			}

			if(Presenting)
				containerView.AddSubview(toViewController.View);

			var originRect = toViewController.SourceFrame;

			var circleRect = new CGRect (originRect.GetMidX(), originRect.GetMidY(), 10, 10);

			var circleMaskPathInitial = UIBezierPath.FromOval(circleRect); //(ovalInRect: button.frame);
			var extremePoint = new CGPoint(circleRect.X - toViewController.View.Bounds.Width, circleRect.Y - toViewController.View.Bounds.Height ); //CGRect.GetHeight (toViewController.view.bounds));
			var radius = (float)Math.Sqrt((extremePoint.X * extremePoint.X) + (extremePoint.Y * extremePoint.Y));
			var largeCircleRect = circleRect.Inset (-radius, -radius);
			var circleMaskPathFinal = UIBezierPath.FromOval (largeCircleRect);

			CGPath fromPath;
			CGPath toPath;

			if (Presenting) {
				fromPath = circleMaskPathInitial.CGPath;
				toPath = circleMaskPathFinal.CGPath;
			} else {
				var path = new CGPath ();
				fromPath = circleMaskPathFinal.CGPath;
				toPath = circleMaskPathInitial.CGPath;
			}

			var maskLayer = new CAShapeLayer();
			maskLayer.Path = fromPath;
			if (Presenting) {
				toViewController.View.Layer.Mask = maskLayer;
			} else {
				toViewController.View.Layer.Mask = maskLayer;
			}

			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.From = ObjCRuntime.Runtime.GetNSObject(fromPath.Handle);
			maskLayerAnimation.To = ObjCRuntime.Runtime.GetNSObject(toPath.Handle);
			maskLayerAnimation.Duration = this.TransitionDuration(transitionContext);
			_animDoneDelegate = new AnimDoneDelegate (transitionContext);
			maskLayerAnimation.Delegate = _animDoneDelegate;
			maskLayer.AddAnimation(maskLayerAnimation, "path");

		}
        public void Open()
        {
            // ISSUE: reference to a compiler-generated method
            _plusLayer.AddAnimation(PlusKeyFrame(true), "plusRot");
            _plusRotation = CoreGraphicsExtensions.Pi * 0.25f;
            var cells = CellArray();

            foreach (var cell in cells)
            {
                InsertCell(cell);
            }
            _baseView.Open(cells);
            // ISSUE: reference to a compiler-generated method
            SetNeedsDisplay();
            //raise event open menu
            OnMenuOpened?.Invoke(this, new FloatingMenuOpenEventArgs(isOpen: true));
        }
        private void AnimateRipple(UITouch touch)
        {
            var view = _touchView;

            var location  = touch.LocationInView(view);
            var startPath = UIBezierPath.FromArc(location, 8f, 0, 360f, true);
            var endPath   = UIBezierPath.FromArc(location, view.Frame.Width - 12, 0, 360f, true);

            SetupAnimationLayer(_rippleLayer, view, 4);

            _rippleAnimation.From = FromObject(startPath.CGPath);
            _rippleAnimation.To   = FromObject(endPath.CGPath);
            UIView.Animate(0.3, () =>
            {
                _rippleLayer.AddAnimation(_rippleAnimation, "rippleAnimation");
                _rippleLayer.AddAnimation(_fadeAnimation, "rippleFadeAnim");
            });
        }
예제 #20
0
        public void StartAnimation()
        {
            var checkmarkStrokeAnimation = CAKeyFrameAnimation.FromKeyPath("strokeEnd");

            checkmarkStrokeAnimation.Values   = new NSObject[] { new NSNumber(0), new NSNumber(1) };
            checkmarkStrokeAnimation.KeyTimes = new[] { new NSNumber(0), new NSNumber(1) };
            checkmarkStrokeAnimation.Duration = .35f;

            _checkmarkShapeLayer?.AddAnimation(checkmarkStrokeAnimation, "checkmarkStrokeAnimation");
        }
예제 #21
0
        private void SetupColorAnimation()
        {
            if (null == _colorAnimation)
            {
                _colorAnimation = CABasicAnimation.FromKeyPath("strokeColor");
                _colorAnimation.AnimationStopped += (x, y) =>
                {
                    if (IsIndeterminate)
                    {
                        _shadowLayer.RemoveAnimation(ANIMATION_COLOR);
                    }
                    else
                    {
                        _shadowLayer.AddAnimation(_colorAnimation, ANIMATION_COLOR);
                    }
                };
            }

            _colorAnimation.SetFrom(_shadowLayer.StrokeColor);

            _colorAnimation.SetTo(UIColor.FromRGBA(_shadowStrokeColor.CGColor.Components[0], _shadowStrokeColor.CGColor.Components[1], _shadowStrokeColor.CGColor.Components[2], 0.2f).CGColor);
            _colorAnimation.Duration            = 1f;
            _colorAnimation.FillMode            = CAFillMode.Forwards;
            _colorAnimation.TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            _colorAnimation.RemovedOnCompletion = false;
            _colorAnimation.AutoReverses        = true;
        }
        private void animate()
        {
            var animation = new CABasicAnimation();

            animation.KeyPath           = "strokeEnd";
            animation.Duration          = Element.AnimationDuration / 1000;
            animation.From              = new NSNumber(0.0);
            animation.To                = new NSNumber(CalculateValue());
            animation.TimingFunction    = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);
            indicatorCircle.StrokeStart = new nfloat(0.0);
            indicatorCircle.StrokeEnd   = new nfloat(CalculateValue());
            indicatorCircle.AddAnimation(animation, "appear");
        }
예제 #23
0
        void startAnimation()
        {
            pathLayer?.RemoveAllAnimations();

            var pathAnimation = CABasicAnimation.FromKeyPath("strokeEnd");

            pathAnimation.AnimationStopped += pathAnimationStopped;
            pathAnimation.Duration          = Settings.LetterDrawDuration;
            pathAnimation.From              = NSObject.FromObject(0);
            pathAnimation.To = NSObject.FromObject(1);

            pathLayer?.AddAnimation(pathAnimation, "strokeEnd");
        }
        private void PlayExpandAnimation()
        {
            CATransaction.Begin();
            CATransaction.CompletionBlock = () =>
            {
                _coloredCircleLayer.Path = coloredCircleLayerPath().CGPath;
                PlayFocusAnimation();
                ShowLabels();
            };
            var animation = CABasicAnimation.FromKeyPath("path");

            animation.Duration       = 0.8f;
            animation.To             = FromObject(coloredCircleLayerPath().CGPath);
            animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            // if you remove it the shape will return to the original shape after the animation finished
            animation.FillMode            = CAShapeLayer.FillRuleEvenOdd;
            animation.RemovedOnCompletion = false;


            _coloredCircleLayer.AddAnimation(animation, null);
            CATransaction.Commit();
        }
예제 #25
0
        async void StartSearching()
        {
            if (Searching)
            {
                return;
            }
            Searching           = true;
            ShouldStopSearching = false;

            if (!IsSufficentPermissionGranted())
            {
                StatusButton.Hidden = false;
                StatusButton.SetTitle("Location Permission Necessary. \n Go to Settings", new UIControlState());
                return;
            }

            shape             = new CAShapeLayer();
            shape.Bounds      = new CGRect(0, 0, PhoneImageView.Frame.Width, PhoneImageView.Frame.Height);
            shape.Position    = new CGPoint(PhoneImageView.Frame.Width / 2, PhoneImageView.Frame.Height / 2);
            shape.Path        = UIBezierPath.FromOval(PhoneImageView.Bounds).CGPath;
            shape.StrokeColor = UIColor.White.CGColor;
            shape.LineWidth   = (nfloat).5;
            shape.FillColor   = UIColor.Clear.CGColor;
            PhoneImageView.Layer.AddSublayer(shape);

            CABasicAnimation grow = CABasicAnimation.FromKeyPath("transform.scale");

            grow.From                = NSObject.FromObject(20);
            grow.Duration            = 2;
            grow.To                  = NSObject.FromObject(1);
            grow.FillMode            = CAFillMode.Forwards;
            grow.RepeatCount         = 10000;
            grow.RemovedOnCompletion = false;
            shape.AddAnimation(grow, "grow");

            StatusButton.Hidden = false;
            StatusButton.SetTitle("Searching for people \n sharing nearby", new UIControlState());

            while (!ShouldStopSearching && View.Window != null)
            {
                await Shared.GetNearbyTransactions();

                StopSearchingIfCardsFound();

                Console.WriteLine("GOT");
                await Task.Delay(TimeSpan.FromSeconds(5));

                Console.WriteLine("DONE");
            }
        }
        private void playAnimationForWhiteCircle()
        {
            var animation = CABasicAnimation.FromKeyPath(path: "path");

            animation.Duration       = 1.55;
            animation.BeginTime      = CAAnimation.CurrentMediaTime() + 0.8;
            animation.To             = FromObject(expandedBlurWhiteCirclePath().CGPath);
            animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            animation.RepeatCount    = float.MaxValue;
            // if you remove it the shape will return to the original shape after the animation finished
            animation.FillMode            = CAShapeLayer.FillRuleEvenOdd;
            animation.RemovedOnCompletion = false;
            _blurWhiteCircleLayer.AddAnimation(animation, null);

            var opacityAnimation = CABasicAnimation.FromKeyPath(path: "opacity");

            opacityAnimation.From        = FromObject(0.5f);
            opacityAnimation.To          = FromObject(0f);
            opacityAnimation.BeginTime   = CAAnimation.CurrentMediaTime() + 0.8;
            opacityAnimation.RepeatCount = float.MaxValue;
            opacityAnimation.Duration    = 1.55;
            _blurWhiteCircleLayer.AddAnimation(opacityAnimation, null);
        }
예제 #27
0
        /// <summary>
        /// Renders the activity spinner and starts the animation.
        /// </summary>
        public void RenderToViewWithAnimation()
        {
            CAShapeLayer circleLayer = new CAShapeLayer();

            nfloat circleSize = (float)Math.Min(this.View.Bounds.Width, this.View.Bounds.Height);

            circleLayer.Path        = this.CreateCirclePath(circleSize, this.lineWidth);
            circleLayer.Position    = new CGPoint(this.View.Bounds.GetMidX(), this.View.Bounds.GetMidY());
            circleLayer.StrokeColor = this.spinnerColor.CGColor;
            circleLayer.FillColor   = UIColor.Clear.CGColor;
            circleLayer.LineWidth   = this.lineWidth;
            circleLayer.LineCap     = CAShapeLayer.CapRound;

            CAAnimation strokeEndAnimation   = this.CreateStrokeAnimation("strokeEnd", Constants.StrokeEndAnimationBeginTime);
            CAAnimation strokeStartAnimation = this.CreateStrokeAnimation("strokeStart", Constants.StrokeStartAnimationBeginTime);
            CAAnimation rotationAnimation    = this.CreateRotationAnimation();

            circleLayer.AddAnimation(strokeEndAnimation, null);
            circleLayer.AddAnimation(strokeStartAnimation, null);
            circleLayer.AddAnimation(rotationAnimation, null);

            this.View.Layer.AddSublayer(circleLayer);
        }
예제 #28
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            //1
            _transitionContext = transitionContext;

            //2
            var containerView      = _transitionContext.ContainerView;
            var fromViewController = _transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey) as OnboardingController;
            var toViewController   = _transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey) as ContainerController;
            var fromRect           = fromViewController.NavigationRect;
            var toRect             = new CGRect(-toViewController.View.Bounds.Width / 2, -toViewController.View.Bounds.Height / 2, toViewController.View.Bounds.Width * 2, toViewController.View.Bounds.Height * 2);

            //3
            containerView.AddSubview(toViewController.View);

            //4
            var circleMaskPathInitial = UIBezierPath.FromRoundedRect(fromRect, fromRect.Height / 2);

            var circleMaskPathFinal = UIBezierPath.FromRoundedRect(toRect, toRect.Height / 2);

            //5
            var maskLayer = new CAShapeLayer();

            maskLayer.Path = circleMaskPathFinal.CGPath;
            toViewController.View.Layer.Mask = maskLayer;

            //6
            var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");

            maskLayerAnimation.SetFrom(circleMaskPathInitial.CGPath);
            maskLayerAnimation.SetTo(circleMaskPathFinal.CGPath);
            maskLayerAnimation.Duration       = TransitionDuration(_transitionContext);
            maskLayerAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseIn);

            maskLayerAnimation.AnimationStopped += (object sender, CAAnimationStateEventArgs e) => {
                if (_transitionContext != null)
                {
                    _transitionContext.CompleteTransition(!_transitionContext.TransitionWasCancelled);
                    var controller = _transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
                    if (controller != null)
                    {
                        controller.View.Layer.Mask = null;
                    }
                }
            };

            maskLayer.AddAnimation(maskLayerAnimation, "path");
        }
예제 #29
0
        private void DrawGrid()
        {
            var size = new CGRect()
            {
                Width  = ContentSize.Width > Frame.Width ? Frame.Width : ContentSize.Width,
                Height = ContentSize.Height > Frame.Width ? Frame.Width : ContentSize.Height,
                X      = ContentOffset.X < 0 ? 0 : ContentOffset.X,
                Y      = ContentOffset.Y < 0 ? 0 : ContentOffset.Y,
            };

            var gridHeight = size.Height / (_linesCount + 1);
            var gridWidth  = size.Width / (_linesCount + 1);

            _path           = UIBezierPath.Create();
            _path.LineWidth = 1;

            for (int i = 1; i < _linesCount + 1; i++)
            {
                var start = new CGPoint(x: i * gridWidth + size.X, y: size.Y);
                var end   = new CGPoint(x: i * gridWidth + size.X, y: size.Height + size.Y);
                _path.MoveTo(start);
                _path.AddLineTo(end);
            }

            for (int i = 1; i < _linesCount + 1; i++)
            {
                var start = new CGPoint(x: size.X, y: i * gridHeight + size.Y);
                var end   = new CGPoint(x: size.Width + size.X, y: i * gridHeight + size.Y);
                _path.MoveTo(start);
                _path.AddLineTo(end);
            }
            _shapeLayer.RemoveAllAnimations();
            _shapeLayer.StrokeColor = _strokeColor.ColorWithAlpha(0.15f).CGColor;

            var animation = CABasicAnimation.FromKeyPath("strokeColor");

            animation.BeginTime = CAAnimation.CurrentMediaTime() + 0.2; //delay
            animation.Duration  = 0.2;
            animation.SetTo(_strokeColor.ColorWithAlpha(0).CGColor);
            animation.RemovedOnCompletion = false;
            animation.FillMode            = CAFillMode.Forwards;

            _shapeLayer.AddAnimation(animation, "flashStrokeColor");
            _shapeLayer.Path = _path.CGPath;
            _path.ClosePath();
        }
예제 #30
0
        CAAnimation ShapeAnimation(CAShapeLayer layer, string keyPath, NSObject from, NSObject to, float duration = 0.2f)
        {
            if (from == to)
            {
                return(null);
            }

            var animation = new CABasicAnimation {
                KeyPath = keyPath
            };

            animation.From     = ValueForKeyPath(new NSString(keyPath));
            animation.To       = to;
            animation.Duration = duration;
            layer.AddAnimation(animation, keyPath);
            layer.SetValueForKey(to, new NSString(keyPath));

            return(animation);
        }
        public void Select()
        {
            _isSelected           = true;
            _imageShape.FillColor = _imageColorOn.CGColor;

            CATransaction.Begin();

            _circleShape.AddAnimation(_circleTransform, "transform");
            _circleMask.AddAnimation(_circleMaskTransform, "transform");
            _imageShape.AddAnimation(_imageTransform, "transform");

            for (int i = 0; i < 5; i++)
            {
                _lines[i].AddAnimation(_lineStrokeStart, "strokeStart");
                _lines[i].AddAnimation(_lineStrokeEnd, "strokeEnd");
                _lines[i].AddAnimation(_lineOpacity, "opacity");
            }

            CATransaction.Commit();
        }
        /// <summary>
        /// Replays the recorded gestures animated.
        /// </summary>
        /// <param name="coll">gesture collection to replay</param>
        /// <param name="duration">Duration in seconds.</param>
        /// <param name="color">Color.</param>
        public void Replay(float duration, UIColor color)
        {
            CAShapeLayer pathLayer = new CAShapeLayer ();
            pathLayer.Frame = this.PictureLoginView.DrawingAreaView.Bounds;
            pathLayer.GeometryFlipped = false;
            pathLayer.Path = this.PictureLoginView.DrawingAreaView.GesturePath;
            pathLayer.StrokeColor = color.CGColor;
            pathLayer.LineWidth = 5f;
            pathLayer.FillColor =  UIColor.Clear.CGColor;

            CABasicAnimation pathAnimation = CABasicAnimation.FromKeyPath("strokeEnd");
            pathAnimation.Duration = duration;
            pathAnimation.From = new NSNumber(0f);
            pathAnimation.To = new NSNumber(1f);
            pathAnimation.AnimationStopped += (object sender, CAAnimationStateEventArgs e) => {
                pathLayer.RemoveAnimation("strokeEndAnimation");
                pathLayer.RemoveFromSuperLayer();
            };
            pathLayer.AddAnimation (pathAnimation, "strokeEndAnimation");
            this.PictureLoginView.DrawingAreaView.Layer.AddSublayer (pathLayer);
        }
예제 #33
0
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			//1
			_transitionContext = transitionContext;

			//2
			var containerView = _transitionContext.ContainerView;
			var fromViewController = _transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as OnboardingController;
			var toViewController = _transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as ContainerController;
			var fromRect = fromViewController.NavigationRect;
			var toRect = new CGRect (-toViewController.View.Bounds.Width / 2, -toViewController.View.Bounds.Height / 2, toViewController.View.Bounds.Width * 2, toViewController.View.Bounds.Height * 2);

			//3
			containerView.AddSubview(toViewController.View);

			//4
			var circleMaskPathInitial = UIBezierPath.FromRoundedRect(fromRect, fromRect.Height/2);

			var circleMaskPathFinal = UIBezierPath.FromRoundedRect (toRect, toRect.Height/2);

			//5
			var maskLayer = new CAShapeLayer();
			maskLayer.Path = circleMaskPathFinal.CGPath;
			toViewController.View.Layer.Mask = maskLayer;

			//6
			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.SetFrom(circleMaskPathInitial.CGPath);
			maskLayerAnimation.SetTo(circleMaskPathFinal.CGPath);
			maskLayerAnimation.Duration =  TransitionDuration(_transitionContext);
			maskLayerAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseIn);

			maskLayerAnimation.AnimationStopped += (object sender, CAAnimationStateEventArgs e) => {
				if(_transitionContext != null) {
					_transitionContext.CompleteTransition (!_transitionContext.TransitionWasCancelled);
					var controller = _transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
					if(controller != null) {
						controller.View.Layer.Mask = null;	
					}
				}
			};

			maskLayer.AddAnimation (maskLayerAnimation, "path");
		}
		private void DrawMarker (CGRect rowRect, float position)
		{
			if (Layer.Sublayers != null) {
				Layer.Sublayers = new CALayer[0];
			}

			var visibleRect = Layer.Bounds;
			var currentTimeRect = visibleRect;

			// The red band of the timeMaker will be 7 pixels wide
			currentTimeRect.X = 0f;
			currentTimeRect.Width = 7f;

			var timeMarkerRedBandLayer = new CAShapeLayer ();
			timeMarkerRedBandLayer.Frame = currentTimeRect;
			timeMarkerRedBandLayer.Position = new CGPoint (rowRect.X, Bounds.Height / 2f);

			var linePath = CGPath.FromRect (currentTimeRect);
			timeMarkerRedBandLayer.FillColor = UIColor.FromRGBA (1.00f, 0.00f, 0.00f, 0.50f).CGColor;

			timeMarkerRedBandLayer.Path = linePath;

			currentTimeRect.X = 0f;
			currentTimeRect.Width = 1f;

			CAShapeLayer timeMarkerWhiteLineLayer = new CAShapeLayer ();
			timeMarkerWhiteLineLayer.Frame = currentTimeRect;
			timeMarkerWhiteLineLayer.Position = new CGPoint (3f, Bounds.Height / 2f);

			CGPath whiteLinePath = CGPath.FromRect (currentTimeRect);
			timeMarkerWhiteLineLayer.FillColor = UIColor.FromRGBA (1.00f, 1.00f, 1.00f, 1.00f).CGColor;
			timeMarkerWhiteLineLayer.Path = whiteLinePath;

			timeMarkerRedBandLayer.AddSublayer (timeMarkerWhiteLineLayer);
			CABasicAnimation scrubbingAnimation = new CABasicAnimation ();
			scrubbingAnimation.KeyPath = "position.x";

			scrubbingAnimation.From = new NSNumber (HorizontalPositionForTime (CMTime.Zero));
			scrubbingAnimation.To = new NSNumber (HorizontalPositionForTime (duration));
			scrubbingAnimation.RemovedOnCompletion = false;
			scrubbingAnimation.BeginTime = 0.000000001;
			scrubbingAnimation.Duration = duration.Seconds;
			scrubbingAnimation.FillMode = CAFillMode.Both;
			timeMarkerRedBandLayer.AddAnimation (scrubbingAnimation, null);
			if (Player != null) {
				Console.WriteLine ("Duration in  seconds - " + Player.CurrentItem.Asset.Duration.Seconds);
				var syncLayer = new AVSynchronizedLayer () {
					PlayerItem = Player.CurrentItem,
				};
				syncLayer.AddSublayer (timeMarkerRedBandLayer);
				Layer.AddSublayer (syncLayer);
			}
		}