Esempio n. 1
0
        public void ReInitialize(RadElement element, object initialValue)
        {
            this.cachedStartValue  = initialValue;
            this.cachedEndValue    = this.setting.EndValue;
            this.value             = this.cachedStartValue;
            this.originalNumFrames = this.setting.NumFrames;
            this.numFrames         = this.setting.NumFrames;
            this.interval          = setting.Interval;
            this.step              = this.setting.Step;
            this.reverseStep       = this.setting.ReverseStep;
            this.animationLoopType = this.setting.AnimationLoopType;

            if (this.setting.AnimationType == RadAnimationType.ByStartEndValues)
            {
                if (this.step == null ||
                    this.setting.AnimationType == RadAnimationType.ByStartEndValues &&
                    (this.setting.StartValue == null ||
                     this.setting.StartValueIsCurrentValue)
                    )
                {
                    if (this.setting.EndValue == null)
                    {
                        throw new InvalidOperationException("Error calculating animation step: EndValue is not specified for property '" + this.setting.Property.FullName + "' ");
                    }

                    object startValue = this.CachedStartValue;

                    AnimationValueCalculator calculator = AnimationValueCalculatorFactory.GetCalculator(this.setting.Property.PropertyType);
                    if (calculator != null)
                    {
                        this.step        = calculator.CalculateAnimationStep(startValue, this.setting.EndValue, this.setting.NumFrames);
                        this.reverseStep = calculator.CalculateInversedStep(step);
                    }
                    else
                    {
                        throw new Exception("Error calculating animation step because there is not any calculator for type '" + this.setting.Property.PropertyType + "' registered.");
                    }
                }
            }

            if (this.reverseStep == null)
            {
                AnimationValueCalculator calculator = AnimationValueCalculatorFactory.GetCalculator(this.setting.Property.PropertyType);
                if (calculator != null)
                {
                    this.reverseStep = calculator.CalculateInversedStep(step);
                }
            }
        }
Esempio n. 2
0
        public AnimatedPropertySetting(RadProperty property, AnimationValueCalculator calculator, object animationStartValue, object animationEndValue, int numFrames, int interval)
        {
            base.Property                = property;
            this.interval                = interval;
            this.NumFrames               = numFrames;
            this.StartValue              = animationStartValue;
            this.EndValue                = animationEndValue;
            this.animationType           = RadAnimationType.ByStartEndValues;
            this.skipToEndValueOnReplace = true;

            this.calculator = calculator;


            if (calculator != null)
            {
                this.step        = calculator.CalculateAnimationStep(this.StartValue, this.EndValue, numFrames);
                this.reverseStep = calculator.CalculateInversedStep(step);
            }
            else
            {
                throw new Exception("Error calculating animation step because there is not any calculator for type '" + base.Property.PropertyType + "' registered.");
            }
        }