NavigateToAppHome() публичный Метод

Navigates the app to the main page of the app.
public NavigateToAppHome ( bool stopCurrentGame = false ) : void
stopCurrentGame bool
Результат void
Пример #1
0
        private void Core_SaveRequested(object sender, SavingEventArgs e)
        {
            // Saves game (autosave).
            SavegameManager.SaveAuto();

            // If e.CloseAfterSave, close the game.
            if (e.CloseAfterSave)
            {
                // Wait for the engine to be done doing what it's doing.
                BeginRunOnIdle(() =>
                {
                    // Shows a message box for that.
                    System.Windows.MessageBox.Show("The cartridge has requested to be terminated. The game has been automatically saved, and you will now be taken back to the main menu of the app.", "The game is ending.", MessageBoxButton.OK);

                    // Back to app home.
                    NavigationManager.NavigateToAppHome(true);
                });
            }
        }
Пример #2
0
        /// <summary>
        /// Called when the app is being activated.
        /// </summary>
        /// <param name="isRecoveringFromTombstone"></param>
        public void HandleAppActivated(bool isRecoveringFromTombstone)
        {
            // Marks the session as being recovered from tombstone.
            HasRecoveredFromTombstone = isRecoveringFromTombstone;

            // If the app was tombstoned, goes back to app's home and show
            // a message.
            if (isRecoveringFromTombstone)
            {
                // When an app recovers from tombstone, an uncancellable
                // navigation occurs to display the last page on the stack.
                // Let us therefore alert the navigation manager about this
                // incoming navigation event.
                NavigationManager.PauseUntilNextNavigation();

                // Runs the following in a dispatcher frame because message boxes cannot
                // be displayed before the first navigation event in the app.
                App.Current.RootFrame.Dispatcher.BeginInvoke(() =>
                {
                    // Displays a message.
                    System.Windows.MessageBox.Show("Geowigo could not resume the game because the app was tombstoned by your phone.\n\n" +
                                                   "This is likely to happen when the app remains in the background for too long, or if your phone's battery is low.",
                                                   "Cannot resume game",
                                                   MessageBoxButton.OK);

                    // Schedules the app to navigate towards the app home
                    // once the tombstone recovery is over.
                    NavigationManager.NavigateToAppHome(true);
                });

                return;
            }

            // Resume the engine if it was paused.
            if (Model.Core.GameState == WF.Player.Core.Engines.EngineGameState.Paused)
            {
                Model.Core.Resume();
            }
        }
Пример #3
0
        /// <summary>
        /// Called when a game crashed. Displays a message and goes back home.
        /// </summary>
        /// <param name="crashMessageType"></param>
        /// <param name="exception"></param>
        /// <param name="cartridge"></param>
        public void HandleGameCrash(CrashMessageType crashMessageType, Exception exception, Cartridge cartridge)
        {
            // Prepares the message.
            StringBuilder sb = new StringBuilder();

            sb.Append("A problem occurred while ");
            switch (crashMessageType)
            {
            case CrashMessageType.NewGame:
                sb.Append("starting a new game");
                break;

            case CrashMessageType.Restore:
                sb.Append("restoring the saved game");
                break;

            case CrashMessageType.Runtime:
                sb.Append("running the game");
                break;

            default:
                sb.Append("running the game");
                break;
            }
            sb.Append(", therefore Geowigo cannot go on. This most likely happens because of a faulty cartridge");
            if (crashMessageType != CrashMessageType.NewGame)
            {
                sb.Append(" or savegame");
            }
            sb.Append(".\n\nIf the problem persists, you should contact Geowigo's developers (\"get support\" from the main menu) or the Cartridge owner, ");
            string cartFullAuthor = cartridge.GetFullAuthor();

            sb.Append(cartFullAuthor);
            AggregateException agex = exception as AggregateException;

            if (agex == null ||
                (agex != null && agex.InnerExceptions != null && agex.InnerExceptions.Count > 0))
            {
                sb.Append(", quoting the following error messages that were raised during the crash:");
                List <string> messages = new List <string>();
                if (agex == null)
                {
                    // In-depth dump of inner exception messages.
                    Exception curex = exception;
                    while (curex != null)
                    {
                        messages.Add(curex.Message);
                        curex = curex.InnerException;
                    }
                    messages.Reverse();
                }
                else
                {
                    foreach (Exception e in agex.InnerExceptions)
                    {
                        messages.Add(e.Message);
                    }
                }
                int i = messages.Count;
                foreach (string message in messages)
                {
                    sb.Append("\n" + i-- + "> " + message);
                }
            }
            else
            {
                sb.Append(".");
            }

            // Prepares the title.
            string caption = "";

            switch (crashMessageType)
            {
            case CrashMessageType.NewGame:
            case CrashMessageType.Restore:
                caption = "Cannot start game";
                break;

            case CrashMessageType.Runtime:
                caption = "Cartridge crashed";
                break;

            default:
                caption = "Game crash";
                break;
            }

            // Dump a log.
            DebugUtils.DumpException(exception, String.Format("Exception during play. Cartridge: {0} by {1}", cartridge.Name, cartFullAuthor), false);

            // Shows a message box.
            System.Windows.MessageBox.Show(
                sb.ToString(),
                caption,
                MessageBoxButton.OK
                );

            // Goes back!
            NavigationManager.NavigateToAppHome(true);
        }