Exemplo n.º 1
0
        private AnimationTimeline AddAnimationToStoryboard(Storyboard storyboard, ControlledAnimation controlledAnimation)
        {
            var animation = controlledAnimation.Animation;

            if (animation == null)
            {
                throw new ArgumentException("The property Animation of the controlled Animation is empty");
            }

            storyboard.Children.Add(animation);
            return(animation);
        }
Exemplo n.º 2
0
        private void SetStoryboardTargetProperty(ControlledAnimation controlledAnimation)
        {
            var animation = controlledAnimation.Animation;

            if (controlledAnimation.TargetProperty != null)
            {
                Storyboard.SetTargetProperty(animation, new PropertyPath(controlledAnimation.TargetProperty));
            }
            else
            {
                if (!controlledAnimation.TargetPropertyType.HasValue)
                {
                    throw new ArgumentException("No TargetProperty or TargetPropertyType provided");
                }

                switch (controlledAnimation.TargetPropertyType.Value)
                {
                case AnimationTargetPropertyType.Opacity:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)"));
                    break;

                case AnimationTargetPropertyType.ScaleX:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
                    break;

                case AnimationTargetPropertyType.ScaleY:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
                    break;

                case AnimationTargetPropertyType.SkewX:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"));
                    break;

                case AnimationTargetPropertyType.SkewY:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"));
                    break;

                case AnimationTargetPropertyType.Rotate:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"));
                    break;

                case AnimationTargetPropertyType.TranslateX:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"));
                    break;

                case AnimationTargetPropertyType.TranslateY:
                    Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
                    break;
                }
            }
        }