示例#1
0
        internal async void ShowEditDeckNameDialog(Deck deck)
        {
            if (deck == null)
            {
                return;
            }
            var settings = new MessageDialogs.Settings {
                AffirmativeButtonText = "set", NegativeButtonText = "cancel", DefaultText = deck.Name
            };
            var newName = await DialogManager.ShowInputAsync(this, "Set deck name", "", settings);

            if (string.IsNullOrEmpty(newName) || deck.Name == newName)
            {
                return;
            }
            deck.Name = newName;
            deck.Edited();
            if (deck.DeckStats.Games.Any())
            {
                foreach (var game in deck.DeckStats.Games)
                {
                    game.DeckName = newName;
                }
                DeckStatsList.Save();
            }

            DeckList.Save();
            DeckPickerList.UpdateDecks();
        }
        internal async void ImportFromIdString()
        {
            try
            {
                var settings  = new MessageDialogs.Settings();
                var clipboard = Clipboard.ContainsText() ? Clipboard.GetText() : "";
                if (clipboard.Count(c => c == ':') > 0 && clipboard.Count(c => c == ';') > 0)
                {
                    settings.DefaultText = clipboard;
                }

                //import dialog
                var idString =
                    await
                    DialogManager.ShowInputAsync(this, "Import deck",
                                                 "id:count;id2:count2;... (e.g. EX1_050:2;EX1_556:1;)\nObtained from: \nEXPORT > COPY IDS TO CLIPBOARD",
                                                 settings);

                if (string.IsNullOrEmpty(idString))
                {
                    return;
                }
                var deck = new Deck();
                foreach (var entry in idString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var splitEntry = entry.Split(':');
                    if (splitEntry.Length != 2)
                    {
                        continue;
                    }
                    var card = Hearthstone.Database.GetCardFromId(splitEntry[0]);
                    if (card.Id == "UNKNOWN")
                    {
                        continue;
                    }
                    int.TryParse(splitEntry[1], out var count);
                    card.Count = count;

                    if (string.IsNullOrEmpty(deck.Class) && card.GetPlayerClass != "Neutral")
                    {
                        deck.Class = card.GetPlayerClass;
                    }

                    deck.Cards.Add(card);
                }
                if (Config.Instance.AutoSaveOnImport)
                {
                    DeckManager.SaveDeck(deck);
                }
                else
                {
                    ShowDeckEditorFlyout(deck, true);
                }
            }
            catch (Exception ex)
            {
                Log.Info("Error importing deck from clipboard(id string): " + ex);
            }
        }
示例#3
0
        internal async void ShowDeleteDecksMessage(IEnumerable <Deck> decks)
        {
            if (decks == null)
            {
                return;
            }
            var decksList = decks.ToList();

            if (!decksList.Any())
            {
                return;
            }

            var settings = new MessageDialogs.Settings {
                AffirmativeButtonText = "Yes", NegativeButtonText = "No"
            };
            var keepStatsInfo = Config.Instance.KeepStatsWhenDeletingDeck
                                                    ? "The stats will be kept (can be changed in options)"
                                                    : "The stats will be deleted (can be changed in options)";
            var result =
                await
                DialogManager.ShowMessageAsync(this, "Deleting " + (decksList.Count == 1 ? decksList.First().Name : decksList.Count + " decks"),
                                               "Are you Sure?\n" + keepStatsInfo, MessageDialogStyle.AffirmativeAndNegative, settings);

            if (result == MessageDialogResult.Negative)
            {
                return;
            }
            foreach (var deck in decksList)
            {
                DeleteDeck(deck, false);
            }
            DeckStatsList.Save();
            DeckList.Save();
            DeckPickerList.UpdateDecks();
            DeckPickerList.UpdateArchivedClassVisibility();
            DeckManagerEvents.OnDeckDeleted.Execute(decksList);
        }