Пример #1
0
        private void CardBookGroupAndOrder()
        {
            PopLocations();
            Print48();
            CardBook.Cards = CardBook.Cards.OrderBy(x => x.Level).ToList();
            ulong previousLevel     = 1;
            var   previousVariation = 0;
            var   previousColor     = "";
            ulong smartLevel        = 0;

            foreach (var card in CardBook.Cards)
            {
                var thisLevel = card.Level;
                if (!string.Equals(card.ColorCode, previousColor))
                {
                    previousVariation = 1;
                    previousColor     = card.ColorCode;
                }
                else
                {
                    previousVariation++;
                }

                card.Variation = previousVariation;
                if (card.Level > previousLevel)
                {
                    card.Level = ++smartLevel;
                }
                else
                {
                    card.Level = smartLevel;
                }

                previousLevel = thisLevel;
            }

            CardBook.LevelCounters = CardBook.Cards.GroupBy(x => x.Level).OrderBy(x => x.Key)
                                     .ToDictionary(x => x.Key, x => x.Count());
            CardBook.DistinctColorGroupssAndCounters = CardBook.Cards.GroupBy(x => x.ColorCode).OrderBy(x => x.Key)
                                                       .ToDictionary(x => x.Key, x => x.Count());
            CardBook.Cards       = CardBook.Cards.OrderBy(x => x.Level).ToList();
            CardBook.ColorGroups = new List <CardGroups>();
            CardBook.Cards       = CardBook.Cards.OrderBy(x => x.ColorCode).ToList();
            var gg = CardBook.Cards.GroupBy(x => x.ColorCode).ToDictionary(x => x.Key, x => x.ToList());

            CardBook.ColorGroups = CardsToGroups(gg);
            Card4S = new List <Card4s>();

            Tocsv();


            var images1  = new List <Bitmap>();
            var images48 = new List <Bitmap>();
            var images2  = new List <Bitmap>();
            var page     = 1;
            var odd      = true;

            foreach (var cg in CardBook.ColorGroups)
            {
                var cardDescription = new CardDescription()
                {
                    ColorList  = cg.ColorCode,
                    Id         = cg.GroupID,
                    Level      = cg.Level,
                    Variations = cg.VariationsOfSameColors.Count
                };
                var bmp = GetBitmap(cardDescription);
                bmp.Save($"{cardDescription.Id:D4}.png");

                if (odd)
                {
                    images1.Add(bmp);
                }
                else
                {
                    images2.Add(bmp);
                }
                odd = !odd;
                if (images1.Count >= 20)
                {
                    SaveImages(images1, $"A_{page:D2}");
                    images1 = new List <Bitmap>();
                }
                if (images2.Count >= 20)
                {
                    SaveImages(images2, $"B_{page++:D2}", true);
                    images2 = new List <Bitmap>();
                }
                foreach (var c in cg.VariationsOfSameColors)
                {
                    Card4S.Add(new Card4s
                    {
                        ID        = c.ID,
                        ColorCode = cg.ColorCode,
                        GroupID   = cg.GroupID,
                        Level     = cg.Level,
                        Variation = c.Variation,
                        Windows   = c.Windows
                    });
                }
            }
            if (images1.Count > 0)
            {
                SaveImages(images1, $"A_{page:D2}");
            }
            if (images2.Count > 0)
            {
                SaveImages(images2, $"B_{page++:D2}", true);
            }
            CardBook.Cards = null;
        }
Пример #2
0
        Bitmap GetBitmap(CardDescription cardDescription)
        {
            var text = $"ID:{cardDescription.Id}, Level:{cardDescription.Level}, Variations:{cardDescription.Variations}";

            return(GetBitmap(cardDescription.ColorList, text));
        }