Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        private ElementValuesAnimator CreateAnimator(RadElement element)
        {
            ElementValuesAnimator result = new ElementValuesAnimator(element, this);

            element.ValuesAnimators.Add(this.GetHashCode(), result);

            return(result);
        }
Exemplo n.º 4
0
        protected override void PropertySettingRemoving(RadObject targetRadObject)
        {
            ElementValuesAnimator animator = ((RadElement)targetRadObject).ValuesAnimators[this.GetHashCode()] as ElementValuesAnimator;

            if (animator != null)
            {
                animator.SettingRemoving();
            }
        }
Exemplo n.º 5
0
        public bool IsAnimating(RadObject element)
        {
            ElementValuesAnimator valuesAnimator = element.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator;

            if (valuesAnimator != null)
            {
                return(valuesAnimator.IsRunning);
            }
            return(false);
        }
Exemplo n.º 6
0
        private ElementValuesAnimator GetAnimator(RadObject element)
        {
            ElementValuesAnimator elementValuesAnimator = element.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator;

            if (elementValuesAnimator == null)
            {
                elementValuesAnimator = new ElementValuesAnimator(element, this);
                element.ValuesAnimators.Add((object)this.GetHashCode(), (object)elementValuesAnimator);
            }
            return(elementValuesAnimator);
        }
Exemplo n.º 7
0
        private ElementValuesAnimator GetAnimator(RadElement element)
        {
            ElementValuesAnimator result = element.ValuesAnimators[this.GetHashCode()] as ElementValuesAnimator;

            if (result == null)
            {
                result = CreateAnimator(element);
            }

            return(result);
        }
Exemplo n.º 8
0
        internal void RemovePreviousAnimation(RadElement element, AnimatedPropertySetting setting)
        {
            // Evtim: Added code to throw OnAnimationFinished when animation is changed with another one
            ElementValuesAnimator prevAnimator = setting != null?setting.GetExistingAnimator(element) : null;

            if (prevAnimator != null && prevAnimator.IsRunning)
            {
                setting.PropertySettingRemoving(element);
                setting.OnAnimationFinished(new AnimationStatusEventArgs(element, true, false));
            }
        }
Exemplo n.º 9
0
        public override void UnregisterValue(RadElement element)
        {
            int key = this.GetHashCode();

            ElementValuesAnimator animator = element.ValuesAnimators[key] as ElementValuesAnimator;

            if (animator != null)
            {
                animator.Stop();
                element.ValuesAnimators.Remove(key);
            }

            this.OnAnimationFinished(new AnimationStatusEventArgs(element, false, true));
        }
Exemplo n.º 10
0
        private void StopAnimation(RadObject element, bool cancel)
        {
            ElementValuesAnimator valuesAnimator = element.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator;

            if (valuesAnimator == null || !valuesAnimator.Waiting && !valuesAnimator.IsRunning)
            {
                return;
            }
            valuesAnimator.Stop();
            if (!cancel)
            {
                valuesAnimator.Value = this.GetEndValue(element);
            }
            this.OnAnimationFinished(new AnimationStatusEventArgs(element, true, !cancel && !this.RemoveAfterApply));
        }
Exemplo n.º 11
0
 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));
     }
 }
Exemplo n.º 12
0
 public void Stop(RadElement element)
 {
     if (this.RemoveDelayTimer(element))
     {
         this.OnAnimationFinished(new AnimationStatusEventArgs(element, true, true));
     }
     else
     {
         ElementValuesAnimator animator = this.GetExistingAnimator(element);
         if (animator != null && animator.IsRunning)
         {
             animator.Stop();
             this.OnAnimationFinished(new AnimationStatusEventArgs(element, true, true));
         }
     }
 }
Exemplo n.º 13
0
        private void RemovePreviousAnimation(RadObject element)
        {
            AnimatedPropertySetting currentAnimation = element.GetCurrentAnimation(this.Property);

            if (currentAnimation == null)
            {
                return;
            }
            ElementValuesAnimator valuesAnimator = element.ValuesAnimators[(object)currentAnimation.GetHashCode()] as ElementValuesAnimator;

            if (valuesAnimator == null || !valuesAnimator.IsRunning)
            {
                return;
            }
            valuesAnimator.Stop();
            currentAnimation.OnAnimationFinished(new AnimationStatusEventArgs(element, true, false));
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        public object GetCurrentValue(RadObject radObject)
        {
            if (!this.IsAnimationEnabled(radObject))
            {
                return(this.GetEndValue(radObject));
            }
            ElementValuesAnimator valuesAnimator = radObject.ValuesAnimators[(object)this.GetHashCode()] as ElementValuesAnimator;

            if (valuesAnimator == null)
            {
                return(this.endValue);
            }
            object obj = valuesAnimator.Value;

            if (this.ApplyEasingType == RadEasingType.OutElastic && obj != null && (this.maxValue != null && Convert.ToDouble(obj) > Convert.ToDouble(this.maxValue)))
            {
                return(this.maxValue);
            }
            return(obj);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
 public ValuesAnimatorApplyingState(ElementValuesAnimator animator)
     : base(animator)
 {
 }
Exemplo n.º 19
0
 /// <summary>
 /// Creates an instance of the <see cref="ValuesAnimatorState"/> class.
 /// </summary>
 /// <param name="animator"></param>
 public ValuesAnimatorState(ElementValuesAnimator animator)
 {
     this.animator = animator;
 }
Exemplo n.º 20
0
 public ValuesAnimatorReversingState(ElementValuesAnimator animator)
     : base(animator)
 {
 }
Exemplo n.º 21
0
        public override object GetCurrentValue(RadObject forObject)
        {
            ElementValuesAnimator animator = this.GetAnimator((RadElement)forObject);

            return(animator.GetCurrentValue());
        }
Exemplo n.º 22
0
 public ValuesAnimatorNotRunningState(ElementValuesAnimator animator)
     : base(animator)
 {
 }
Exemplo n.º 23
0
        public bool IsAnimating(RadElement element)
        {
            ElementValuesAnimator animator = GetExistingAnimator(element);

            return(animator != null ? animator.IsRunning : false);
        }