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();
        }
Ejemplo n.º 2
0
        private async void ListViewDecks_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (OnDoubleClick != null)
            {
                //wait for doubleclick to be over to not reselect the deck
                await Task.Delay(SystemInformation.DoubleClickTime);

                OnDoubleClick(this, SelectedDecks.FirstOrDefault());
            }
        }
Ejemplo n.º 3
0
        private void BtnUseDeck_Click(object sender, RoutedEventArgs e)
        {
            var deck = SelectedDecks.FirstOrDefault();

            if (deck != null)
            {
                Core.MainWindow.DeckPickerList.SelectDeck(deck);
                Core.MainWindow.SelectDeck(deck, true);
                Core.MainWindow.DeckPickerList.RefreshDisplayedDecks();
            }
        }
Ejemplo n.º 4
0
 private void ListViewDecks_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (Config.Instance.DeckPickerItemLayout == DeckLayout.Legacy)
     {
         foreach (var deck in e.AddedItems.Cast <DeckPickerItem>())
         {
             deck.RefreshProperties();
         }
         foreach (var deck in e.RemovedItems.Cast <DeckPickerItem>())
         {
             deck.RefreshProperties();
         }
     }
     if (e.AddedItems.Count > 0)
     {
         OnSelectedDeckChanged?.Invoke(this, SelectedDecks.FirstOrDefault());
     }
 }
        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();
            }
        }
Ejemplo n.º 6
0
 private void BtnExportDeck_Click(object sender, RoutedEventArgs e) => Core.MainWindow.ShowExportFlyout(SelectedDecks.FirstOrDefault());
Ejemplo n.º 7
0
 private void BtnName_Click(object sender, RoutedEventArgs e) => Core.MainWindow.ShowEditDeckNameDialog(SelectedDecks.FirstOrDefault());
Ejemplo n.º 8
0
 private void BtnCloneSelectedVersion_Click(object sender, RoutedEventArgs e) => Core.MainWindow.ShowCloneDeckVersionDialog(SelectedDecks.FirstOrDefault());
Ejemplo n.º 9
0
 private void BtnOpenDeckUrl_Click(object sender, RoutedEventArgs e) => Core.MainWindow.OpenDeckUrl(SelectedDecks.FirstOrDefault());
Ejemplo n.º 10
0
 private void BtnUpdateDeck_Click(object sender, RoutedEventArgs e) => Core.MainWindow.UpdateDeckFromWeb(SelectedDecks.FirstOrDefault());
Ejemplo n.º 11
0
 private void MenuItemMissingDust_OnClick(object sender, RoutedEventArgs e) => Core.MainWindow.ShowMissingCardsMessage(SelectedDecks.FirstOrDefault(), false).Forget();
Ejemplo n.º 12
0
 private void BtnEditDeck_Click(object sender, RoutedEventArgs e) => Core.MainWindow.ShowDeckEditorFlyout(SelectedDecks.FirstOrDefault(), false);