Ejemplo n.º 1
0
        protected void RunAnimation()
        {
            this.isAnimating = true;
            AnimatorBase animation = null;

            switch (this.currentAnimationType)
            {
            case TransitionDirection.ForwardIn:
                animation = this.GetAnimation(this.currentAnimationType, fromUri);
                break;

            case TransitionDirection.BackwardOut:
                animation = this.GetAnimation(this.currentAnimationType, this.arrivedFromUri);
                break;

            case TransitionDirection.BackwardIn:
                animation = this.GetAnimation(this.currentAnimationType, this.arrivedFromUri);
                break;

            default:
                animation = this.GetAnimation(this.currentAnimationType, this.nextUri);
                break;
            }

            this.Dispatcher.BeginInvoke(
                () =>
            {
                AnimatorBase transitionAnimation;
                if (animation == null)
                {
                    this.AnimationContext.Opacity = 1;
                    this.TransitionCompleted();
                }
                else
                {
                    transitionAnimation           = animation;
                    this.AnimationContext.Opacity = 1;
                    transitionAnimation.Begin(this.TransitionCompleted);
                }
            });
        }
Ejemplo n.º 2
0
        protected virtual AnimatorBase GetAnimation(TransitionDirection direction, Uri fromAddress)
        {
            var animationOverride = this.PageTransitions.FirstOrDefault(
                p => this.Matches(p.MatchUrl, fromAddress) || this.Matches(p.MatchUrl, this.nextUri));
            var style = this.DefaultTransition;

            if (animationOverride != null)
            {
                switch (direction)
                {
                case TransitionDirection.ForwardOut:
                    if (this.Matches(animationOverride.MatchUrl, this.nextUri))
                    {
                        style = animationOverride.NavigatingTo;
                    }
                    break;

                case TransitionDirection.ForwardIn:
                    if (this.Matches(animationOverride.MatchUrl, fromAddress))
                    {
                        style = animationOverride.NavigatedFrom;
                    }
                    break;

                case TransitionDirection.BackwardIn:
                    if (this.Matches(animationOverride.MatchUrl, fromAddress))
                    {
                        style = animationOverride.ReturningFrom;
                    }
                    break;
                }
            }

            AnimatorBase animation = this.GetAnimation(direction, style);

            animation.RootElement = this.AnimationContext;
            return(animation);
        }