Exemple #1
0
        AnimationElement GetAnimationElement(int listIndex)
        {
            AnimationElement element;

            if (!animationElements.TryGetValue(listIndex, out element))
            {
                element = new AnimationElement();
                animationElements[listIndex] = element;
            }
            return(element);
        }
Exemple #2
0
        void StartAnimation(Racer racer, Color color)
        {
            AnimationElement element        = GetAnimationElement(racer);
            DoubleAnimation  speedAnimation = new DoubleAnimation()
            {
                To = racer.Speed,
                AccelerationRatio = 0.5,
                DecelerationRatio = 0.5,
                Duration          = new Duration(TimeSpan.FromSeconds(5))
            };
            ColorAnimation colorAnimation = new ColorAnimation()
            {
                From     = color,
                To       = Colors.Transparent,
                Duration = new Duration(TimeSpan.FromSeconds(5))
            };

            element.BeginAnimation(AnimationElement.CurrentSpeedProperty, speedAnimation);
            element.BeginAnimation(AnimationElement.SpeedColorProperty, colorAnimation);
        }