Ejemplo n.º 1
0
        private void RefreshDisplayedData(bool full)
        {
            IEdition editionSelected = EditionSelected;

            if (full)
            {
                foreach (CardCollectionInputGraphicViewModel c in _cards)
                {
                    c.PropertyChanged -= ItemChanged;
                }
                _cards.Clear();
            }

            if (editionSelected == null)
            {
                return;
            }

            List <CardCollectionInputGraphicViewModel> toSort = new List <CardCollectionInputGraphicViewModel>();

            if (full)
            {
                foreach (ICardAllDbInfo cardInfo in _allCardInfos.Where(cadi => cadi.Edition == editionSelected))
                {
                    CardCollectionInputGraphicViewModel newCard = new CardCollectionInputGraphicViewModel(new CardViewModel(cardInfo));
                    newCard.PropertyChanged += ItemChanged;
                    toSort.Add(newCard);
                }
            }
            else
            {
                toSort.AddRange(_cards);
                _cards.Clear();
            }

            foreach (CardCollectionInputGraphicViewModel ccigvm in toSort)
            {
                CardViewModel card = ccigvm.Card;
                _allCardTranslation.TryGetValue(card.Card, out string name);
                int count = 0;

                foreach (ICardInCollectionCount cardInCollectionCount in _magicDatabase.GetCollectionStatisticsForCard(CardCollection, card.Card)
                         .Where(cicc => cicc.IdLanguage == InputLanguage.Id && _magicDatabase.GetEdition(cicc.IdGatherer).Id == editionSelected.Id))
                {
                    if (AltArt)
                    {
                        count += Foil ? cardInCollectionCount.FoilAltArtNumber : cardInCollectionCount.AltArtNumber;
                    }
                    else
                    {
                        count += Foil ? cardInCollectionCount.FoilNumber : cardInCollectionCount.Number;
                    }
                }
                ccigvm.SetInfo(name, count);
            }

            toSort.Sort(CardCollectionInputGraphicViewModel.GetComparer(DisplayOrder));
            _cards.AddRange(toSort);
        }
Ejemplo n.º 2
0
        private bool CheckName(CardCollectionInputGraphicViewModel vm)
        {
            if (string.IsNullOrEmpty(Filter))
            {
                return(true);
            }

            return(vm.NameInLanguage.Contains(Filter));
        }
Ejemplo n.º 3
0
        private bool CheckType(CardCollectionInputGraphicViewModel vm)
        {
            if (TypesSelected.Count == 0)
            {
                return(true);
            }

            CardType type       = vm.GetCardType();
            CardType wantedType = TypesSelected.Aggregate(CardType.Token, (current, newType) => current | newType);

            return(Matcher <CardType> .HasValue(type, wantedType));
        }
Ejemplo n.º 4
0
        private bool CheckColor(CardCollectionInputGraphicViewModel vm)
        {
            if (ColorsSelected.Count == 0)
            {
                return(true);
            }

            ShardColor color           = vm.GetColor();
            bool       wantedColorless = ColorsSelected.Contains(ShardColor.Colorless);
            ShardColor wantedColor     = ColorsSelected.Aggregate(ShardColor.Colorless, (current, newColor) => current | newColor);

            return(Matcher <ShardColor> .HasValue(color, wantedColor) || (wantedColorless && color == ShardColor.Colorless));
        }