Esempio n. 1
0
        private void PrintResourceType(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;
            var cardNameFont    = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var suit            = orderCard.CardSuit;
            var resourceName    = suit.ResourceName().ToUpper();
            var text            = AddHairSpaces(resourceName);
            var brush           = new SolidBrush(suit.Color());
            var textMeasurement = graphics.MeasureString(text, cardNameFont, new SizeF(usableRectangle.Width, usableRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var textBoxHeight   = (int)textMeasurement.Height;
            var rectangle       = new Rectangle(
                usableRectangle.X,
                usableRectangle.Bottom - textBoxHeight,
                usableRectangle.Width,
                textBoxHeight);

            GraphicsUtilities.DrawString(
                graphics,
                text,
                cardNameFont,
                brush,
                rectangle,
                GraphicsUtilities.HorizontalFarAlignment);
        }
Esempio n. 2
0
        private void PrintRoleIconAndName(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;

            var cardNameFont    = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var suit            = orderCard.CardSuit;
            var roleName        = suit.RoleName();
            var iconImageWidth  = RoleIconWidth(cardImage);
            var iconImageHeight = (int)(iconImageWidth * 190f / 140f);

            GraphicsUtilities.PrintScaledPng(
                graphics,
                $@"RoleIcons\{roleName}",
                usableRectangle.X,
                usableRectangle.Y,
                iconImageWidth,
                iconImageHeight);

            var text  = new string(roleName.ToUpper().ToCharArray().SelectMany(character => character == 'M' ? new[] { character } : new[] { character, (char)0x2009 }).ToArray());
            var brush = BrushesByCardSuit[suit];
            var singleCharacterMeasurement = graphics.MeasureString("M", cardNameFont, new SizeF(usableRectangle.Width, usableRectangle.Height), GraphicsUtilities.HorizontalNearAlignment);
            var textBoxWidth    = (int)singleCharacterMeasurement.Width;
            var xOffset         = (int)(iconImageWidth / 2.0f - textBoxWidth / 2);
            var yOffset         = iconImageHeight;
            var rectangle       = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, textBoxWidth, usableRectangle.Height);
            var textMeasurement = graphics.MeasureString(text, cardNameFont, new SizeF(rectangle.Width, rectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);

            graphics.FillRectangle(new SolidBrush(Color.FromArgb(200, Color.White)), new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, (int)textMeasurement.Height));
            GraphicsUtilities.DrawString(graphics, text, cardNameFont, brush, rectangle);
        }
Esempio n. 3
0
        private void PrintOrderCardName(OrderCard orderCard, CardImage cardImage)
        {
            var xOffset         = RoleIconWidth(cardImage);
            var maxTextBoxWidth = CardNameWidth(cardImage);
            var yOffset         = (int)(cardImage.UsableRectangle.Width * .05f);

            PrintCardName(orderCard.CardName, cardImage, GraphicsUtilities.BlackBrush, true, xOffset, maxTextBoxWidth, yOffset);
        }
Esempio n. 4
0
        private int PrintCardImage(OrderCard orderCard, CardImage cardImage)
        {
            var graphics      = cardImage.Graphics;
            var fullRectangle = cardImage.FullRectangle;
            var imageWidth    = fullRectangle.Width;
            var imageHeight   = GraphicsUtilities.PrintFullWidthPng(
                graphics,
                $@"CardImages\{orderCard.CardName}",
                fullRectangle.X + (orderCard.ImageIsRoughlyCentered ? CenteredImageOffset(cardImage) : 0),
                fullRectangle.Y,
                imageWidth);

            return(fullRectangle.Y + imageHeight);
        }
Esempio n. 5
0
        public CardImage CreateOrderCardFront(OrderCard orderCard, int index)
        {
            var name      = $"{orderCard.CardName}_{index}";
            var cardImage = new CardImage(name, ImageOrientation.Portrait);

            cardImage.PrintCardBorderAndBackground(Color.White, Color.White);
            var bottomOfImage = PrintCardImage(orderCard, cardImage);

            PrintRoleIconAndName(orderCard, cardImage);
            PrintOrderCardName(orderCard, cardImage);
            PrintResourceType(orderCard, cardImage);
            PrintSetIndicator(orderCard, cardImage);
            PrintOrderCardText(orderCard, cardImage, bottomOfImage);
            PrintInfluence(orderCard, cardImage);
            return(cardImage);
        }
Esempio n. 6
0
        private void PrintOrderCardText(OrderCard orderCard, CardImage cardImage, int bottomOfCardImage)
        {
            var usableRectangle     = cardImage.UsableRectangle;
            var textBoxWidth        = CardTextWidth(cardImage);
            var influenceImageSide  = InfluenceImageSide(cardImage);
            var textRectangleHeight = usableRectangle.Bottom - (influenceImageSide + bottomOfCardImage);
            var top = bottomOfCardImage;

            if (textRectangleHeight < 0)
            {
                top -= usableRectangle.Height / 2;
                textRectangleHeight = usableRectangle.Bottom - (influenceImageSide + top);
            }
            var xOffset = RoleIconWidth(cardImage);

            PrintCardText(orderCard.CardText, cardImage, top, textBoxWidth, textRectangleHeight, xOffset, true, GraphicsUtilities.BlackBrush);
        }
Esempio n. 7
0
        private void PrintInfluence(OrderCard orderCard, CardImage cardImage)
        {
            var graphics           = cardImage.Graphics;
            var usableRectangle    = cardImage.UsableRectangle;
            var influenceImageSide = InfluenceImageSide(cardImage);

            var suit = orderCard.CardSuit;

            for (var i = 0; i < suit.Influence(); i++)
            {
                GraphicsUtilities.PrintScaledPng(
                    graphics,
                    $@"Influence\{suit.ColorText()}Influence",
                    usableRectangle.X + influenceImageSide * i,
                    usableRectangle.Bottom - influenceImageSide,
                    influenceImageSide,
                    influenceImageSide);
            }
        }
Esempio n. 8
0
        private void PrintSetIndicator(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var usableRectangle = cardImage.UsableRectangle;

            var setIndicatorCircleWidth = (int)(usableRectangle.Width * SetIndicatorPercentage);
            var setIndicatorImageSide   = (int)(setIndicatorCircleWidth * .7f);
            var suit      = orderCard.CardSuit;
            var brush     = new SolidBrush(suit.Color());
            var haloBrush = new SolidBrush(Color.FromArgb(200, Color.White));
            var set       = orderCard.CardSet;

            for (var i = 0; i < suit.Points(); i++)
            {
                var circleRectangle = new Rectangle(
                    usableRectangle.Right - setIndicatorCircleWidth,
                    usableRectangle.Y + (i * setIndicatorCircleWidth) + (i > 0 ? i * (int)(setIndicatorCircleWidth * .2f) : 0),
                    setIndicatorCircleWidth,
                    setIndicatorCircleWidth);
                var haloSize      = (int)(circleRectangle.Width * 1.2f);
                var haloRectangle = new Rectangle(
                    circleRectangle.X - (haloSize - circleRectangle.Width) / 2,
                    circleRectangle.Y - (haloSize - circleRectangle.Width) / 2,
                    haloSize,
                    haloSize);

                graphics.FillEllipse(haloBrush, haloRectangle);
                graphics.FillEllipse(brush, circleRectangle);
                if (set.HasSetImage())
                {
                    GraphicsUtilities.PrintScaledPng(
                        graphics,
                        "Misc",
                        set.SetText(),
                        circleRectangle.X + (int)(circleRectangle.Width * ((1 - .7f) / 2)),
                        circleRectangle.Y + (int)(circleRectangle.Height * ((1 - .7f) / 2)),
                        setIndicatorImageSide,
                        setIndicatorImageSide);
                }
            }
        }
Esempio n. 9
0
        private void PrintRoleIconAndName(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var usableRectangle = cardImage.UsableRectangle;

            var cardNameFont    = new Font(boldFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var suit            = orderCard.CardSuit;
            var roleName        = suit.RoleName();
            var iconImageWidth  = RoleIconWidth(cardImage);
            var iconImageHeight = (int)(iconImageWidth * 190f / 140f);

            GraphicsUtilities.PrintScaledPng(
                graphics,
                "RoleIcons",
                roleName,
                usableRectangle.X,
                usableRectangle.Y,
                iconImageWidth,
                iconImageHeight);

            var text    = roleName.ToUpper();
            var brush   = BrushesByCardSuit[suit];
            var letters = text.ToList().Select(letter => letter.ToString()).ToList();;
            var singleCharacterMeasurement = letters.Max(letter => graphics.MeasureString(letter, cardNameFont, new SizeF(usableRectangle.Width, usableRectangle.Height), GraphicsUtilities.HorizontalNearAlignment).Width);
            var textBoxWidth = (int)singleCharacterMeasurement;
            var xOffset      = (int)(iconImageWidth / 2.0f - textBoxWidth / 2);
            var yOffset      = iconImageHeight;
            var rectangle    = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, textBoxWidth, usableRectangle.Height);
            var fragments    = letters
                               .Select(character => new TextFragment
            {
                Brush         = brush,
                Font          = cardNameFont,
                ForcesNewline = true,
                Text          = character
            })
                               .ToList();

            GraphicsUtilities.DrawFragmentsCentered(graphics, fragments, rectangle, 200, false, false);
        }
Esempio n. 10
0
 private static IEnumerable <CardImage> CreateCardsForOrderCard(GloryToRomeImageCreator imageCreator, OrderCard orderCard)
 {
     return(Enumerable.Range(0, orderCard.CardSuit.CardCountPerDeck())
            .Select(index => imageCreator.CreateOrderCardFront(orderCard, index))
            .ToList());
 }