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 );
        }
Пример #2
0
        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);
 }
Пример #4
0
        /// <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 );
            }
        }
Пример #6
0
 public void Run( IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration )
 {
     Run( context, control, duration, null );
 }
Пример #7
0
 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);
Пример #10
0
 public abstract void Run(IAnimationContext context,
                          Control control,
                          TimeSpan duration,
                          Action <Control> endMethod);
Пример #11
0
 public void Run(IAnimationContext context, Control control, TimeSpan duration)
 {
     Run(context, control, duration, null);
 }
Пример #12
0
 public void Run(IAnimationContext context, Control control, TimeSpan duration)
 {
     Run( context, control, duration, null );
 }
Пример #13
0
 public abstract void Run(IAnimationContext context, Control control, TimeSpan duration, Action<Control> endMethod);