Exemplo n.º 1
0
        public static byte[] CreateLabels(IEnumerable <Expansion> expansionsToPrint)
        {
            var cardsToPrint = DominionCardDataAccess.GetCardsToPrint(expansionsToPrint);

            var trajan               = Path.Combine(CurrentPath, "Fonts", "TRAJANPROREGULAR.TTF");
            var trajanBold           = Path.Combine(CurrentPath, "Fonts", "TRAJANPROBOLD.TTF");
            var font                 = PdfFontFactory.CreateFont(trajan, true);
            var boldFont             = PdfFontFactory.CreateFont(trajanBold, true);
            var drawActionRectangles = cardsToPrint.SelectMany(card => new List <Action <PdfCanvas, Rectangle> >
            {
                (canvas, rectangle) =>
                {
                    var topCursor    = new Cursor();
                    var bottomCursor = new Cursor();
                    topCursor.AdvanceCursor(rectangle.GetTop());
                    bottomCursor.AdvanceCursor(rectangle.GetBottom());
                    DrawBackgroundImage(card.SuperType, rectangle, canvas);
                    DrawCosts(boldFont, card, rectangle, canvas, topCursor);
                    DrawSetImageAndReturnTop(rectangle, bottomCursor, card.Set.Image, canvas);

                    var cardName = card.GroupName ?? card.Name;
                    DrawCardText(rectangle, topCursor, bottomCursor, canvas, cardName, font, card.SuperType);
                }
            }).ToList();
            var drawActionRectangleQueue = new Queue <Action <PdfCanvas, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(drawActionRectangleQueue, ColorConstants.WHITE));
        }
        public static byte[] CreateLabels(IEnumerable <Expansion> expansionsToPrint)
        {
            var cardsToPrint = DominionCardDataAccess.GetCardsToPrint(expansionsToPrint);

            var trajan               = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Cinzel-Regular.ttf");
            var trajanBold           = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Cinzel-Bold.ttf");
            var baseFont             = BaseFont.CreateFont(trajan, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var boldBaseFont         = BaseFont.CreateFont(trajanBold, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var drawActionRectangles = cardsToPrint.SelectMany(card => new List <Action <PdfContentByte, Rectangle> >
            {
                (canvas, rectangle) =>
                {
                    var topCursor    = new Cursor();
                    var bottomCursor = new Cursor();
                    DrawBackgroundImage(card.SuperType, rectangle, canvas, topCursor, bottomCursor);
                    DrawCosts(boldBaseFont, card, rectangle, canvas, topCursor);
                    DrawSetImageAndReturnTop(rectangle, bottomCursor, card.Set.Image, canvas);

                    var cardName = card.GroupName ?? card.Name;
                    DrawCardText(rectangle, topCursor, bottomCursor, canvas, cardName, baseFont, card.SuperType);
                }
            }).ToList();
            var drawActionRectangleQueue = new Queue <Action <PdfContentByte, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(drawActionRectangleQueue, BaseColor.WHITE));
        }
        public static void CreateLabels(bool drawBorders)
        {
            var normalStandeeContainers = GloomhavenStandeeDataAccess.GetStandardStandeeContainers();
            var bossStandeeContainers   = GloomhavenStandeeDataAccess.GetBossStandeeContainers();
            //var fontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "segoeui.ttf");
            var fontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "HTOWERT.TTF");
            //TODO: Try different fonts
            var boldFontPath        = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "arialbd.ttf");
            var baseFont            = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var boldBaseFont        = BaseFont.CreateFont(boldFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var normalStandeeLabels = normalStandeeContainers
                                      .Select(container =>
            {
                var containerLabels = container.Description.Select(description => new Action <PdfContentByte, Rectangle>((canvas, rectangle) =>
                {
                    DrawCardText(rectangle, description, canvas, baseFont, rectangle.Width / 2, rectangle.Height / 2, 16f, Element.ALIGN_CENTER);
                }))
                                      .ToList();
                var standeeGroupLabels = container.StandeeGroups
                                         .SelectMany(standeeGroup =>
                {
                    var nameWithImageAction = GetNameWithImageActionForStandeeGroup(standeeGroup, baseFont);
                    var justImageAction     = GetImageActionForStandeeGroup(standeeGroup);
                    return(new [] { nameWithImageAction, justImageAction });
                });
                return(containerLabels.Concat(standeeGroupLabels).ToList());
            })
                                      .SelectMany(actions => actions)
                                      .ToList();
            var bossStandeeLabels = bossStandeeContainers
                                    .Select(container =>
            {
                var containerLabels = container.Description.Select(description => new Action <PdfContentByte, Rectangle>((canvas, rectangle) =>
                {
                    DrawCardText(rectangle, description, canvas, baseFont, rectangle.Width / 2, rectangle.Height / 2, 16f, Element.ALIGN_CENTER);
                }))
                                      .ToList();
                var standeeGroupLabels = container.StandeeGroups
                                         .SelectMany(standeeGroup =>
                {
                    var nameWithImageAction = GetNameWithImageActionForStandeeGroup(standeeGroup, baseFont);
                    var justImageAction     = GetImageActionForStandeeGroup(standeeGroup);
                    return(new[] { nameWithImageAction, justImageAction });
                });
                return(containerLabels.Concat(standeeGroupLabels).ToList());
            })
                                    .SelectMany(actions => actions)
                                    .ToList();
            var allActions = normalStandeeLabels.Concat(bossStandeeLabels).ToList();
            var drawActionRectangleQueue = new Queue <Action <PdfContentByte, Rectangle> >(allActions);
            var outputPath = PdfGenerator.DrawRectangles(drawActionRectangleQueue, BaseColor.WHITE, "Gloomhaven", drawBorders);

            PdfGenerator.StampPdfWithTemplate(outputPath);
        }
        public static byte[] CreateLabels()
        {
            var garamond     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "GARA.TTF");
            var garamondBold = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "GARABD.TTF");
            var baseFont     = BaseFont.CreateFont(garamond, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var boldBaseFont = BaseFont.CreateFont(garamondBold, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            var beers                = GetBeers();
            var labelBackground      = new CMYKColor(0, 8, 26, 0);
            var drawActionRectangles = beers.SelectMany(beer => new List <Action <PdfContentByte, Rectangle> >
            {
                (canvas, rectangle) =>
                {
                    TextSharpHelpers.DrawRectangle(canvas, rectangle, labelBackground);
                    //name
                    //gold label
                    const float startOfLabelOffset = 4f;
                    var topCursor = new Cursor();
                    topCursor.AdvanceCursor(rectangle.Top - startOfLabelOffset);
                    if (beer.Points > 0)
                    {
                        DrawPoints(rectangle, topCursor, canvas, beer, boldBaseFont);
                    }
                    if (beer.Barrel)
                    {
                        DrawBarrel(rectangle, topCursor, canvas);
                    }
                    if (beer.Hops)
                    {
                        DrawHops(rectangle, topCursor, canvas);
                    }
                    if (!string.IsNullOrEmpty(beer.GoldLabelImageName))
                    {
                        DrawGoldLabel(rectangle, topCursor, canvas, beer);
                    }

                    DrawBeerName(rectangle, topCursor, canvas, beer, baseFont);
                }
            }).ToList();

            var drawActionRectangleQueue = new Queue <Action <PdfContentByte, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(
                       drawActionRectangleQueue,
                       BaseColor.WHITE));
        }
Exemplo n.º 5
0
        public static byte[] CreateLabels()
        {
            var garamond     = Path.Combine(CurrentPath, "Fonts", "GARA.TTF");
            var garamondBold = Path.Combine(CurrentPath, "Fonts", "GARABD.TTF");
            var font         = PdfFontFactory.CreateFont(garamond, true);
            var boldFont     = PdfFontFactory.CreateFont(garamondBold, true);

            var beers                = GetBeers();
            var labelBackground      = new DeviceRgb(254, 246, 229);
            var drawActionRectangles = beers.SelectMany(beer => new List <Action <PdfCanvas, Rectangle> >
            {
                (canvas, rectangle) =>
                {
                    TextSharpHelpers.DrawRectangle(canvas, rectangle, labelBackground);
                    //name
                    //gold label
                    const float startOfLabelOffset = 4f;
                    var topCursor = new Cursor();
                    topCursor.AdvanceCursor(rectangle.GetTop() - startOfLabelOffset);
                    if (beer.Points > 0)
                    {
                        DrawPoints(rectangle, topCursor, canvas, beer, boldFont);
                    }
                    if (beer.Barrel)
                    {
                        DrawBarrel(rectangle, topCursor, canvas);
                    }
                    if (beer.Hops)
                    {
                        DrawHops(rectangle, topCursor, canvas);
                    }
                    if (!string.IsNullOrEmpty(beer.GoldLabelImageName))
                    {
                        DrawGoldLabel(rectangle, topCursor, canvas, beer);
                    }

                    DrawBeerName(rectangle, topCursor, canvas, beer, font);
                }
            }).ToList();

            var drawActionRectangleQueue = new Queue <Action <PdfCanvas, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(
                       drawActionRectangleQueue,
                       ColorConstants.WHITE));
        }
        public static byte[] CreateLabels(IEnumerable <Expansion> includedSets)
        {
            var garamond     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "GARA.TTF");
            var garamondBold = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "GARABD.TTF");
            var baseFont     = BaseFont.CreateFont(garamond, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var boldBaseFont = BaseFont.CreateFont(garamondBold, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            var dividers = DataAccess.GetDividers()
                           .Where(divider => includedSets.Contains(divider.Expansion))
                           .ToList();
            var drawActionRectangles = dividers
                                       .SelectMany(divider => new List <Action <PdfContentByte, Rectangle> >
            {
                (canvas, rectangle) =>
                {
                    var centeringCursor          = new CenteringCursor(rectangle.Top, rectangle.Bottom);
                    var topCursor                = centeringCursor.StartCursor;
                    var bottomCursor             = centeringCursor.EndCursor;
                    const float topPadding       = -4f;
                    const float dummyCostPadding = -27f;
                    topCursor.AdvanceCursor(topPadding);

                    DrawBackground(canvas, rectangle, divider.Type, topCursor, bottomCursor);
                    if (divider.Cost != null)
                    {
                        DrawCost(canvas, rectangle, divider.Cost.Value, boldBaseFont, topCursor);
                    }
                    else
                    {
                        topCursor.AdvanceCursor(dummyCostPadding);
                    }
                    DrawExpansionLogo(canvas, rectangle, divider.Expansion.GetAbbreviation(), boldBaseFont, bottomCursor);
                    DrawName(canvas, rectangle, divider.Name, baseFont, centeringCursor);
                }
            })
                                       .ToList();


            var drawActionRectangleQueue = new Queue <Action <PdfContentByte, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(drawActionRectangleQueue, BaseColor.WHITE));
        }
Exemplo n.º 7
0
        public static byte[] CreateLabels(IEnumerable <Expansion> selectedExpansions)
        {
            var garamond     = Path.Combine(CurrentPath, "Fonts", "GARA.TTF");
            var garamondBold = Path.Combine(CurrentPath, "Fonts", "GARABD.TTF");
            var font         = PdfFontFactory.CreateFont(garamond, true);
            var boldFont     = PdfFontFactory.CreateFont(garamondBold, true);

            var dividers = DataAccess.GetDividers()
                           .Where(divider => selectedExpansions.Contains(divider.Expansion))
                           .ToList();
            var drawActionRectangles = dividers
                                       .Select((divider) => new Action <PdfCanvas, Rectangle>(
                                                   (canvas, rectangle) =>
            {
                var centeringCursor          = new CenteringCursor(rectangle.GetTop(), rectangle.GetBottom());
                var topCursor                = centeringCursor.StartCursor;
                var bottomCursor             = centeringCursor.EndCursor;
                const float dummyCostPadding = -27f;
                topCursor.AdvanceCursor(rectangle.GetTop());
                bottomCursor.AdvanceCursor(rectangle.GetBottom());

                DrawBackground(canvas, rectangle, divider.Type);
                if (divider.Cost != null)
                {
                    DrawCost(canvas, rectangle, divider.Cost.Value, boldFont, topCursor);
                }
                else
                {
                    topCursor.AdvanceCursor(dummyCostPadding);
                }
                DrawExpansionLogo(canvas, rectangle, divider.Expansion.GetAbbreviation(), boldFont, bottomCursor);
                DrawName(canvas, rectangle, divider.Name, font, centeringCursor);
            }))
                                       .ToList();


            var drawActionRectangleQueue = new Queue <Action <PdfCanvas, Rectangle> >(drawActionRectangles);

            return(PdfGenerator.DrawRectangles(drawActionRectangleQueue, ColorConstants.WHITE));
        }
Exemplo n.º 8
0
        public static byte[] CreateLabels(IEnumerable <Expansion> selectedExpansions, bool includeSpecialSetupCards)
        {
            var allHeroes        = DataAccess.GetHeroCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(heroCardSet => heroCardSet.Heroes);
            var allMasterminds   = DataAccess.GetMastermindCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(mastermindCardSet => mastermindCardSet.Masterminds);
            var allVillains      = DataAccess.GetVillainCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(villainCardSet => villainCardSet.Villains);
            var allHenchmen      = DataAccess.GetHenchmenCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(henchmenCardSet => henchmenCardSet.Henchmen);
            var allStartingCards = DataAccess.GetStartingCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(startingCardSet => startingCardSet.StartingCards);
            var allSetupCards    = DataAccess.GetSetupCardSets()
                                   .Where(set => selectedExpansions.Contains(set.Expansion))
                                   .SelectMany(setupCardSet => setupCardSet.SetupCards)
                                   .Where(setupCard => includeSpecialSetupCards || !setupCard.IsSpecialCard);
            var allVillainSetupCards = DataAccess.GetVillainSetupCardSets().Where(set => selectedExpansions.Contains(set.Expansion)).SelectMany(setupCardSet => setupCardSet.VillainSetupCards);

            var mastermindBaseColor       = new DeviceRgb(255, 61, 83);
            var villainBaseColor          = new DeviceRgb(255, 102, 119);
            var henchmenBaseColor         = new DeviceRgb(255, 173, 182);
            var startingCardBaseColor     = new DeviceRgb(200, 200, 200);
            var setupCardBaseColor        = new DeviceRgb(35, 255, 39);
            var villainSetupCardBaseColor = new DeviceRgb(255, 73, 197);

            var fontPath        = Path.Combine(CurrentPath, "Fonts", "KOMIKAX.TTF");
            var font            = PdfFontFactory.CreateFont(fontPath, true);
            var drawHeroActions = allHeroes.Select(hero => new Action <PdfCanvas, Rectangle>(
                                                       (canvas, rectangle) =>
            {
                var topCursor    = new Cursor();
                var bottomCursor = new Cursor();
                const float startOfLabelOffset = 4f;
                topCursor.AdvanceCursor(rectangle.GetTop() - startOfLabelOffset);
                bottomCursor.AdvanceCursor(rectangle.GetBottom() + startOfLabelOffset);
                TextSharpHelpers.DrawRoundedRectangle(canvas, rectangle, new DeviceRgb(168, 255, 247));

                DrawFactionsAndTypes(hero, rectangle, canvas, topCursor, bottomCursor);

                DrawCardText(rectangle, topCursor, bottomCursor, canvas, hero.Name, font);
                DrawSetText(rectangle, topCursor, bottomCursor, canvas, hero.Expansion.GetExpansionName(), font);
            }
                                                       )).ToList();
            var drawMastermindActions = allMasterminds.Select(mastermind =>
                                                              CreateActionToDrawNameAndSet(
                                                                  mastermind.Name,
                                                                  mastermind.Expansion.GetExpansionName(),
                                                                  font,
                                                                  mastermindBaseColor
                                                                  ));
            var drawVillainActions = allVillains.Select(villain =>
                                                        CreateActionToDrawNameAndSet(
                                                            villain.Name,
                                                            villain.Expansion.GetExpansionName(),
                                                            font,
                                                            villainBaseColor
                                                            ));
            var drawHenchmenActions = allHenchmen.Select(henchmen =>
                                                         CreateActionToDrawNameAndSet(
                                                             henchmen.Name,
                                                             henchmen.Expansion.GetExpansionName(),
                                                             font,
                                                             henchmenBaseColor
                                                             ));
            var drawStartingCardsActions = allStartingCards.Select(startingCard =>
                                                                   CreateActionToDrawNameAndSet(
                                                                       startingCard.Name,
                                                                       startingCard.Expansion.GetExpansionName(),
                                                                       font,
                                                                       startingCardBaseColor
                                                                       ));
            var drawSetupCardsActions = allSetupCards.Select(setupCard =>
                                                             CreateActionToDrawNameAndSet(
                                                                 setupCard.Name,
                                                                 setupCard.Expansion.GetExpansionName(),
                                                                 font,
                                                                 setupCardBaseColor
                                                                 ));
            var drawVillainSetupCardsActions = allVillainSetupCards.Select(villainSetupCard =>
                                                                           CreateActionToDrawNameAndSet(
                                                                               villainSetupCard.Name,
                                                                               villainSetupCard.Expansion.GetExpansionName(),
                                                                               font,
                                                                               villainSetupCardBaseColor
                                                                               ));


            var allActions = drawHeroActions
                             .Concat(drawMastermindActions)
                             .Concat(drawVillainActions)
                             .Concat(drawHenchmenActions)
                             .Concat(drawStartingCardsActions)
                             .Concat(drawSetupCardsActions)
                             .Concat(drawVillainSetupCardsActions);

            var drawActionRectangleQueue = new Queue <Action <PdfCanvas, Rectangle> >(allActions);

            return(PdfGenerator.DrawRectangles(drawActionRectangleQueue, ColorConstants.WHITE));
        }