/// <summary>
        /// Creates a new <see cref="AnimationBase"/> instance from the specified animation definition.
        /// </summary>
        /// <param name="animationDefinition">The animation definition to instantiate.</param>
        /// <param name="animatedPropertyType">The type of property which is being animated.</param>
        /// <returns>The <see cref="AnimationBase"/> instance that was created.</returns>
        private AnimationBase InstantiateStoryboardAnimation(UvssStoryboardAnimation animationDefinition, Type animatedPropertyType)
        {
            if (animatedPropertyType == null)
            {
                return(null);
            }

            var animationType = GetAnimationType(animatedPropertyType);

            if (animationType == null)
            {
                return(null);
            }

            var animation = (AnimationBase)Activator.CreateInstance(animationType);

            foreach (var keyframeDefinition in animationDefinition.Keyframes)
            {
                var keyframe = InstantiateStoryboardAnimationKeyframe(keyframeDefinition, animatedPropertyType);
                animation.AddKeyframe(keyframe);
            }

            return(animation);
        }
        /// <summary>
        /// Creates a new <see cref="AnimationBase"/> instance based on the specified <see cref="UvssStoryboardAnimation"/>.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="targetDefinition">The type filter on the storyboard target.</param>
        /// <param name="animationDefinition">The storyboard animation definition.</param>
        /// <param name="animationKey">The name of the dependency property which is being animated.</param>
        /// <returns>The reified storyboard animation.</returns>
        public static AnimationBase ReifyStoryboardAnimation(UltravioletContext uv, UvssStoryboardTarget targetDefinition, UvssStoryboardAnimation animationDefinition, out StoryboardTargetAnimationKey animationKey)
        {
            Contract.Require(targetDefinition, "targetDefinition");
            Contract.Require(animationDefinition, "animationDefinition");

            var propertyName = animationDefinition.AnimatedProperty;
            var propertyType = GetDependencyPropertyType(uv, targetDefinition.Filter, ref propertyName);

            var navigationExpression = default(NavigationExpression?);
            var navigationExpressionDef = animationDefinition.NavigationExpression;
            if (navigationExpressionDef != null)
            {
                propertyType = GetDependencyPropertyType(uv, new[] { navigationExpressionDef.NavigationPropertyType }, ref propertyName);
                navigationExpression = NavigationExpression.FromUvssNavigationExpression(uv, navigationExpressionDef);
            }

            animationKey = new StoryboardTargetAnimationKey(new UvmlName(propertyName), navigationExpression);

            if (propertyType == null)
                return null;

            var animationType = GetAnimationType(propertyType);
            if (animationType == null)
                return null;

            var animation = (AnimationBase)Activator.CreateInstance(animationType);

            foreach (var keyframeDefinition in animationDefinition.Keyframes)
            {
                var keyframe = ReifyStoryboardAnimationKeyframe(uv, keyframeDefinition, propertyType);
                animation.AddKeyframe(keyframe);
            }

            return animation;
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new <see cref="AnimationBase"/> instance from the specified animation definition.
        /// </summary>
        /// <param name="animationDefinition">The animation definition to instantiate.</param>
        /// <param name="animatedPropertyType">The type of property which is being animated.</param>
        /// <returns>The <see cref="AnimationBase"/> instance that was created.</returns>
        private AnimationBase InstantiateStoryboardAnimation(UvssStoryboardAnimation animationDefinition, Type animatedPropertyType)
        {
            if (animatedPropertyType == null)
                return null;

            var animationType = GetAnimationType(animatedPropertyType);
            if (animationType == null)
                return null;

            var animation = (AnimationBase)Activator.CreateInstance(animationType);

            foreach (var keyframeDefinition in animationDefinition.Keyframes)
            {
                var keyframe = InstantiateStoryboardAnimationKeyframe(keyframeDefinition, animatedPropertyType);
                animation.AddKeyframe(keyframe);
            }

            return animation;
        }