Exemplo n.º 1
0
        private void OnAnimationNotify(IAdornerAnimation sender, AdornerAnimationNotification eventArg)
        {
            if (!this.ShouldNotify())
            {
                return;
            }
            AdornerAnimation adornerAnimation = (AdornerAnimation)sender;

            if (eventArg == AdornerAnimationNotification.AnimationComplete)
            {
                adornerAnimation.Stop();
                adornerAnimation.AnimationEventHandlers -= new Action <IAdornerAnimation, AdornerAnimationNotification>(this.OnAnimationNotify);
                this.activeAnimations.Remove(adornerAnimation);
                adornerAnimation.Dispose();
            }
            else
            {
                if (eventArg != AdornerAnimationNotification.AnimationTick)
                {
                    return;
                }
                this.InvalidateRender();
                this.Update();
            }
        }
Exemplo n.º 2
0
        public void StartAnimation(string name, double duration, bool reverse, Action <IAdornerAnimation, AdornerAnimationNotification> listener)
        {
            double           startLerpValue    = reverse ? 1.0 : 0.0;
            double           endLerpValue      = reverse ? 0.0 : 1.0;
            AdornerAnimation adornerAnimation1 = Enumerable.FirstOrDefault <AdornerAnimation>((IEnumerable <AdornerAnimation>) this.activeAnimations, (Func <AdornerAnimation, bool>)(item => item.Name == name));

            if (adornerAnimation1 != null)
            {
                startLerpValue = adornerAnimation1.LerpValue;
                adornerAnimation1.Stop();
                adornerAnimation1.Dispose();
                this.activeAnimations.Remove(adornerAnimation1);
            }
            AdornerAnimation adornerAnimation2 = new AdornerAnimation(this, name, duration, startLerpValue, endLerpValue);

            adornerAnimation2.AnimationEventHandlers += new Action <IAdornerAnimation, AdornerAnimationNotification>(this.OnAnimationNotify);
            if (listener != null)
            {
                adornerAnimation2.AnimationEventHandlers += listener;
            }
            this.activeAnimations.Add(adornerAnimation2);
            adornerAnimation2.Start();
        }