private PageScope GetPageScope(Uri pageUri)
        {
            string pageName = pageUri.ToNormalizedString();
            string prefix   = "/Views/";

            PageScope scope = PageScope.Unknown;

            if (pageName.StartsWith(prefix + "InputPage.xaml") ||
                pageName.StartsWith(prefix + "TaskPage.xaml") ||
                pageName.StartsWith(prefix + "ThingPage.xaml"))
            {
                scope = PageScope.Game;
            }
            else if (pageName.StartsWith(prefix + "HomePage.xaml") ||
                     pageName.StartsWith(prefix + "CartridgeInfoPage.xaml") ||
                     pageName.StartsWith(prefix + "SettingsPage.xaml") ||
                     pageName.StartsWith(prefix + "HelpPage.xaml"))
            {
                scope = PageScope.App;
            }
            else if (pageName.StartsWith(prefix + "CompassCalibrationPage.xaml") ||
                     pageName.StartsWith(prefix + "GameHomePage.xaml") ||
                     pageName.StartsWith(prefix + "GameMapPage.xaml") ||
                     pageName.StartsWith(prefix + "PlayerPage.xaml"))
            {
                scope = PageScope.GameExtra;
            }
            else if (pageName.StartsWith(prefix + "BetaLicensePage.xaml") ||
                     pageName.StartsWith("/FileTypeAssociation"))
            {
                scope = PageScope.OneShot;
            }

            return(scope);
        }
            private void ConformBackStack(Uri latestNavigatedUri)
            {
                // What is the scope of the latest navigated Uri?
                // Game -> Removes all non App entries before this one so that
                //		the page is the only Game page in the stack.
                //		(Wherigo spec)
                // GameExtra -> Do not change anything.
                // App -> Removes all entries up to and including the previous
                //		entry for this page only if the stack contains this.
                // Others -> Do not change anything.
                PageScope latestPageScope = _parent.GetPageScope(latestNavigatedUri);

                if (latestPageScope == PageScope.App)
                {
                    // If this is the home page, empties the whole back stack, in order
                    // to leave the home page as the root page of the app.
                    if (latestNavigatedUri.ToNormalizedString().StartsWith("/Views/HomePage.xaml"))
                    {
                        ClearBackStack();
                    }

                    // If the page Uri can be found in the back stack, clears entries up to and including the back stack.
                    else if (ClearBackStackFor(latestNavigatedUri))
                    {
                        _rootFrame.RemoveBackEntry();
                    }
                }
                else if (latestPageScope == PageScope.Game)
                {
                    foreach (JournalEntry entry in _rootFrame.BackStack.ToList())
                    {
                        // Removes the current entry if it is a game entry.
                        if (_parent.GetPageScope(entry.Source) == PageScope.Game)
                        {
                            // Removes the entry.
                            _rootFrame.RemoveBackEntry();
                        }
                        else
                        {
                            // Stop right here, we hit an App entry.
                            break;
                        }
                    }
                }

                // If the top of the stack is a OneShot page, remove it
                // now, since it may be the last time it's possible to do it.
                JournalEntry topEntry = _rootFrame.BackStack.FirstOrDefault();

                if (topEntry != null && _parent.GetPageScope(topEntry.Source) == PageScope.OneShot)
                {
                    _rootFrame.RemoveBackEntry();
                }
            }
        /// <summary>
        /// Determines if a page name corresponds to a view of the game.
        /// </summary>
        /// <param name="pageUri"></param>
        /// <returns></returns>
        public bool IsGameViewUri(Uri pageUri)
        {
            PageScope scope = GetPageScope(pageUri);

            return(scope == PageScope.Game || scope == PageScope.GameExtra);
        }