private static object ConvertValueFromString(Type valueType, string value) { if (value == null) { return(null); } //convert value using calculator AnimationValueCalculator calc = AnimationValueCalculatorFactory.GetCalculator(valueType); return(calc.ConvertToAnimationStepFromString(value)); }
public static string ConvertValueToString(object value) { if (value == null) { return(null); } Type valueType = value.GetType(); //convert value using calculator AnimationValueCalculator calc = AnimationValueCalculatorFactory.GetCalculator(valueType); return(calc.ConvertAnimationStepToString(value)); }
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); } } }
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); }
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); }
public void Initialize(RadObject element, object initialValue) { this.startValue = initialValue; this.value = initialValue; if (this.setting.EndValue == null && this.setting.Step == null) { throw new InvalidOperationException("Error calculating animation properties: EndValue and Step are not specified for property '" + this.setting.Property.FullName + "' "); } this.calculator = AnimationValueCalculatorFactory.GetCalculator(this.setting.Property.PropertyType); if (this.calculator == null) { throw new Exception("Error calculating animation step because there is not any calculator for type '" + (object)this.setting.Property.PropertyType + "' registered."); } if (this.setting.EndValue == null) { this.setting.EndValue = this.calculator.CalculateAnimationEndValue(this.startValue, this.setting.Step, this.setting.NumFrames); } this.step = this.setting.Step != null ? this.setting.Step : this.calculator.CalculateAnimationStep(this.startValue, this.setting.EndValue, this.setting.NumFrames); this.easingCalculator.EasingType = this.setting.ApplyEasingType; }
public static AnimationValueCalculator GetCalculator(Type objectType) { Type actualStepType = GetRegisteredTypeFromStepType(objectType); if (actualStepType == null) { actualStepType = objectType; } Type resType = (Type)registeredCalculators[actualStepType]; if (resType == null) { return(null); } AnimationValueCalculator res = (AnimationValueCalculator)Activator.CreateInstance(resType); res.AssociatedType = actualStepType; return(res); }
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."); } }