Exemplo n.º 1
0
        private async void BtnAddNewGame_Click(object sender, RoutedEventArgs e)
        {
            if (_deck == null)
            {
                return;
            }
            var dialog = new AddGameDialog(_deck);
            await
            Helper.MainWindow.ShowMetroDialogAsync(dialog,
                                                   new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" });

            var game = await dialog.WaitForButtonPressAsync();

            await Helper.MainWindow.HideMetroDialogAsync(dialog);

            if (game != null)
            {
                _deck.DeckStats.AddGameResult(game);
                if (Config.Instance.HearthStatsAutoUploadNewGames)
                {
                    if (game.GameMode == GameMode.Arena)
                    {
                        HearthStatsManager.UploadArenaMatchAsync(game, _deck, true, true);
                    }
                    else
                    {
                        HearthStatsManager.UploadMatchAsync(game, _deck.GetSelectedDeckVersion(), true, true);
                    }
                }
                Refresh();
            }
            DeckStatsList.Save();
            Helper.MainWindow.DeckPickerList.UpdateDecks(forceUpdate: new[] { _deck });
        }
        public static async Task <bool> ShowAddGameDialog(this MetroWindow window, Deck deck)
        {
            if (deck == null)
            {
                return(false);
            }
            var dialog = new AddGameDialog(deck);
            await window.ShowMetroDialogAsync(dialog, new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" });

            var game = await dialog.WaitForButtonPressAsync();

            await window.HideMetroDialogAsync(dialog);

            if (game == null)
            {
                return(false);
            }
            deck.DeckStats.AddGameResult(game);
            if (Config.Instance.HearthStatsAutoUploadNewGames)
            {
                if (game.GameMode == GameMode.Arena)
                {
                    HearthStatsManager.UploadArenaMatchAsync(game, deck, true, true).Forget();
                }
                else
                {
                    HearthStatsManager.UploadMatchAsync(game, deck.GetSelectedDeckVersion(), true, true).Forget();
                }
            }
            DeckStatsList.Save();
            Core.MainWindow.DeckPickerList.UpdateDecks(forceUpdate: new[] { deck });
            return(true);
        }
        public static async Task <bool> ShowEditGameDialog(this MetroWindow window, GameStats game)
        {
            if (game == null)
            {
                return(false);
            }
            var dialog = new AddGameDialog(game);
            await window.ShowMetroDialogAsync(dialog, new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" });

            var result = await dialog.WaitForButtonPressAsync();

            await window.HideMetroDialogAsync(dialog);

            if (result == null)
            {
                return(false);
            }
            DeckStatsList.Save();
            Core.MainWindow.DeckPickerList.UpdateDecks();
            return(true);
        }
        public static async Task <bool> ShowAddGameDialog(this MetroWindow window, Deck deck)
        {
            if (deck == null)
            {
                return(false);
            }
            var dialog = new AddGameDialog(deck);
            await window.ShowMetroDialogAsync(dialog, new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" });

            var game = await dialog.WaitForButtonPressAsync();

            await window.HideMetroDialogAsync(dialog);

            if (game == null)
            {
                return(false);
            }
            deck.DeckStats.AddGameResult(game);
            DeckStatsList.Save();
            Core.MainWindow.DeckPickerList.UpdateDecks(forceUpdate: new[] { deck });
            return(true);
        }
Exemplo n.º 5
0
        private async void EditGame(GameStats game)
        {
            if (game == null)
            {
                return;
            }

            var dialog = new AddGameDialog(game);
            await
            Helper.MainWindow.ShowMetroDialogAsync(dialog,
                                                   new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" });

            var result = await dialog.WaitForButtonPressAsync();

            await Helper.MainWindow.HideMetroDialogAsync(dialog);

            if (result == null)            //cancelled
            {
                return;
            }
            Refresh();
            if (Config.Instance.HearthStatsAutoUploadNewGames && HearthStatsAPI.IsLoggedIn)
            {
                var deck = DeckList.Instance.Decks.FirstOrDefault(d => d.DeckId == game.DeckId);
                if (deck != null)
                {
                    if (game.GameMode == GameMode.Arena)
                    {
                        HearthStatsManager.UpdateArenaMatchAsync(game, deck, true, true);
                    }
                    else
                    {
                        HearthStatsManager.UpdateMatchAsync(game, deck.GetVersion(game.PlayerDeckVersion), true, true);
                    }
                }
            }
            DeckStatsList.Save();
            Helper.MainWindow.DeckPickerList.UpdateDecks();
        }