public void UpdateDecks(bool reselectActiveDeck = true, IEnumerable <Deck> forceUpdate = null) { var selectedDeck = SelectedDecks.FirstOrDefault(); var decks = DeckList.Instance.Decks.Where( d => (string.IsNullOrEmpty(DeckNameFilter) || d.Name.ToLowerInvariant().Contains(DeckNameFilter.ToLowerInvariant())) && DeckMatchesSelectedDeckType(d) && DeckMatchesSelectedTags(d) && (SelectedClasses.Any( c => ((c.ToString() == "All" || d.Class == c.ToString()) && !d.Archived) || (c.ToString() == "Archived" && d.Archived)))).ToList(); if (forceUpdate == null) { forceUpdate = new List <Deck>(); } foreach (var deck in _displayedDecks.Where(dpi => !decks.Contains(dpi.Deck) || forceUpdate.Contains(dpi.Deck)).ToList()) { _displayedDecks.Remove(deck); } foreach (var deck in decks.Where(d => !_displayedDecks.Select(x => x.Deck).Contains(d))) { _displayedDecks.Add(GetDeckPickerItemFromCache(deck)); } Sort(); if (selectedDeck != null && reselectActiveDeck && decks.Contains(selectedDeck)) { SelectDeck(selectedDeck); } ActiveDeck?.StatsUpdated(); }
public void UpdateDecks(bool reselectActiveDeck = true, bool simpleRefill = true) { _refillingList = true; var decks = DeckList.Instance.Decks.Where( d => DeckMatchesSelectedDeckType(d) && DeckMatchesSelectedTags(d) && (SelectedClasses.Any( c => ((c.ToString() == "All" || d.Class == c.ToString()) && !d.Archived) || (c.ToString() == "Archived" && d.Archived)))).ToList(); if (simpleRefill) { _displayedDecks.Clear(); foreach (var deck in decks) { _displayedDecks.Add(new NewDeckPickerItem(deck)); } } else { var displayedDecksTemp = new List <NewDeckPickerItem>(); foreach (var dpi in _displayedDecks) { if (!decks.Contains(dpi.Deck)) { displayedDecksTemp.Add(dpi); } } foreach (var dpi in displayedDecksTemp) { _displayedDecks.Remove(dpi); } displayedDecksTemp.Clear(); foreach (var deck in decks) { if (!_displayedDecks.Any(x => x.Deck == deck)) { displayedDecksTemp.Add(new NewDeckPickerItem(deck)); } } foreach (var dpi in displayedDecksTemp) { _displayedDecks.Add(dpi); } } Sort(); _refillingList = false; _reselectingDecks = true; if (reselectActiveDeck && decks.Contains(DeckList.Instance.ActiveDeck)) { SelectDeck(DeckList.Instance.ActiveDeck); } _reselectingDecks = false; }
public void UpdateDecks(bool reselectActiveDeck = true, bool simpleRefill = true) { var selectedDeck = SelectedDecks.FirstOrDefault(); _refillingList = true; var decks = DeckList.Instance.Decks.Where( d => (string.IsNullOrEmpty(DeckNameFilter) || d.Name.ToLowerInvariant().Contains(DeckNameFilter.ToLowerInvariant())) && DeckMatchesSelectedDeckType(d) && DeckMatchesSelectedTags(d) && (SelectedClasses.Any( c => ((c.ToString() == "All" || d.Class == c.ToString()) && !d.Archived) || (c.ToString() == "Archived" && d.Archived)))).ToList(); if (simpleRefill) { foreach (var deck in _displayedDecks.Where(dpi => !decks.Contains(dpi.Deck)).ToList()) { _displayedDecks.Remove(deck); } foreach (var deck in decks.Where(d => !_displayedDecks.Select(x => x.Deck).Contains(d))) { _displayedDecks.Add(GetDeckPickerItemFromCache(deck)); } } Sort(); _refillingList = false; _reselectingDecks = true; if (selectedDeck != null && reselectActiveDeck && decks.Contains(selectedDeck)) { SelectDeck(selectedDeck); } _reselectingDecks = false; if (ActiveDeck != null) { ActiveDeck.StatsUpdated(); } }