Ejemplo n.º 1
0
        public void NextTransition()
        {
            // Remember that the application has requested that we start:
            // - This is used to distinguish when we start the app with no transitions enabled vs.
            //   we start with some enabled and the User subsequently disables all of them.
            // - This enables the caller to call UpdateTransitionEnabled() to configure the
            //   TransitionController before calling NextTransition().

            _started = true;


            // Determine the next transition and tile to display.

            if ((_entries == null) || (_entries.Length <= 0))
            {
                return;
            }

            TransitionEntry entry = ChooseNextTransition();

            if (entry == null)
            {
                return;
            }

            Tile nextTile = entry.NextTile();


            // Update the selected tile.

            if (_currentSelectedTile != null)
            {
                _currentSelectedTile.IsSelected = false;
                _currentSelectedTile            = null;
            }

            if ((entry.Options & TransitionOptions.Select) != 0)
            {
                _currentSelectedTile            = nextTile;
                _currentSelectedTile.IsSelected = true;
            }


            // Update desaturation of all tiles:
            // - If this transition uses desaturation, desaturate all tiles except the nextTile.
            // - Otherwise, if we were using desaturation for previous transition, need to turn full
            //   saturation back on.

            switch (entry.DesaturationMode)
            {
            case TransitionDesaturationMode.None:
                foreach (var tile in _layoutManager.AllTiles)
                {
                    tile.IsDesaturated = false;

                    _transitionLibrary.ApplyDesaturation(
                        tile,
                        TransitionDesaturationMode.None);
                }

                break;

            case TransitionDesaturationMode.Regular:
                foreach (var tile in _layoutManager.AllTiles)
                {
                    tile.IsDesaturated = (tile != nextTile);

                    _transitionLibrary.ApplyDesaturation(
                        tile,
                        TransitionDesaturationMode.Regular);
                }

                break;

            case TransitionDesaturationMode.ColorFlashlight:
                if (!_isFlashlightEnabled)
                {
                    goto case TransitionDesaturationMode.Regular;
                }

                foreach (var tile in _layoutManager.AllTiles)
                {
                    tile.IsDesaturated = (tile != nextTile);

                    _transitionLibrary.ApplyDesaturation(
                        tile,
                        (tile == nextTile) ?
                        TransitionDesaturationMode.None :
                        TransitionDesaturationMode.ColorFlashlight);
                }

                break;
            }


            // Create the Transition and begin playing animations.

            Transition transition = entry.CreateTransition(nextTile.Frame);

            if (transition != null)
            {
                transition.TransitionFinished += Transition_TransitionFinished;
                transition.PlayAllAnimations();

                _currentTransition = transition;
            }
        }