public void UpdateArchivedClassVisibility()
        {
            if (DeckList.Instance.Decks.Any(d => d.Archived))
            {
                if (!_classItems.Contains(_archivedClassItem))
                {
                    _classItems.Add(_archivedClassItem);
                    ArchivedClassVisible = true;

                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ArchivedClassVisible"));
                }
            }
            else
            {
                var removed = _classItems.Remove(_archivedClassItem);

                if (removed)
                {
                    ArchivedClassVisible = false;

                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ArchivedClassVisible"));
                }

                SelectedClasses.Remove(HeroClassAll.Archived);
                if (SelectedClasses.Count == 0)
                {
                    SelectClass(HeroClassAll.All);
                }
            }
        }
        public void SelectDeckAndAppropriateView(Deck deck)
        {
            if (Config.Instance.SelectedDeckType != DeckType.All)
            {
                if (deck.IsArenaDeck && Config.Instance.SelectedDeckType != DeckType.Arena)
                {
                    SelectDeckType(DeckType.Arena);
                }
                else if (!deck.IsArenaDeck && Config.Instance.SelectedDeckType != DeckType.Constructed)
                {
                    SelectDeckType(DeckType.Constructed);
                }
            }

            if (deck.Archived && !SelectedClasses.Contains(HeroClassAll.Archived))
            {
                SelectClass(HeroClassAll.Archived);
            }
            else if (!SelectedClasses.Contains(HeroClassAll.All))
            {
                HeroClassAll deckClass;
                if (Enum.TryParse(deck.Class, out deckClass))
                {
                    if (!SelectedClasses.Contains(deckClass))
                    {
                        SelectClass(deckClass);
                    }
                }
            }

            UpdateDecks(false);
            SelectDeck(deck);
        }
        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();
        }
示例#4
0
        public void UpdateArchivedClassVisibility()
        {
            _anyArchived = DeckList.Instance.Decks.Any(d => d.Archived);

            if (_anyArchived)
            {
                if (!_classItems.Contains(_archivedClassItem))
                {
                    _classItems.Add(_archivedClassItem);

                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs("MinWindowHeight"));
                    }
                }
            }
            else
            {
                var removed = _classItems.Remove(_archivedClassItem);

                if (removed && PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("MinWindowHeight"));
                }

                SelectedClasses.Remove(HeroClassAll.Archived);
                if (SelectedClasses.Count == 0)
                {
                    SelectClass(HeroClassAll.All);
                }
            }
        }
示例#5
0
        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;
        }
示例#6
0
 public void SelectClass(HeroClassAll heroClass)
 {
     if (!SelectedClasses.Contains(heroClass))
     {
         var dpci = PickerClassItemFromEnum(ListViewClasses, heroClass);
         ListViewClasses.SelectedItems.Add(dpci);
     }
 }
示例#7
0
        private void DeselectPickerClassItem(DeckPickerClassItem dpci)
        {
            var heroClass = dpci.DataContext as HeroClassAll?;

            if (heroClass != null && SelectedClasses.Remove(heroClass.Value))
            {
                dpci.OnDelselected();
            }
        }
示例#8
0
        private void SelectPickerClassItem(DeckPickerClassItem dpci)
        {
            var heroClass = dpci.DataContext as HeroClassAll?;

            if (heroClass != null && !SelectedClasses.Contains(heroClass.Value))
            {
                SelectedClasses.Add(heroClass.Value);
                dpci.OnSelected();
            }
        }
示例#9
0
        private void DeselectPickerClassItem(DeckPickerClassItem dpci)
        {
#pragma warning disable IDE0019
            var heroClass = dpci.DataContext as HeroClassAll?;
            if (heroClass != null && SelectedClasses.Remove(heroClass.Value))
            {
                dpci.OnDelselected();
            }
#pragma warning restore IDE0019
        }
示例#10
0
        private void SelectPickerClassItem(DeckPickerClassItem dpci)
        {
#pragma warning disable IDE0019
            var heroClass = dpci.DataContext as HeroClassAll?;
            if (heroClass != null && !SelectedClasses.Contains(heroClass.Value))
            {
                SelectedClasses.Add(heroClass.Value);
                dpci.OnSelected();
            }
#pragma warning restore IDE0019
        }
        public void SelectDeckAndAppropriateView(Deck deck)
        {
            if (deck == null)
            {
                return;
            }
            ClearFromCache(deck);
            if (Config.Instance.SelectedDeckType != DeckType.All)
            {
                if (deck.IsArenaDeck && Config.Instance.SelectedDeckType != DeckType.Arena)
                {
                    SelectDeckType(DeckType.Arena);
                }
                else if (!deck.IsArenaDeck && Config.Instance.SelectedDeckType != DeckType.Constructed)
                {
                    SelectDeckType(DeckType.Constructed);
                }
            }

            if (deck.Archived && !SelectedClasses.Contains(HeroClassAll.Archived))
            {
                SelectClass(HeroClassAll.Archived);
            }
            else if (!SelectedClasses.Contains(HeroClassAll.All))
            {
                HeroClassAll deckClass;
                if (Enum.TryParse(deck.Class, out deckClass))
                {
                    if (!SelectedClasses.Contains(deckClass))
                    {
                        SelectClass(deckClass);
                    }
                }
            }

            UpdateDecks(false);
            SelectDeck(deck);
            var dpi = _displayedDecks.FirstOrDefault(x => Equals(x.Deck, deck));

            if (dpi != null)
            {
                ListViewDecks.ScrollIntoView(dpi);
            }
        }
        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();
            }
        }
        public void GetAllSelection(IList <NodeItem> selected)
        {
            List <NodeItem> removeList = new List <NodeItem>();

            foreach (var item in selected)
            {
                if (!_classes.Any(o => o.Name == item.ClassificationName))
                {
                    removeList.Add(item);
                }
            }
            foreach (var item in removeList)
            {
                selected.Remove(item);
            }
            SelectedClasses.Clear();
            if (selected.Count > 0)
            {
                BindableCollection <NodeItem> newNodes = new BindableCollection <NodeItem>(
                    NodeItem.RestructureFlatNodes(_classes.ToList(), selected));
                SelectedClasses = newNodes;
            }
            UpdatePropNotice(_selectedClasses);
        }
示例#14
0
        public void UpdateArchivedClassVisibility()
        {
            if (DeckList.Instance.Decks.Any(d => d.Archived))
            {
                if (!_classItems.Contains(_archivedClassItem))
                {
                    _classItems.Add(_archivedClassItem);
                    ArchivedClassVisible = true;
                }
            }
            else
            {
                if (_classItems.Remove(_archivedClassItem))
                {
                    ArchivedClassVisible = false;
                }

                SelectedClasses.Remove(HeroClassAll.Archived);
                if (SelectedClasses.Count == 0)
                {
                    SelectClass(HeroClassAll.All);
                }
            }
        }
示例#15
0
        public void SelectDeckAndAppropriateView(Deck deck)
        {
            if (deck == null)
            {
                return;
            }
            ClearFromCache(deck);
            if (Config.Instance.SelectedDeckPickerDeckType != DeckType.All)
            {
                if (deck.IsArenaDeck && Config.Instance.SelectedDeckPickerDeckType != DeckType.Arena)
                {
                    SelectDeckType(DeckType.Arena);
                }
                else if (!deck.IsArenaDeck)
                {
                    if (deck.StandardViable && Config.Instance.SelectedDeckPickerDeckType != DeckType.Standard)
                    {
                        SelectDeckType(DeckType.Standard);
                    }
                    else if (!deck.StandardViable && Config.Instance.SelectedDeckPickerDeckType != DeckType.Wild)
                    {
                        SelectDeckType(DeckType.Wild);
                    }
                }
            }
            if (deck.Archived && !SelectedClasses.Contains(HeroClassAll.Archived))
            {
                SelectClass(HeroClassAll.Archived);
            }
            else if (!SelectedClasses.Contains(HeroClassAll.All))
            {
                HeroClassAll deckClass;
                if (Enum.TryParse(deck.Class, out deckClass))
                {
                    if (!SelectedClasses.Contains(deckClass))
                    {
                        SelectClass(deckClass);
                    }
                }
            }

            if (!DeckMatchesSelectedTags(deck))
            {
                if (Config.Instance.TagOperation == TagFilerOperation.Or)
                {
                    var missingTags = deck.Tags.Where(tag => !Config.Instance.SelectedTags.Contains(tag)).ToList();
                    if (missingTags.Any())
                    {
                        Config.Instance.SelectedTags.AddRange(missingTags);
                        Log.Info("Added missing tags so the deck shows up: " + missingTags.Aggregate((c, n) => c + ", " + n));
                    }
                    else
                    {
                        Config.Instance.SelectedTags.Add("None");
                        Log.Info("Added missing tags so the deck shows up: None");
                    }
                }
                else
                {
                    Config.Instance.SelectedTags = new List <string> {
                        "All"
                    };
                    Log.Info("Set tags to ALL so the deck shows up");
                }
                Config.Save();
                Core.MainWindow.SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags);
            }

            UpdateDecks(false);
            SelectDeck(deck);
            var dpi = _displayedDecks.FirstOrDefault(x => Equals(x.Deck, deck));

            if (dpi != null)
            {
                ListViewDecks.ScrollIntoView(dpi);
            }
        }
示例#16
0
        private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_reselectingClasses)
            {
                return;
            }

            var removedPickerClassItems = e.RemovedItems.OfType <DeckPickerClassItem>();
            var addedPickerClassItems   = e.AddedItems.OfType <DeckPickerClassItem>().ToList();
            var addedClasses            = PickerClassItemsAsEnum(addedPickerClassItems).ToList();

            if (addedClasses.Contains(HeroClassAll.All))
            {
                _reselectingClasses = true;
                var senderList = ((ListView)sender);
                senderList.UnselectAll();
                foreach (var item in senderList.Items)
                {
                    var dpci = item as DeckPickerClassItem;
                    if (dpci != null)
                    {
                        var hca = (HeroClassAll)dpci.DataContext;

                        switch (hca)
                        {
                        case HeroClassAll.All:
                            senderList.SelectedItems.Add(item);
                            SelectPickerClassItem(dpci);
                            break;

                        case HeroClassAll.Archived:
                            if (!SelectedClasses.Contains(HeroClassAll.Archived))
                            {
                                if (addedClasses.Contains(HeroClassAll.Archived))
                                {
                                    senderList.SelectedItems.Add(item);
                                    SelectPickerClassItem(dpci);
                                }
                            }
                            else
                            {
                                if (PickerClassItemsAsEnum(removedPickerClassItems).Contains(HeroClassAll.Archived))
                                {
                                    DeselectPickerClassItem(dpci);
                                }
                                else
                                {
                                    senderList.SelectedItems.Add(item);
                                }
                            }
                            break;

                        default:
                            DeselectPickerClassItem(dpci);
                            break;
                        }
                    }
                }
                _reselectingClasses = false;
            }
            else
            {
                DeckPickerClassItem removedAllClassItem = null;
                foreach (var dpci in removedPickerClassItems)
                {
                    var heroClass = dpci.DataContext as HeroClassAll?;
                    switch (heroClass)
                    {
                    case null:
                        continue;

                    case HeroClassAll.All:
                        // We remove this from SelectedClasses now but we don't raise it's OnDeselected event yet,
                        // instead store a reference to it in case we want to quietly add this back to the
                        // SelectedClasses list later
                        SelectedClasses.Remove(heroClass.Value);
                        removedAllClassItem = dpci;
                        break;

                    default:
                        DeselectPickerClassItem(dpci);
                        break;
                    }
                }

                var allIsSelected = SelectedClasses.Contains(HeroClassAll.All);
                foreach (var dpci in addedPickerClassItems)
                {
                    var heroClass = dpci.DataContext as HeroClassAll?;
                    if (heroClass == null)
                    {
                        continue;
                    }

                    if (allIsSelected && heroClass != HeroClassAll.Archived)
                    {
                        _reselectingClasses = true;
                        ((ListView)sender).SelectedItems.Remove(dpci);
                        _reselectingClasses = false;
                        continue;
                    }

                    SelectPickerClassItem(dpci);
                }

                if (SelectedClasses.Count == 0 && !_clearingClasses)
                {
                    var senderList = (ListView)sender;
                    if (removedAllClassItem == null)
                    {
                        var dpciAll = PickerClassItemFromEnum(senderList, HeroClassAll.All);

                        // Select 'All', raising its OnSelected event
                        _reselectingClasses = true;
                        senderList.SelectedItems.Add(dpciAll);
                        SelectPickerClassItem(dpciAll);
                        _reselectingClasses = false;
                    }
                    else
                    {
                        // If there are no selected classes, and we earlier removed 'All', quietly add it back
                        _reselectingClasses = true;
                        senderList.SelectedItems.Add(removedAllClassItem);
                        SelectedClasses.Add(HeroClassAll.All);
                        _reselectingClasses = false;

                        // And make sure we do not raise its OnDeselected event if we were going to
                        removedAllClassItem = null;
                    }
                }

                // If we removed the 'All' class earlier, raise the DeckPickerClassItem's OnDeselected event now
                removedAllClassItem?.OnDelselected();
            }

            if (Core.MainWindow.IsLoaded)
            {
                UpdateDecks();
            }
        }