private async Task <Deck> ImportDeckFromWeb() { var settings = new MetroDialogSettings(); var clipboard = Clipboard.GetText(); var validUrls = new[] { "hearthstats", "hss.io", "hearthpwn", "hearthhead", "hearthstoneplayers", "tempostorm", "hearthstonetopdeck", "hearthnews.fr", "arenavalue", "hearthstone-decks" }; if (validUrls.Any(clipboard.Contains)) { settings.DefaultText = clipboard; } //import dialog var url = await this.ShowInputAsync("Import deck", "Supported websites:\n" + validUrls.Aggregate((x, next) => x + ", " + next), settings); if (string.IsNullOrEmpty(url)) { return(null); } var controller = await this.ShowProgressAsync("Loading Deck...", "please wait"); //var deck = await this._deckImporter.Import(url); var deck = await DeckImporter.Import(url); deck.Url = url; await controller.CloseAsync(); return(deck); }
private async void BtnWeb_Click(object sender, RoutedEventArgs e) { var settings = new MetroDialogSettings(); var clipboard = Clipboard.GetText(); var validUrls = new[] { "hearthstats", "hss.io", "hearthpwn", "hearthhead", "hearthstoneplayers", "tempostorm", "hearthstonetopdeck", "hearthnews.fr", "arenavalue" }; if (validUrls.Any(clipboard.Contains)) { settings.DefaultText = clipboard; } //import dialog var url = await Helper.MainWindow.ShowInputAsync("Import deck", "", settings); if (string.IsNullOrEmpty(url)) { return; } var controller = await Helper.MainWindow.ShowProgressAsync("Loading Deck...", "please wait"); //var deck = await Helper.MainWindow._deckImporter.Import(url); var deck = await DeckImporter.Import(url); await controller.CloseAsync(); if (deck != null) { var reimport = Helper.MainWindow.EditingDeck && Helper.MainWindow.NewDeck != null && Helper.MainWindow.NewDeck.Url == url; deck.Url = url; if (reimport) //keep old notes { deck.Note = Helper.MainWindow.NewDeck.Note; } if (!deck.Note.Contains(url)) { deck.Note = url + "\n" + deck.Note; } Helper.MainWindow.SetNewDeck(deck, reimport); } else { await Helper.MainWindow.ShowMessageAsync("Error", "Could not load deck from specified url"); } After_Click(); }
private async Task<Deck> ImportDeckFromURL(string url) { var controller = await this.ShowProgressAsync("Loading Deck...", "please wait"); //var deck = await this._deckImporter.Import(url); var deck = await DeckImporter.Import(url); if(deck != null) deck.Url = url; await controller.CloseAsync(); return deck; }
internal async void BtnUpdateDeck_Click(object sender, RoutedEventArgs e) { var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault(); if (selectedDeck == null || string.IsNullOrEmpty(selectedDeck.Url)) { return; } var deck = await DeckImporter.Import(selectedDeck.Url); if (deck == null) { await this.ShowMessageAsync("Error", "Could not load deck from specified url."); return; } //this could be expanded to check against the last version of the deck that was not modified after downloading if (deck.Cards.All(c1 => selectedDeck.GetSelectedDeckVersion().Cards.Any(c2 => c1.Name == c2.Name && c1.Count == c2.Count))) { await this.ShowMessageAsync("Already up to date.", "No changes found."); return; } SetNewDeck(selectedDeck, true); TextBoxDeckName.Text = deck.Name; _newDeck.Cards.Clear(); foreach (var card in deck.Cards) { _newDeck.Cards.Add(card); } _newDeck.Edited(); UpdateCardCount(); Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst); ManaCurveMyDecks.UpdateValues(); TagControlEdit.SetSelectedTags(deck.Tags); }
private async void BtnUpdateDeck_Click(object sender, RoutedEventArgs e) { var selectedDeck = DeckPickerList.SelectedDeck; if (selectedDeck == null || string.IsNullOrEmpty(selectedDeck.Url)) { return; } var deck = await DeckImporter.Import(selectedDeck.Url); if (deck == null) { await this.ShowMessageAsync("Error", "Could not load deck from specified url."); return; } if (deck.Cards.All(c1 => selectedDeck.Cards.Any(c2 => c1.Name == c2.Name && c1.Count == c2.Count))) { await this.ShowMessageAsync("Already up to date.", "No changes found."); return; } SetNewDeck(selectedDeck, true); TextBoxDeckName.Text = deck.Name; _newDeck.Cards.Clear(); foreach (var card in deck.Cards) { _newDeck.Cards.Add(card); } UpdateTitle(); Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst); ManaCurveMyDecks.UpdateValues(); TagControlEdit.SetSelectedTags(deck.Tags); }