private static void HandleEquationChanged(object sender, DependencyPropertyChangedEventArgs e) { PennerDoubleAnimation pda = sender as PennerDoubleAnimation; // cache method so we avoid lookup while animating pda._EasingMethod = typeof(PennerDoubleAnimation).GetMethod(e.NewValue.ToString()); }
/// <summary> /// Starts a PennerDoubleAnimation. /// </summary> /// <param name="element">The DependencyObject containing the property to be animated.</param> /// <param name="prop">The DependencyProperty to animate.</param> /// <param name="type">The PennerDoubleAnimation.Equations easing equation to use.</param> /// <param name="to">The target value.</param> /// <param name="durationMS">Duration of the animation, in milliseconds.</param> /// <param name="callbackFunc">Optional method to be called when animation completes.</param> /// <returns>The AnimationClock used to control the animation.</returns> public static AnimationClock AnimatePenner( DependencyObject element, DependencyProperty prop, PennerDoubleAnimation.Equations type, double to, int durationMS, EventHandler callbackFunc) { return AnimatePenner(element, prop, type, null, to, durationMS, callbackFunc); }
/// <summary> /// Starts a PennerDoubleAnimation. /// </summary> /// <param name="element">The DependencyObject containing the property to be animated.</param> /// <param name="prop">The DependencyProperty to animate.</param> /// <param name="type">The PennerDoubleAnimation.Equations easing equation to use.</param> /// <param name="from">Optional start value.</param> /// <param name="to">The target value.</param> /// <param name="durationMS">Duration of the animation, in milliseconds.</param> /// <param name="callbackFunc">Optional method to be called when animation completes.</param> /// <returns>The AnimationClock used to control the animation.</returns> public static AnimationClock AnimatePenner( DependencyObject element, DependencyProperty prop, PennerDoubleAnimation.Equations type, double? from, double to, int durationMS, EventHandler callbackFunc) { double defaultFrom = double.IsNaN((double)element.GetValue(prop)) ? 0 : (double)element.GetValue(prop); PennerDoubleAnimation anim = new PennerDoubleAnimation(type, from.GetValueOrDefault(defaultFrom), to); return Animate(element, prop, anim, durationMS, null, null, callbackFunc); }
/// <summary> /// Starts a PennerDoubleAnimation. /// </summary> /// <param name="element">The DependencyObject containing the property to be animated.</param> /// <param name="prop">The DependencyProperty to animate.</param> /// <param name="type">The PennerDoubleAnimation.Equations easing equation to use.</param> /// <param name="from">Optional start value.</param> /// <param name="to">The target value.</param> /// <param name="durationMS">Duration of the animation, in milliseconds.</param> /// <param name="callbackFunc">Optional method to be called when animation completes.</param> /// <returns>The AnimationClock used to control the animation.</returns> public static AnimationClock AnimatePenner( DependencyObject element, DependencyProperty prop, PennerDoubleAnimation.Equations type, double?from, double to, int durationMS, EventHandler callbackFunc) { double defaultFrom = double.IsNaN((double)element.GetValue(prop)) ? 0 : (double)element.GetValue(prop); PennerDoubleAnimation anim = new PennerDoubleAnimation(type, from.GetValueOrDefault(defaultFrom), to); return(Animate(element, prop, anim, durationMS, null, null, callbackFunc)); }