Ejemplo n.º 1
0
        private static bool ValidateFromToOrByValue(object value)
        {
            CornerRadius?nullable = (CornerRadius?)value;

            if (nullable.HasValue)
            {
                return(AnimationHelpers.IsValidAnimationValueCornerRadius(nullable.Value));
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates a value that represents the current value of the property being animated, as determined by the <see cref="T:System.Windows.Media.Animation.ThicknessAnimation"/>.
        /// </summary>
        ///
        /// <returns>
        /// The calculated value of the property, as determined by the current animation.
        /// </returns>
        /// <param name="defaultOriginValue">The suggested origin value, used if the animation does not have its own explicitly set start value.</param><param name="defaultDestinationValue">The suggested destination value, used if the animation does not have its own explicitly set end value.</param><param name="animationClock">An <see cref="T:System.Windows.Media.Animation.AnimationClock"/> that generates the <see cref="P:System.Windows.Media.Animation.Clock.CurrentTime"/> or <see cref="P:System.Windows.Media.Animation.Clock.CurrentProgress"/> used by the animation.</param>
        protected override CornerRadius GetCurrentValueCore(CornerRadius defaultOriginValue, CornerRadius defaultDestinationValue, AnimationClock animationClock)
        {
            if (!this._isAnimationFunctionValid)
            {
                this.ValidateAnimationFunction();
            }
            double          num1           = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = this.EasingFunction;

            if (easingFunction != null)
            {
                num1 = easingFunction.Ease(num1);
            }
            var  from       = new CornerRadius();
            var  to         = new CornerRadius();
            var  thickness1 = new CornerRadius();
            var  thickness2 = new CornerRadius();
            bool flag1      = false;
            bool flag2      = false;

            switch (this._AnimationMode)
            {
            case AnimationMode.Automatic:
                from  = defaultOriginValue;
                to    = defaultDestinationValue;
                flag1 = true;
                flag2 = true;
                break;

            case AnimationMode.From:
                from  = this._keyValues[0];
                to    = defaultDestinationValue;
                flag2 = true;
                break;

            case AnimationMode.To:
                from  = defaultOriginValue;
                to    = this._keyValues[0];
                flag1 = true;
                break;

            case AnimationMode.By:
                to         = this._keyValues[0];
                thickness2 = defaultOriginValue;
                flag1      = true;
                break;

            case AnimationMode.FromTo:
                from = this._keyValues[0];
                to   = this._keyValues[1];
                if (this.IsAdditive)
                {
                    thickness2 = defaultOriginValue;
                    flag1      = true;
                    break;
                }
                break;

            case AnimationMode.FromBy:
                from = this._keyValues[0];
                to   = AnimationHelpers.AddCornerRadius(this._keyValues[0], this._keyValues[1]);
                if (this.IsAdditive)
                {
                    thickness2 = defaultOriginValue;
                    flag1      = true;
                    break;
                }
                break;
            }
            if (flag1 && !AnimationHelpers.IsValidAnimationValueCornerRadius(defaultOriginValue))
            {
                throw new InvalidOperationException("Animation_Invalid_DefaultValue");
            }
            if (flag2 && !AnimationHelpers.IsValidAnimationValueCornerRadius(defaultDestinationValue))
            {
                throw new InvalidOperationException("Animation_Invalid_DefaultValue");
            }
            if (this.IsCumulative)
            {
                int?   currentIteration = animationClock.CurrentIteration;
                int    num2             = 1;
                double factor           = (double)(currentIteration.HasValue ? new int?(currentIteration.GetValueOrDefault() - num2) : new int?()).Value;
                if (factor > 0.0)
                {
                    thickness1 = AnimationHelpers.ScaleCornerRadius(AnimationHelpers.SubtractCornerRadius(to, from), factor);
                }
            }
            return(AnimationHelpers.AddCornerRadius(thickness2, AnimationHelpers.AddCornerRadius(thickness1, AnimationHelpers.InterpolateCornerRadius(from, to, num1))));
        }