Пример #1
0
        public override Storyboard GetAnimationStoryboard(string propertyToAnimate, AnimationTriggerValue triggerValue, GridLength newValue, GridLength oldValue)
        {
            GridAnimation animation = new GridAnimation()
            {
                To =
                    triggerValue == AnimationTriggerValue.Start || triggerValue == AnimationTriggerValue.Unset ? newValue : oldValue,

                From =
                    triggerValue == AnimationTriggerValue.Start || triggerValue == AnimationTriggerValue.Unset ? oldValue : newValue,

                Duration =
                    triggerValue == AnimationTriggerValue.Unset ? TimeSpan.FromSeconds(0.3) : TimeSpan.FromSeconds(0.18),

                AccelerationRatio =
                    triggerValue == AnimationTriggerValue.Unset ? 0.3 : 0.7,

                EasingFunction =
                    new QuarticEase()
            };

            Storyboard.SetTargetProperty(animation, new PropertyPath(propertyToAnimate));

            Storyboard animationStoryboard = new Storyboard();

            animationStoryboard.Children.Add(animation);

            return(animationStoryboard);
        }
Пример #2
0
 /// <summary>
 /// Get stortyboard for animation
 /// </summary>
 /// <param name="propertyToAnimate"></param>
 /// <param name="newValue"></param>
 /// <param name="oldValue"></param>
 /// <returns></returns>
 public abstract Storyboard GetAnimationStoryboard(DependencyObject element, string propertyToAnimate, AnimationTriggerValue triggerValue, Property newValue, Property oldValue);
Пример #3
0
 /// <summary>
 /// Check if element is FrameworkElement or FrameworkContentElement
 /// </summary>
 /// <returns></returns>
 public void GetAnimationStoryboardWithOldValueAndStart(DependencyObject element, string propertyToAnimate, AnimationTriggerValue triggerValue,
                                                        Property newValue, Property oldValue)
 {
     if (element is FrameworkElement)
     {
         GetAnimationStoryboard(element, propertyToAnimate, triggerValue, newValue, oldValue).Begin(element as FrameworkElement);
     }
     else if (element is FrameworkContentElement)
     {
         GetAnimationStoryboard(element, propertyToAnimate, triggerValue, newValue, oldValue).Begin(element as FrameworkContentElement);
     }
     else
     {
         throw new ArgumentException("Element type must be FrameworkElement or FrameworkContentElement");
     }
 }
Пример #4
0
 /// <summary>
 /// Sets attached property with animation trigger
 /// </summary>
 /// <param name="animationPropertyProperty">The element to get the property from</param>
 /// <param name="value">New value</param>
 public static void SetAnimationTrigger(DependencyObject d, AnimationTriggerValue value) =>
 d.SetValue(AnimationTriggerProperty, value);
Пример #5
0
 /// <summary>
 /// Reverse <see cref="AnimationTriggerValue"/>
 /// If value set to Start it changes to StartReverce
 /// If value set to StartReverce it changes to Start
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static AnimationTriggerValue ReverceAnimationTriggerValue(AnimationTriggerValue value) =>
 value == AnimationTriggerValue.Start ? AnimationTriggerValue.StartReverce : AnimationTriggerValue.Start;
Пример #6
0
 /// <summary>
 /// Get stortyboard for animation
 /// </summary>
 /// <param name="propertyToAnimate"></param>
 /// <param name="newValue"></param>
 /// <param name="oldValue"></param>
 /// <returns></returns>
 public abstract Storyboard GetAnimationStoryboard(string propertyToAnimate, AnimationTriggerValue triggerValue, Property newValue, Property oldValue);