public override void Run( IAnimationContext context, Control control, TimeSpan duration, Action<Control> endMethod) { var storyboard = new Storyboard(); DoubleAnimation fadeAnimation; if ( rounds > 1 ) { fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) ); fadeAnimation.AutoReverse = true; fadeAnimation.RepeatBehavior = new RepeatBehavior( rounds - 1 ); storyboard.Children.Add( fadeAnimation ); Storyboard.SetTarget( fadeAnimation, control ); Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) ); } fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) ); fadeAnimation.BeginTime = TimeSpan.FromMilliseconds( duration.TotalMilliseconds * ( rounds - 1 ) * 2 ); storyboard.Children.Add( fadeAnimation ); Storyboard.SetTarget( fadeAnimation, control ); Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) ); if ( endMethod != null ) storyboard.Completed += ( s, a ) => endMethod( control ); storyboard.Begin( control ); }
public override void Run( IAnimationContext context, Control control, TimeSpan duration, Action <Control> endMethod) { var storyboard = new Storyboard(); DoubleAnimation fadeAnimation; if (rounds > 1) { fadeAnimation = new DoubleAnimation(startOpacity, endOpacity, new Duration(duration)); fadeAnimation.AutoReverse = true; fadeAnimation.RepeatBehavior = new RepeatBehavior(rounds - 1); storyboard.Children.Add(fadeAnimation); Storyboard.SetTarget(fadeAnimation, control); Storyboard.SetTargetProperty(fadeAnimation, new PropertyPath(UIElement.OpacityProperty)); } fadeAnimation = new DoubleAnimation(startOpacity, endOpacity, new Duration(duration)); fadeAnimation.BeginTime = TimeSpan.FromMilliseconds(duration.TotalMilliseconds * (rounds - 1) * 2); storyboard.Children.Add(fadeAnimation); Storyboard.SetTarget(fadeAnimation, control); Storyboard.SetTargetProperty(fadeAnimation, new PropertyPath(UIElement.OpacityProperty)); if (endMethod != null) { storyboard.Completed += (s, a) => endMethod(control); } storyboard.Begin(control); }
/// <summary> /// Runs the transition. /// </summary> /// <param name="transition">Transition handler.</param> /// <param name="context">The context of the transition.</param> /// <param name="control">The control which the transition should be run on.</param> /// <param name="duration">The duration of the transition.</param> public static void Run( [NotNull] this ITransition transition, [NotNull] IAnimationContext context, [NotNull] Control control, TimeSpan duration) { if (transition is null) { throw new ArgumentNullException(nameof(transition)); } transition.Run(context, control, duration, null); }
/// <inheritdoc /> public void Animate( IAnimationContext context, System.Windows.Controls.Control control, double x, double y, TimeSpan duration) { if (!double.IsNaN(x)) { double from = GraphCanvas.GetX(control); from = double.IsNaN(from) ? 0.0 : from; // Create the animation for the horizontal position var animationX = new DoubleAnimation( from, x, duration, FillBehavior.HoldEnd); animationX.Completed += (s, e) => { control.BeginAnimation(GraphCanvas.XProperty, null); control.SetValue(GraphCanvas.XProperty, x); }; control.BeginAnimation(GraphCanvas.XProperty, animationX, HandoffBehavior.Compose); } if (!double.IsNaN(y)) { double from = GraphCanvas.GetY(control); from = (double.IsNaN(from) ? 0.0 : from); // Create an animation for the vertical position var animationY = new DoubleAnimation( from, y, duration, FillBehavior.HoldEnd); animationY.Completed += (s, e) => { control.BeginAnimation(GraphCanvas.YProperty, null); control.SetValue(GraphCanvas.YProperty, y); }; control.BeginAnimation(GraphCanvas.YProperty, animationY, HandoffBehavior.Compose); } }
public void Animate( IAnimationContext context, System.Windows.Controls.Control control, double x, double y, TimeSpan duration ) { if ( !double.IsNaN( x ) ) { double from = GraphCanvas.GetX( control ); from = double.IsNaN( from ) ? 0.0 : from; //create the animation for the horizontal position var animationX = new DoubleAnimation( from, x, duration, FillBehavior.HoldEnd ); animationX.Completed += ( s, e ) => { control.BeginAnimation( GraphCanvas.XProperty, null ); control.SetValue( GraphCanvas.XProperty, x ); }; control.BeginAnimation( GraphCanvas.XProperty, animationX, HandoffBehavior.Compose ); } if ( !double.IsNaN( y ) ) { double from = GraphCanvas.GetY( control ); from = ( double.IsNaN( from ) ? 0.0 : from ); //create an animation for the vertical position var animationY = new DoubleAnimation( from, y, duration, FillBehavior.HoldEnd ); animationY.Completed += ( s, e ) => { control.BeginAnimation( GraphCanvas.YProperty, null ); control.SetValue( GraphCanvas.YProperty, y ); }; control.BeginAnimation( GraphCanvas.YProperty, animationY, HandoffBehavior.Compose ); } }
public void Run( IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration ) { Run( context, control, duration, null ); }
public abstract void Run( IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration, Action<System.Windows.Controls.Control> endMethod);
public void Run(IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration) { Run(context, control, duration, null); }
public abstract void Run(IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration, Action <System.Windows.Controls.Control> endMethod);
public abstract void Run(IAnimationContext context, Control control, TimeSpan duration, Action <Control> endMethod);
public void Run(IAnimationContext context, Control control, TimeSpan duration) { Run(context, control, duration, null); }
public void Run(IAnimationContext context, Control control, TimeSpan duration) { Run( context, control, duration, null ); }
public abstract void Run(IAnimationContext context, Control control, TimeSpan duration, Action<Control> endMethod);