/// <summary>
        /// When the user cancels the main menu, ask if they want to exit the sample.
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            if ((ScreenManager.Game as HalfCakedGame).CurrentProfile.Name.Length < 1 && (ScreenManager.Game as HalfCakedGame).Device != null)
            {
                const string message = "You have currently unsaved game progress.\nWould you like to save before you exit?";
                MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message, new string[]{"Yes", "No", "Cancel"}, 0);

                confirmExitMessageBox.Buttons[0].Pressed += ConfirmSaveMessageBoxAccepted;
                confirmExitMessageBox.Buttons[1].Pressed += ConfirmExitMessageBoxAccepted;

                ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
            }
            else
            {
                const string message = "Are you sure you want to exit the game?";
                MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

                confirmExitMessageBox.Buttons[0].Pressed += ConfirmExitMessageBoxAccepted;

                ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
            }
        }
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this level?\n     All current progress will be lost.";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Buttons[0].Pressed += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
        public override void HandleInput(InputState input)
        {
            if (mReadingInput)
            {
                string text = input.GetTextSinceUpdate(ControllingPlayer);
                if (text.Length == 0)
                    return;

                if (text[text.Length - 1] == '\n')
                {
                    text = text.Remove(text.Length - 1);
                    mReadingInput = false;
                }

                if (text.Length > 0 && text[0] == '\b')
                {
                    if (mProfiles[mSelectedButton].Name.Length > 0)
                        mProfiles[mSelectedButton].Name = mProfiles[mSelectedButton].Name.Remove(mProfiles[mSelectedButton].Name.Length - 1) + text.Substring(1);
                    else
                        mProfiles[mSelectedButton].Name = text.Substring(1);
                }
                else
                    mProfiles[mSelectedButton].Name += text;

                Buttons[mSelectedButton].Text = mProfiles[mSelectedButton].Name;
                CreateDimensions();

                if (!mReadingInput)
                {
                    if (mProfiles[mSelectedButton].Name.Length < 1)
                        mProfiles[mSelectedButton].Name = " ";
                    ProfileSelectedButton(Buttons[mSelectedButton], null);

                    if (ProfileSaved != null)
                        ProfileSaved(this, new PlayerIndexEventArgs(ControllingPlayer.HasValue ? ControllingPlayer.Value : PlayerIndex.One));

                    mProfiles[mSelectedButton].Register();
                    ExitScreen();
                }
            }
            else
            {
                base.HandleInput(input);
                PlayerIndex pl;

                if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.Delete, ControllingPlayer, out pl))
                {
                    MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen("Are you sure you want to delete Profile:\n         " + mProfiles[mSelectedButton].Name);

                    confirmExitMessageBox.Buttons[0].Pressed += ConfirmExitMessageBoxAccepted;

                    ScreenManager.AddScreen(confirmExitMessageBox, pl);
                }
            }
        }
        void ProfileMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            var device = (ScreenManager.Game as HalfCakedGame).Device;
            GameScreen msgbox;
            if (device != null)
                msgbox = new ProfileScreen(device);
            else
                msgbox = new MessageBoxScreen("Unable to write to your documents folder. Cannot save profiles.", new string[]{"Ok"}, 0);

            ScreenManager.AddScreen(msgbox, null);
        }
        void TestButton(object sender, PlayerIndexEventArgs e)
        {
            ResolutionChange();
            (ScreenManager.Game as HalfCakedGame).UpdateGraphics();

            const string message = "Apply these settings?";
            MessageBoxScreen testMessageBox = new MessageBoxScreen(message);
            testMessageBox.Buttons[0].Pressed += new EventHandler<PlayerIndexEventArgs>(ApplySettings);
            testMessageBox.Buttons[1].Pressed += new EventHandler<PlayerIndexEventArgs>(RevertSettings);
            testMessageBox.Cancelled += new EventHandler<PlayerIndexEventArgs>(RevertSettings);
            ScreenManager.AddScreen(testMessageBox, e.PlayerIndex);
        }