예제 #1
0
        private static void ApplyAnimation(this FrameworkElement element, AnimationSettings settings, Color from, Color to, string targetProperty, ref Storyboard storyboard)
        {
            var anim = new ColorAnimation()
            {
                From           = from,
                To             = to,
                Duration       = new Duration(TimeSpan.FromMilliseconds(settings.Duration)),
                BeginTime      = TimeSpan.FromMilliseconds(settings.Delay),
                EasingFunction = settings.GetEase()
            };

            element.ApplyAnimationCore(anim, settings, from.ToString(), to.ToString(), targetProperty, ref storyboard);
        }
        private static void ApplyAnimation(this FrameworkElement element, AnimationSettings settings, double from, double to, string targetProperty, ref Storyboard storyboard)
        {
            var anim = new DoubleAnimation()
            {
                From           = from,
                To             = to,
                Duration       = new Duration(TimeSpan.FromMilliseconds(settings.Duration)),
                BeginTime      = TimeSpan.FromMilliseconds(settings.Delay),
                EasingFunction = settings.GetEase()
            };

            Storyboard.SetTarget(anim, element);
            Storyboard.SetTargetProperty(anim, new PropertyPath(targetProperty));

            storyboard.Children.Add(anim);

            // If the element is ListBoxItem-based, we must check the logging property on its parent ListBox
            if (element is ListBoxItem &&
                element.FindAscendant <ListBox>() is ListBox lb &&
                Animations.GetEnableLogging(lb))
            {
                // Log for a ListBoxItem
                element.LogAnimationInfo(targetProperty, anim, settings);
            }