/// <summary>
        /// Creates a new <see cref="StoryboardTarget"/> instance based on the specified <see cref="UvssStoryboardTarget"/>.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="targetDefinition">The storyboard target definition.</param>
        /// <returns>The reified storyboard target.</returns>
        public static StoryboardTarget ReifyStoryboardTarget(UltravioletContext uv, UvssStoryboardTarget targetDefinition)
        {
            Contract.Require(targetDefinition, "targetDefinition");

            var target = new StoryboardTarget(targetDefinition.Selector);

            foreach (var animationDefinition in targetDefinition.Animations)
            {
                var animationKey = default(StoryboardTargetAnimationKey);
                var animation = ReifyStoryboardAnimation(uv, targetDefinition, animationDefinition, out animationKey);
                if (animation != null)
                {
                    target.Animations.Add(animationKey, animation);
                }
            }

            return target;
        }
예제 #2
0
        /// <summary>
        /// Creates a new <see cref="StoryboardTarget"/> instance from the specified target definition.
        /// </summary>
        /// <param name="targetDefinition">The storyboard target definition to instantiate.</param>
        /// <returns>The <see cref="StoryboardTarget"/> instance that was created.</returns>
        private StoryboardTarget InstantiateStoryboardTarget(UvssStoryboardTarget targetDefinition)
        {
            var target = new StoryboardTarget(targetDefinition.Selector);

            foreach (var animationDefinition in targetDefinition.Animations)
            {
                var animatedPropertyName = animationDefinition.AnimatedProperty;
                var animatedPropertyType = ResolvePropertyTypeFromFilter(Ultraviolet, targetDefinition.Filter, ref animatedPropertyName);

                var navigationExpression = default(NavigationExpression?);
                var navigationExpressionDef = animationDefinition.NavigationExpression;
                if (navigationExpressionDef != null)
                {
                    animatedPropertyType = ResolvePropertyTypeFromFilter(Ultraviolet,
                        new[] { navigationExpressionDef.NavigationPropertyType }, ref animatedPropertyName);

                    navigationExpression = NavigationExpression.FromUvssNavigationExpression(Ultraviolet, navigationExpressionDef);
                }

                var animationKey = new StoryboardTargetAnimationKey(new DependencyName(animatedPropertyName), navigationExpression);
                var animation = InstantiateStoryboardAnimation(animationDefinition, animatedPropertyType);
                if (animation != null)
                {
                    target.Animations.Add(animationKey, animation);
                }
            }

            return target;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StoryboardTargetAnimationCollection"/> class.
        /// </summary>
        /// <param name="target">The storyboard target that owns the collection.</param>
        public StoryboardTargetAnimationCollection(StoryboardTarget target)
        {
            Contract.Require(target, nameof(target));

            this.target = target;
        }