Пример #1
0
        private static IEnumerable <ISaveableImage> CreateIndividualImages(GtrConfig gtrConfig)
        {
            var allSuits = Enum.GetValues(typeof(CardSuit))
                           .Cast <CardSuit>()
                           .ToList();
            var imageCreator = new GloryToRomeImageCreator(gtrConfig);

            var cardsToPrint = Enumerable.Empty <ISaveableImage>();

            var orderCards          = ReadOrderCards();
            var orderCardsToInclude = orderCards
                                      .Where(orderCard => gtrConfig.CardTypesToInclude.Contains(orderCard.CardType))
                                      .ToList();
            var orderCardFrontImages = orderCardsToInclude.SelectMany(orderCard => CreateCardsForOrderCard(imageCreator, orderCard)).ToList();

            if (orderCardsToInclude.Any())
            {
                var orderCardBackImage = imageCreator.CreateOrderCardBack();
                cardsToPrint = cardsToPrint.Concat(orderCardFrontImages).Concat(new[] { orderCardBackImage });
            }

            if (gtrConfig.CardTypesToInclude.Contains(CardType.SiteCard))
            {
                var siteFrontImages = allSuits.Select(suit => imageCreator.CreateSiteFront(suit)).ToList();
                var siteBackImages  = allSuits.Select(suit => imageCreator.CreateSiteBack(suit)).ToList();
                cardsToPrint = cardsToPrint.Concat(siteFrontImages).Concat(siteBackImages);
            }

            if (gtrConfig.CardTypesToInclude.Contains(CardType.MiscCard))
            {
                var jackImageFront = imageCreator.CreateJackImageSword();
                var jackImageBack  = imageCreator.CreateJackImageQuill();

                var merchantBonusCards = allSuits.Select(suit => imageCreator.CreateMerchantBonusImage(suit)).ToList();

                var leaderImage = imageCreator.CreateLeaderImage();
                cardsToPrint = cardsToPrint
                               .Concat(new[] { jackImageFront, jackImageBack })
                               .Concat(merchantBonusCards)
                               .Concat(new[] { leaderImage });
            }

            return(cardsToPrint.ToList());
        }
Пример #2
0
        static void Main(string[] args)
        {
            var allSuits = Enum.GetValues(typeof(CardSuit))
                           .Cast <CardSuit>()
                           .ToList();
            var imageCreator = new GloryToRomeImageCreator();


            var orderCards           = ReadOrderCards();
            var orderCardFrontImages = orderCards.SelectMany(orderCard => CreateCardsForOrderCard(imageCreator, orderCard)).ToList();
            var orderCardBackImage   = imageCreator.CreateOrderCardBack();

            var siteFrontImages = allSuits.SelectMany(suit => Enumerable.Range(0, 3).Select(index => imageCreator.CreateSiteFront(suit))).ToList();
            var siteBackImages  = allSuits.SelectMany(suit => Enumerable.Range(0, 3).Select(index => imageCreator.CreateSiteBack(suit))).ToList();

            foreach (var siteBackImage in siteBackImages)
            {
                siteBackImage.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }

            var jackImageFront = imageCreator.CreateJackImage1();
            var jackImageBack  = imageCreator.CreateJackImage2();

            jackImageBack.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);

            var merchantBonusFrontCards = allSuits.Select(suit => imageCreator.CreateMerchantBonusImage(suit)).ToList();
            var merchantBonusBackCards  = allSuits.Select(suit => imageCreator.CreateMerchantBonusImage(suit)).ToList();

            foreach (var merchantBonusBackCard in merchantBonusBackCards)
            {
                merchantBonusBackCard.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }

            var leaderImageFront = imageCreator.CreateLeaderImage();
            var leaderImageBack  = imageCreator.CreateLeaderImage();

            leaderImageBack.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);

            var dateStamp = DateTime.Now.ToString("yyyyMMddTHHmmss");

            Directory.CreateDirectory($"c:\\delete\\images\\{dateStamp}");

            var pages = new List <Page>();

            var remainingOrderCards = orderCardFrontImages.ToList();

            while (remainingOrderCards.Any())
            {
                var page       = new Page($"OrderCards_{pages.Count}");
                var cardsAdded = page.AddCardsToPage(remainingOrderCards);
                remainingOrderCards = remainingOrderCards.Skip(cardsAdded).ToList();
                pages.Add(page);
            }

            var pageOfOrderBackImages = Enumerable.Repeat(orderCardBackImage, Page.cardsPerColumn * Page.cardsPerRow).ToList();
            var orderBackPage         = new Page("OrderCardBack");

            orderBackPage.AddCardsToPage(pageOfOrderBackImages);
            pages.Add(orderBackPage);

            var siteFrontPage = new Page("SiteFront");

            siteFrontPage.AddCardsToPage(siteFrontImages);
            pages.Add(siteFrontPage);

            var siteBackPage = new Page("SiteBack");

            siteBackPage.AddCardsToPage(siteBackImages);
            pages.Add(siteBackPage);

            var miscImagesFront = Enumerable.Repeat(jackImageFront, 6)
                                  .Concat(merchantBonusFrontCards)
                                  .Concat(Enumerable.Repeat(leaderImageFront, 3))
                                  .ToList();

            var miscFrontPage = new Page("MiscFront");

            miscFrontPage.AddCardsToPage(miscImagesFront);
            pages.Add(miscFrontPage);

            var miscImagesBack = Enumerable.Repeat(jackImageBack, 6)
                                 .Concat(merchantBonusBackCards.Take(3).Reverse())
                                 .Concat(merchantBonusBackCards.Skip(3).Take(3).Reverse())
                                 .Concat(Enumerable.Repeat(leaderImageBack, 3))
                                 .ToList();

            var miscBackPage = new Page("MiscBack");

            miscBackPage.AddCardsToPage(miscImagesBack);
            pages.Add(miscBackPage);

            if (useOverlay)
            {
                var overlay = new Bitmap(@"Images\Misc\Poker Cards (2-5x3-5) 18 per sheet.png");
                overlay.SetResolution(300, 300);
                var landscapeOverlay = new Bitmap(overlay);
                landscapeOverlay.RotateFlip(RotateFlipType.Rotate90FlipNone);
                var matrix = new ColorMatrix {
                    Matrix33 = .5f
                };
                var attributes = new ImageAttributes();
                attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                foreach (var page in pages)
                {
                    var graphics = Graphics.FromImage(page.Bitmap);
                    if (page.Bitmap.Width < page.Bitmap.Height)
                    {
                        graphics.DrawImage(overlay, new Rectangle(0, 0, overlay.Width, overlay.Height), 0, 0, overlay.Width, overlay.Height, GraphicsUnit.Pixel, attributes);
                    }
                    else
                    {
                        graphics.DrawImage(landscapeOverlay, new Rectangle(0, 0, landscapeOverlay.Width, landscapeOverlay.Height), 0, 0, landscapeOverlay.Width, landscapeOverlay.Height, GraphicsUnit.Pixel, attributes);
                    }
                }
            }

            foreach (var page in pages)
            {
                page.Bitmap.Save($"c:\\delete\\images\\{dateStamp}\\{page.Name}.png", ImageFormat.Png);
            }
        }
Пример #3
0
        private static IEnumerable <ISaveableImage> CreatePages(GtrConfig gtrConfig)
        {
            Console.WriteLine($"{DateTime.Now:G}: Starting CreatePages");
            var pages = new List <Page>();

            var allSuits = Enum.GetValues(typeof(CardSuit))
                           .Cast <CardSuit>()
                           .ToList();
            var imageCreator = new GloryToRomeImageCreator(gtrConfig);


            var orderCards          = ReadOrderCards();
            var orderCardsToInclude = orderCards
                                      .Where(orderCard => gtrConfig.CardTypesToInclude.Contains(orderCard.CardType))
                                      .ToList();
            var orderCardFrontImages = orderCardsToInclude
                                       .SelectMany(orderCard => CreateCardsForOrderCard(imageCreator, orderCard))
                                       .ToList();

            Console.WriteLine($"{DateTime.Now:G}: Created order card front images");
            var remainingOrderCards = orderCardFrontImages.ToList();

            while (remainingOrderCards.Any())
            {
                var page       = new Page($"OrderCards_{pages.Count}", "Pages");
                var cardsAdded = page.AddCardsToPage(remainingOrderCards);
                foreach (var card in remainingOrderCards.Take(cardsAdded))
                {
                    card.Dispose();
                }
                remainingOrderCards = remainingOrderCards.Skip(cardsAdded).ToList();
                pages.Add(page);
            }
            Console.WriteLine($"{DateTime.Now:G}: Created order card front pages");

            if (orderCardsToInclude.Any())
            {
                var orderCardBackImage    = imageCreator.CreateOrderCardBack();
                var pageOfOrderBackImages = Enumerable.Repeat(orderCardBackImage, Page.cardsPerColumn * Page.cardsPerRow).ToList();
                var orderBackPage         = new Page("OrderCardBack", "Pages");
                orderBackPage.AddCardsToPage(pageOfOrderBackImages);
                orderCardBackImage.Dispose();
                pages.Add(orderBackPage);
                Console.WriteLine($"{DateTime.Now:G}: Created order card back page");
            }

            if (gtrConfig.CardTypesToInclude.Contains(CardType.SiteCard))
            {
                var siteFrontImages = allSuits.SelectMany(suit => Enumerable.Range(0, 3).Select(index => imageCreator.CreateSiteFront(suit))).ToList();
                var siteFrontPage   = new Page("SiteFront", "Pages");
                siteFrontPage.AddCardsToPage(siteFrontImages);
                foreach (var card in siteFrontImages)
                {
                    card.Dispose();
                }
                pages.Add(siteFrontPage);
                Console.WriteLine($"{DateTime.Now:G}: Created site front page");

                var siteBackImages = allSuits.SelectMany(suit => Enumerable.Range(0, 3).Select(index => imageCreator.CreateSiteBack(suit))).ToList();
                foreach (var siteBackImage in siteBackImages)
                {
                    siteBackImage.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                }
                var siteBackPage = new Page("SiteBack", "Pages");
                siteBackPage.AddCardsToPage(siteBackImages);
                foreach (var card in siteBackImages)
                {
                    card.Dispose();
                }
                pages.Add(siteBackPage);
                Console.WriteLine($"{DateTime.Now:G}: Created site back page");
            }

            if (gtrConfig.CardTypesToInclude.Contains(CardType.MiscCard))
            {
                var jackImageFront          = imageCreator.CreateJackImageSword();
                var merchantBonusFrontCards = allSuits.Select(suit => imageCreator.CreateMerchantBonusImage(suit)).ToList();
                var leaderImageFront        = imageCreator.CreateLeaderImage();

                var miscImagesFront = Enumerable.Repeat(jackImageFront, 6)
                                      .Concat(merchantBonusFrontCards)
                                      .Concat(Enumerable.Repeat(leaderImageFront, 3))
                                      .ToList();

                var miscFrontPage = new Page("MiscFront", "Pages");
                miscFrontPage.AddCardsToPage(miscImagesFront);
                jackImageFront.Dispose();
                foreach (var card in merchantBonusFrontCards)
                {
                    card.Dispose();
                }
                leaderImageFront.Dispose();
                pages.Add(miscFrontPage);
                Console.WriteLine($"{DateTime.Now:G}: Created misc front page");

                var merchantBonusBackCards = allSuits.Select(suit => imageCreator.CreateMerchantBonusImage(suit)).ToList();
                foreach (var merchantBonusBackCard in merchantBonusBackCards)
                {
                    merchantBonusBackCard.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                }
                var jackImageBack = imageCreator.CreateJackImageQuill();
                jackImageBack.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                var leaderImageBack = imageCreator.CreateLeaderImage();
                leaderImageBack.Bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);

                var miscImagesBack = Enumerable.Repeat(jackImageBack, 6)
                                     .Concat(merchantBonusBackCards.Take(3).Reverse())
                                     .Concat(merchantBonusBackCards.Skip(3).Take(3).Reverse())
                                     .Concat(Enumerable.Repeat(leaderImageBack, 3))
                                     .ToList();

                var miscBackPage = new Page("MiscBack", "Pages");
                miscBackPage.AddCardsToPage(miscImagesBack);
                jackImageBack.Dispose();
                foreach (var card in merchantBonusBackCards)
                {
                    card.Dispose();
                }
                leaderImageBack.Dispose();
                pages.Add(miscBackPage);
                Console.WriteLine($"{DateTime.Now:G}: Created misc back page");
            }

            return(pages);
        }