Beispiel #1
0
        public bool Equals(AnimationRate animationRate)
        {
            if (this.HasDuration)
            {
                if (animationRate.HasDuration)
                {
                    return(_duration == animationRate._duration);
                }

                return(false);
            }
            else // HasSpeed
            {
                if (animationRate.HasSpeed)
                {
                    if (DoubleHelper.IsNaN(_speed))
                    {
                        return(DoubleHelper.IsNaN(animationRate._speed));
                    }

                    return(_speed == animationRate._speed);
                }

                return(false);
            }
        }
 public abstract Rect GetInitialChildPlacement(
   UIElement child,
   Rect currentPlacement,
   Rect targetPlacement,
   AnimationPanel activeLayout,
   ref AnimationRate animationRate,
   out object placementArgs,
   out bool isDone );
 public abstract Rect GetNextChildPlacement(
   UIElement child,
   TimeSpan currentTime,
   Rect currentPlacement,
   Rect targetPlacement,
   AnimationPanel activeLayout,
   AnimationRate animationRate,
   ref object placementArgs,
   out bool isDone );
Beispiel #4
0
        public static int Compare(AnimationRate t1, AnimationRate t2)
        {
            if (t1 < t2)
            {
                return(-1);
            }

            if (t1 > t2)
            {
                return(1);
            }

            // Neither is greater than the other
            return(0);
        }
 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;
 }
        public override object ConvertTo(
            ITypeDescriptorContext context,
            CultureInfo cultureInfo,
            object value,
            Type destinationType)
        {
            if (destinationType != null && value is AnimationRate)
            {
                AnimationRate rateValue = ( AnimationRate )value;

                if (destinationType == typeof(InstanceDescriptor))
                {
                    MemberInfo mi;
                    if (rateValue.HasDuration)
                    {
                        mi = typeof(AnimationRate).GetConstructor(new Type[] { typeof(TimeSpan) });
                        return(new InstanceDescriptor(mi, new object[] { rateValue.Duration }));
                    }
                    else if (rateValue.HasSpeed)
                    {
                        mi = typeof(AnimationRate).GetConstructor(new Type[] { typeof(double) });
                        return(new InstanceDescriptor(mi, new object[] { rateValue.Speed }));
                    }
                }
                else if (destinationType == typeof(string))
                {
                    return(rateValue.ToString());
                }
                else if (destinationType == typeof(double))
                {
                    return(rateValue.HasSpeed ? rateValue.Speed : 0.0d);
                }
                else if (destinationType == typeof(TimeSpan))
                {
                    return(rateValue.HasDuration ? rateValue.Duration : TimeSpan.FromSeconds(0));
                }
            }

            return(base.ConvertTo(context, cultureInfo, value, destinationType));
        }
 public override Rect GetNextChildPlacement( UIElement child, TimeSpan currentTime,
     Rect currentPlacement, Rect targetPlacement, AnimationPanel activeLayout,
     AnimationRate animationRate, ref object placementArgs, out bool isDone )
 {
   Rect result = targetPlacement;
   isDone = true;
   if( _equation != null )
   {
     Rect from = ( Rect )placementArgs;
     TimeSpan duration = animationRate.Duration;
     isDone = currentTime >= duration;
     if( !isDone )
     {
       double x = _equation.Evaluate( currentTime, from.Left, targetPlacement.Left, duration );
       double y = _equation.Evaluate( currentTime, from.Top, targetPlacement.Top, duration );
       double width = Math.Max( 0, _equation.Evaluate( currentTime, from.Width, targetPlacement.Width, duration ) );
       double height = Math.Max( 0, _equation.Evaluate( currentTime, from.Height, targetPlacement.Height, duration ) );
       result = new Rect( x, y, width, height );
     }
   }
   return result;
 }
 public static AnimationRate Plus( AnimationRate animationRate )
 {
   return animationRate;
 }
    public static int Compare( AnimationRate t1, AnimationRate t2 )
    {
      if( t1 < t2 )
        return -1;

      if( t1 > t2 )
        return 1;

      // Neither is greater than the other
      return 0;
    }
 public AnimationRate Subtract( AnimationRate animationRate )
 {
   return this - animationRate;
 }
 public static bool Equals( AnimationRate t1, AnimationRate t2 )
 {
   return t1.Equals( t2 );
 }
    public bool Equals( AnimationRate animationRate )
    {
      if( this.HasDuration )
      {
        if( animationRate.HasDuration )
          return _duration == animationRate._duration;

        return false;
      }
      else // HasSpeed
      {
        if( animationRate.HasSpeed )
        {
          if( DoubleHelper.IsNaN( _speed ) )
            return DoubleHelper.IsNaN( animationRate._speed );

          return _speed == animationRate._speed;
        }

        return false;
      }
    }
 public AnimationRate Add( AnimationRate animationRate )
 {
   return this + animationRate;
 }
Beispiel #14
0
 public static AnimationRate Plus(AnimationRate animationRate)
 {
     return(animationRate);
 }
 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 ) );
 }
Beispiel #16
0
 public AnimationRate Subtract(AnimationRate animationRate)
 {
     return(this - animationRate);
 }
Beispiel #17
0
 public static bool Equals(AnimationRate t1, AnimationRate t2)
 {
     return(t1.Equals(t2));
 }
Beispiel #18
0
 public AnimationRate Add(AnimationRate animationRate)
 {
     return(this + animationRate);
 }