Exemple #1
0
        private void startGrowInAnimation(bool inAndOut, int delay)
        {
            if (!_doingAnimation)
            {
                _doingAnimation          = true;
                Overlay.IsHitTestVisible = true;
                ContentHolder.Opacity    = 0;

                //do fade in on overlay
                ColorAnimation overlayAnimation;
                overlayAnimation          = new ColorAnimation();
                overlayAnimation.From     = Color.FromArgb(0, 0, 0, 0);
                overlayAnimation.To       = Color.FromArgb(88, 0, 0, 0);
                overlayAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
                Overlay.Background.BeginAnimation(SolidColorBrush.ColorProperty, overlayAnimation);

                //do grow in animation
                ScaleTransform scale = new ScaleTransform(1.0, 1.0);
                Card.RenderTransformOrigin = new Point(0.5, 0.5);
                Card.RenderTransform       = scale;

                DoubleAnimation growXAnimation = new DoubleAnimation();
                growXAnimation.Duration       = new Duration(TimeSpan.FromSeconds(0.5));
                growXAnimation.From           = 0;
                growXAnimation.To             = 1;
                growXAnimation.EasingFunction = new CubicEase
                {
                    EasingMode = EasingMode.EaseOut
                };
                Card.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, growXAnimation);

                DoubleAnimation growYAnimation = new DoubleAnimation();
                growYAnimation.Duration       = new Duration(TimeSpan.FromSeconds(0.5));
                growYAnimation.From           = 0;
                growYAnimation.To             = 1;
                growYAnimation.EasingFunction = new CubicEase
                {
                    EasingMode = EasingMode.EaseOut
                };
                growYAnimation.Completed += delegate
                {
                    _doingAnimation = false;
                    if (inAndOut)
                    {
                        startGrowOutAnimation(delay);
                    }
                };
                Card.RenderTransform.BeginAnimation(ScaleTransform.ScaleYProperty, growYAnimation);

                //do fade in on content
                DoubleAnimation fadeIn = new DoubleAnimation
                {
                    From      = 0,
                    To        = 1,
                    BeginTime = TimeSpan.FromSeconds(0.2),
                    Duration  = new Duration(TimeSpan.FromSeconds(0.3))
                };
                ContentHolder.BeginAnimation(UIElement.OpacityProperty, fadeIn);
            }
        }