Пример #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));
        }