public void ApplyValue(RadObject element) { this.RemovePreviousAnimation(element); if (!this.IsAnimationEnabled(element)) { this.OnAnimationStarted(new AnimationStatusEventArgs(element, false)); this.OnAnimationFinished(new AnimationStatusEventArgs(element, true, !this.RemoveAfterApply)); } else { ElementValuesAnimator animator = this.GetAnimator(element); animator.Initialize(element, this.startValue != null ? this.startValue : element.GetValue(this.Property)); if (this.RandomDelay != 0) { this.ApplyDelay = AnimatedPropertySetting.rand.Next(this.RandomDelay); } if (this.ApplyDelay > 0) { animator.Waiting = true; Timer timer = new Timer(); timer.Interval = this.ApplyDelay; timer.Tick += new EventHandler(this.delayTimer_Tick); timer.Tag = (object)element; timer.Start(); } else { this.OnAnimationStarted(new AnimationStatusEventArgs(element, false)); animator.Start(element); } } }
public override void UnapplyValue(RadElement element) { if (this.IsAnimationEnabled(element) && (this.AnimatorStyle & AnimatorStyles.AnimateWhenUnapply) == AnimatorStyles.AnimateWhenUnapply) { //Undo animation only if already aplied ElementValuesAnimator animator = element.ValuesAnimators[this.GetHashCode()] as ElementValuesAnimator; if (animator != null) { animator.Start(AnimationState.Reversing); } } else { OnAnimationFinished(new AnimationStatusEventArgs(element, false, false)); } }
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); }
private void delayTimer_Tick(object sender, EventArgs e) { Timer timer = (Timer)sender; RadObject tag = (RadObject)timer.Tag; timer.Tick -= new EventHandler(this.delayTimer_Tick); timer.Stop(); timer.Dispose(); ElementValuesAnimator valuesAnimator = tag.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator; if (valuesAnimator == null) { return; } valuesAnimator.Waiting = false; this.OnAnimationStarted(new AnimationStatusEventArgs(tag, false)); valuesAnimator.Start(tag); }
public void AppendValue( RadObject element, RadProperty property, object startValue, object endValue, int frames, int interval) { if (this.Property != property) { return; } this.StartValue = startValue; this.EndValue = endValue; this.NumFrames = frames; this.Interval = interval; ElementValuesAnimator animator = this.GetAnimator(element); animator.Stop(); animator.Initialize(element, this.StartValue); animator.Start(element); }