Пример #1
0
        private object GetEndValue(RadObject element)
        {
            if (this.endValue != null)
            {
                return(this.endValue);
            }
            AnimationValueCalculator calculator = AnimationValueCalculatorFactory.GetCalculator(this.Property.PropertyType);
            EasingCalculator         calc       = (EasingCalculator) new StandardEasingCalculator(RadEasingType.InQuad);
            object currValue = this.StartValue;

            for (int currFrameNum = 1; currFrameNum <= this.NumFrames; ++currFrameNum)
            {
                currValue = calculator.CalculateAnimatedValue(this.StartValue, this.EndValue, currValue, this.step, currFrameNum, this.NumFrames, calc);
            }
            return(currValue);
        }
Пример #2
0
        private void ApplyValueInternal(RadElement element)
        {
            RemovePreviousAnimation(element, this.GetAnimatedSetting(element));

            ElementValuesAnimator animator = this.GetAnimator(element);

            animator.ReInitialize(element, this.GetInitialValue(element));

            //notify attached element for animation start event
            if (this.applyDelay <= 0)
            {
                this.OnAnimationStarted(new AnimationStatusEventArgs(element, false));
            }

            if (this.IsAnimationEnabled(element) && (this.AnimatorStyle & AnimatorStyles.AnimateWhenApply) == AnimatorStyles.AnimateWhenApply &&
                element.Visibility == ElementVisibility.Visible && element.ElementTree != null && element.ElementTree.Control.Visible)
            {
                animator.Start(AnimationState.Applying);
                return;
            }

            //we should animate the value, simply calculate the EndValue and apply it to the element.
            AnimationValueCalculator calculator = AnimationValueCalculatorFactory.GetCalculator(this.Property.PropertyType);
            object animatedValue;

            if (this.EndValue == null)
            {
                animatedValue = this.StartValue;
                if (animatedValue == null)
                {
                    animatedValue = animator.CachedStartValue;
                }
                for (int i = 1; i <= this.NumFrames; i++)
                {
                    animatedValue = calculator.CalculateAnimatedValue(this.StartValue, this.EndValue, animatedValue, this.Step, i, this.NumFrames, new StandardEasingCalculator(RadEasingType.InQuad));
                }
            }
            else
            {
                animatedValue = this.EndValue;
            }

            animator.SetCurrentValue(animatedValue);
            //notify for the value change
            this.OnValueApplied(element);
        }