Esempio n. 1
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);
        }
Esempio n. 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 ownerType = default(Type);
                if (animationDefinition.AnimatedProperty.IsAttached)
                {
                    PresentationFoundation.Instance.GetKnownType(animationDefinition.AnimatedProperty.Owner, out ownerType);
                }

                var animatedPropertyName = animationDefinition.AnimatedProperty.Name;
                var animatedPropertyType = default(Type);
                if (animationDefinition.AnimatedProperty.IsAttached)
                {
                    var dp = DependencyPropertySystem.FindByStylingName(animatedPropertyName, ownerType);
                    if (dp != null)
                    {
                        animatedPropertyType = dp.PropertyType;
                        animatedPropertyName = dp.Name;
                    }
                }
                else
                {
                    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 animationDependencyName = new DependencyName(animationDefinition.AnimatedProperty.IsAttached ?
                                                                 $"{animationDefinition.AnimatedProperty.Owner}.{animatedPropertyName}" : animatedPropertyName);
                var animationKey = new StoryboardTargetAnimationKey(animationDependencyName, navigationExpression);
                var animation    = InstantiateStoryboardAnimation(animationDefinition, animatedPropertyType);
                if (animation != null)
                {
                    target.Animations.Add(animationKey, animation);
                }
            }

            return(target);
        }