コード例 #1
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 );
        }
コード例 #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);
        }
コード例 #3
0
 /// <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);
            }
        }
コード例 #5
0
        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);
コード例 #8
0
 public void Run(IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration)
 {
     Run(context, control, duration, null);
 }
コード例 #9
0
 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);