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 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);
        }
Example #3
0
        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 static AnimationRate Plus(AnimationRate animationRate)
 {
     return(animationRate);
 }
 public AnimationRate Subtract(AnimationRate animationRate)
 {
     return(this - animationRate);
 }
 public static bool Equals(AnimationRate t1, AnimationRate t2)
 {
     return(t1.Equals(t2));
 }
 public AnimationRate Add(AnimationRate animationRate)
 {
     return(this + animationRate);
 }