Ejemplo n.º 1
0
        async void debuggingCheckBox_Click(object sender, RoutedEventArgs e)
        {
            bool?debugging = debuggingCheckBox.IsChecked;

            Log.i(this, "Changed state of Debugging to " + debugging.ToString());
            Utility.SettingsSave("debug", debugging);

            //Offer the immediate change
            await PopupDialog.ShowPopupDialog
            (
                "Change will take place after next restart.\nDo you want to exit the game now?"
                , "Yes"
                , () =>
            {
                Utility.ExitGame(this);
            }
                , "No"
                , null
                , false
                , "Yes + schedule restart in 15 minutes"
                , async() =>
            {
                //Supposedly should be called before registering any background task, TODO: verify and integrate into schedule function
                await BackgroundExecutionManager.RequestAccessAsync();

                var restarter = BackgroundTask.ScheduleOneTime("GameRestarter", 15);
                Utility.ExitGame(this);
            }
            );
        }
Ejemplo n.º 2
0
        async void NewGameButton_Click(object sender, RoutedEventArgs e)
        {
            Log.i(this, "User clicked on New Game Button");
            string message = "Are you sure you want to start a new game?";

            if (GameRunning)
            {
                message += "\nYou will lose all of the current progress!";
            }
            await PopupDialog.ShowPopupDialog(message, "Yes, I am", () => ChangeScreen(typeof(GameRound)), "No, let me play", null);
        }
Ejemplo n.º 3
0
        async void DeletePlayerButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = PlayersComboBox.SelectedItem as Services.Entity.Player;

            if (selectedItem == null)
            {
                Log.e(this, "Selected player is null");
                return;
            }

            await PopupDialog.ShowPopupDialog
            (
                "Are you sure you want to delete player " + selectedItem.Name + "?"
                , "Sure"
                , () =>
            {
                using (var db = new Persistence())
                {
                    var players = db.Players;
                    if (players == null)
                    {
                        Log.e(this, "Players in Database returned null");
                        return;
                    }

                    var scores = db.Scores;

                    //Removes scores of the player
                    scores
                    .Where(score => score.Player.Id == selectedItem.Id)
                    .ToList()
                    .ForEach(score => scores.Remove(score));

                    //Removes the player
                    players.Remove(selectedItem);
                    db.SaveChanges();
                    UpdatePlayers(players);
                    Log.i(this, "Player removed");
                }
            }
                , "NO, it was a misclick!"
                , null
            );
        }
Ejemplo n.º 4
0
 //Exit Dialog implementation
 async Task ShowExitDialog()
 {
     await PopupDialog.ShowPopupDialog("Are you sure you don't want to keep playing?", "Yes, I am", () => ChangeScreen(typeof(MainMenu)), "No, let me play", null);
 }