예제 #1
0
        public override Rect GetNextChildPlacement(UIElement child, TimeSpan currentTime,
                                                   Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout,
                                                   AnimationRate animationRate, ref object placementArgs, out bool isDone)
        {
            var result = targetPlacement;

            isDone = true;
            if (_equation is not null)
            {
                var from     = (Rect)placementArgs;
                var duration = animationRate.Duration;
                isDone = currentTime >= duration;
                if (!isDone)
                {
                    var x     = _equation.Evaluate(currentTime, from.Left, targetPlacement.Left, duration);
                    var y     = _equation.Evaluate(currentTime, from.Top, targetPlacement.Top, duration);
                    var width = Math.Max(0,
                                         _equation.Evaluate(currentTime, from.Width, targetPlacement.Width, duration));
                    var height = Math.Max(0,
                                          _equation.Evaluate(currentTime, from.Height, targetPlacement.Height, duration));
                    result = new Rect(x, y, width, height);
                }
            }

            return(result);
        }
예제 #2
0
 public abstract Rect GetInitialChildPlacement(
     UIElement child,
     Rect currentPlacement,
     Rect targetPlacement,
     AnimationPanel activeLayout,
     ref AnimationRate animationRate,
     out object placementArgs,
     out bool isDone);
예제 #3
0
 public abstract Rect GetNextChildPlacement(
     UIElement child,
     TimeSpan currentTime,
     Rect currentPlacement,
     Rect targetPlacement,
     AnimationPanel activeLayout,
     AnimationRate animationRate,
     ref object placementArgs,
     out bool isDone);
 public override Rect GetInitialChildPlacement(UIElement child, Rect currentPlacement,
                                               Rect targetPlacement, AnimationPanel activeLayout, ref AnimationRate animationRate,
                                               out object placementArgs, out bool isDone)
 {
     isDone = (animationRate.HasSpeed && animationRate.Speed <= 0) || (animationRate.HasDuration && animationRate.Duration.Ticks == 0);
     if (!isDone)
     {
         Vector startVector    = new Vector(currentPlacement.Left + (currentPlacement.Width / 2), currentPlacement.Top + (currentPlacement.Height / 2));
         Vector finalVector    = new Vector(targetPlacement.Left + (targetPlacement.Width / 2), targetPlacement.Top + (targetPlacement.Height / 2));
         Vector distanceVector = startVector - finalVector;
         animationRate = new AnimationRate(animationRate.HasDuration ? animationRate.Duration
                                 : TimeSpan.FromMilliseconds(distanceVector.Length / animationRate.Speed));
     }
     placementArgs = currentPlacement;
     return(currentPlacement);
 }
예제 #5
0
 public override Rect GetNextChildPlacement(UIElement child, TimeSpan currentTime, Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout, AnimationRate animationRate, ref object placementArgs, out bool isDone)
 {
     throw new InvalidOperationException(ErrorMessages.GetMessage(ErrorMessages.DefaultAnimatorCantAnimate));
 }