Exemple #1
0
        public override void ApplyValue(RadElement element)
        {
            if (this.ApplyDelay > 0)
            {
                //we have an initial delay that we should reflect
                Timer timer = new Timer();
                timer.Interval = this.ApplyDelay;
                timer.Tick    += new EventHandler(delayTimer_Tick);
                timer.Tag      = element;

                delayTimerForElement[element.GetHashCode()] = timer;
                timer.Start();

                object animatedValue = this.StartValue;
                if (animatedValue != null)
                {
                    ElementValuesAnimator animator = this.GetAnimator(element);
                    animator.SetCurrentValue(animatedValue);
                    this.OnAnimationStarted(new AnimationStatusEventArgs(element, false));
                }
            }
            else
            {
                ApplyValueInternal(element);
            }
        }
Exemple #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);
        }