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
        public CardImage CreateSiteBack(CardSuit suit)
        {
            var name            = $"{suit.ResourceName()}_SiteBack";
            var cardImage       = new CardImage(GtrConfig, name, "Sites", ImageOrientation.Portrait);
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var fullRectangle   = cardImage.FullRectangle;
            var usableRectangle = cardImage.UsableRectangle;

            cardImage.PrintCardBorderAndBackground(Color.White, Color.White);

            var       thickness = fullRectangle.Width / diagonalLinesPerCard;
            var       width     = (int)Math.Sqrt(Math.Pow(thickness, 2) / 2);
            var       pen       = new Pen(suit.Color(), width);
            const int extra     = 25;

            for (var xOffset = -2 * fullRectangle.Width + 10; xOffset < fullRectangle.Width; xOffset += thickness * 2)
            {
                graphics.DrawLine(pen, fullRectangle.Left + xOffset - extra, fullRectangle.Top - extra, fullRectangle.Left + fullRectangle.Height + xOffset + extra, fullRectangle.Bottom + extra);
            }

            var cardNameFont                 = new Font(boldFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var costFont                     = new Font(regularFontFamily, siteCardCostTextFontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            var resourceNameText             = AddFourPerEmSpaces(suit.ResourceName().ToUpper());
            var outOfTownSiteText            = AddFourPerEmSpaces("out of town site");
            var maxTextBoxWidth              = usableRectangle.Width;
            var initialRectangle             = new Rectangle(usableRectangle.X, usableRectangle.Y, maxTextBoxWidth, usableRectangle.Height);
            var resourceNameTextMeasurement  = graphics.MeasureString(outOfTownSiteText, cardNameFont, new SizeF(initialRectangle.Width, initialRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var outOfTownSiteTextMeasurement = graphics.MeasureString(outOfTownSiteText, cardNameFont, new SizeF(initialRectangle.Width, initialRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var resourceNameTextHeight       = (int)Math.Ceiling(resourceNameTextMeasurement.Height);
            var outOfTownSiteTextHeight      = (int)Math.Ceiling(outOfTownSiteTextMeasurement.Height);
            var textHeight                   = resourceNameTextHeight + outOfTownSiteTextHeight;
            var yOffset = usableRectangle.Height / 2 - textHeight / 2;
            var resourceNameTextRectangle  = new Rectangle(usableRectangle.X, usableRectangle.Y + yOffset - resourceNameTextHeight, maxTextBoxWidth, textHeight);
            var outOfTownSiteTextRectangle = new Rectangle(usableRectangle.X, usableRectangle.Y + yOffset, maxTextBoxWidth, textHeight);

            if (GtrConfig.ShowSiteBackTextBackground)
            {
                var backgroundRectangle = new Rectangle(usableRectangle.X + (int)(maxTextBoxWidth * .2), usableRectangle.Y + yOffset - (int)(resourceNameTextHeight * 1.5), (int)(maxTextBoxWidth * .6), resourceNameTextHeight + textHeight);
                graphics.FillRectangle(new SolidBrush(Color.White), backgroundRectangle);
            }
            //graphics.FillRectangle(new SolidBrush(Color.Blue), textRectangle);
            GraphicsUtilities.DrawString(graphics, resourceNameText, cardNameFont, GraphicsUtilities.BlackBrush, resourceNameTextRectangle, GraphicsUtilities.HorizontalCenterAlignment);
            GraphicsUtilities.DrawString(graphics, outOfTownSiteText, costFont, GraphicsUtilities.BlackBrush, outOfTownSiteTextRectangle, GraphicsUtilities.HorizontalCenterAlignment);

            return(cardImage);
        }
Esempio n. 4
0
        private void PrintCardName(string name, CardImage cardImage, Brush brush, bool addTranslucentBackground, int xOffset, int maxTextBoxWidth, int yOffset)
        {
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;
            var cardNameFont    = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var text            = string.Join(
                "  ",
                name.ToUpper()
                .Split(' ')
                .Select(token => AddNonBreakingNarrowSpaces(token))
                .ToList());
            var initialRectangle = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y, maxTextBoxWidth, usableRectangle.Height);
            var textMeasurement  = graphics.MeasureString(text, cardNameFont, new SizeF(initialRectangle.Width, initialRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var textHeight       = (int)Math.Ceiling(textMeasurement.Height);
            var textRectangle    = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, maxTextBoxWidth, textHeight);

            if (addTranslucentBackground)
            {
                graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.White)), textRectangle);
            }
            //graphics.FillRectangle(new SolidBrush(Color.Blue), textRectangle);
            GraphicsUtilities.DrawString(graphics, text, cardNameFont, brush, textRectangle, GraphicsUtilities.HorizontalCenterAlignment);
        }
Esempio n. 5
0
        private void DrawSiteCost(CardImage cardImage, CardSuit suit)
        {
            var graphics         = cardImage.Graphics;
            var fullRectangle    = cardImage.FullRectangle;
            var usableRectangle  = cardImage.UsableRectangle;
            var costRegionHeight = (int)(fullRectangle.Height * SiteCostRegionHeightPercentage);
            var costRectangle    = new Rectangle(fullRectangle.Left, fullRectangle.Bottom - costRegionHeight, fullRectangle.Width, costRegionHeight);
            var costRegion       = new Region(costRectangle);
            var oldClip          = graphics.Clip;

            graphics.Clip = costRegion;
            var       barThickness = (int)(fullRectangle.Width / diagonalLinesPerCard);
            var       strokeWidth  = (int)Math.Sqrt(Math.Pow(barThickness, 2) / 2);
            var       pen          = new Pen(suit.Color(), strokeWidth);
            const int extra        = 25;

            for (var xOffset = -2 * fullRectangle.Width + 10; xOffset < fullRectangle.Width; xOffset += barThickness * 2)
            {
                graphics.DrawLine(pen, fullRectangle.Left + xOffset - extra, fullRectangle.Bottom + extra, fullRectangle.Left + fullRectangle.Height + xOffset + extra, fullRectangle.Top - extra);
            }
            graphics.Clip = oldClip;
            var material            = suit.Cost() > 1 ? "materials" : "material";
            var costText            = AddHairSpaces($"foundation +{suit.Cost()} {material}");
            var costFont            = new Font(headerFontFamily, siteCardCostTextFontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            var costTextMeasurement = graphics.MeasureString(costText, costFont, fullRectangle.Width);
            var costTextWidth       = (int)Math.Ceiling(costTextMeasurement.Width);
            var costTextHeight      = (int)costTextMeasurement.Height;
            var costTextRectangle   = new Rectangle(
                fullRectangle.Width / 2 - costTextWidth / 2,
                (int)(costRectangle.Top + costRectangle.Height * .1f),
                costTextWidth,
                costTextHeight);

            graphics.FillRectangle(new SolidBrush(Color.White), costTextRectangle);
            GraphicsUtilities.DrawString(graphics, costText, costFont, GraphicsUtilities.BlackBrush, costTextRectangle);
        }
Esempio n. 6
0
        public CardImage CreateSiteFront(CardSuit suit)
        {
            var name            = $"{suit.ResourceName()}_Site";
            var cardImage       = new CardImage(name, ImageOrientation.Portrait);
            var graphics        = cardImage.Graphics;
            var fullRectangle   = cardImage.FullRectangle;
            var usableRectangle = cardImage.UsableRectangle;

            cardImage.PrintCardBorderAndBackground(Color.White, Color.White);

            DrawSiteCost(cardImage, suit);

            var costRegionHeight             = (int)(fullRectangle.Height * SiteCostRegionHeightPercentage);
            var costImagePaddingHeight       = (int)(fullRectangle.Height * SiteResourceSectionPaddingPercentage);
            var costImageTopPaddingHeight    = costImagePaddingHeight / 2;
            var costImageBottomPaddingHeight = costImagePaddingHeight / 2;
            var costImageSectionHeight       = (int)(fullRectangle.Height * SiteResourceHeightPercentage);
            var costImageHeight    = costImageSectionHeight - costImagePaddingHeight;
            var costImageRectangle = new Rectangle(
                usableRectangle.X,
                fullRectangle.Y + (fullRectangle.Bottom - (costRegionHeight + costImageBottomPaddingHeight + costImageHeight)),
                usableRectangle.Width,
                costImageHeight);

            //graphics.FillRectangle(new SolidBrush(Color.Blue), costImageRectangle);
            GraphicsUtilities.PrintScaledAndCenteredPng(
                graphics,
                $@"Resources\{suit.ResourceName()}",
                costImageRectangle.X,
                costImageRectangle.Y,
                costImageRectangle.Width,
                costImageRectangle.Height);

            var cardNameFont     = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var text             = AddHairSpaces(suit.ResourceName().ToUpper());
            var maxTextBoxWidth  = usableRectangle.Width;
            var initialRectangle = new Rectangle(usableRectangle.X, usableRectangle.Y, maxTextBoxWidth, usableRectangle.Height);
            var textMeasurement  = graphics.MeasureString(text, cardNameFont, new SizeF(initialRectangle.Width, initialRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var textHeight       = (int)Math.Ceiling(textMeasurement.Height);
            var yOffset          = fullRectangle.Bottom - (costRegionHeight + costImageSectionHeight + textHeight);
            var textRectangle    = new Rectangle(usableRectangle.X, usableRectangle.Y + yOffset, maxTextBoxWidth, textHeight);

            graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.White)), textRectangle);
            //graphics.FillRectangle(new SolidBrush(Color.Blue), textRectangle);
            GraphicsUtilities.DrawString(graphics, text, cardNameFont, GraphicsUtilities.BlackBrush, textRectangle, GraphicsUtilities.HorizontalCenterAlignment);

            var centerPoint = usableRectangle.X + usableRectangle.Width / 2;

            var coinOffsetCount = 0f;

            switch (suit.Cost())
            {
            case 1:
                coinOffsetCount = -.5f;
                break;

            case 2:
                coinOffsetCount = -1;
                break;

            case 3:
                coinOffsetCount = -1.5f;
                break;
            }
            var siteCoinPadding = SiteCoinPadding(cardImage);
            var siteCoinWidth   = SiteCoinWidth(cardImage);
            var xOffset         = (int)(coinOffsetCount * siteCoinWidth + (coinOffsetCount + .5f) * siteCoinPadding);

            for (var i = 0; i < suit.Cost(); i++)
            {
                GraphicsUtilities.PrintScaledPng(
                    graphics,
                    $@"Misc\Coin",
                    centerPoint + xOffset + (i * (siteCoinWidth + siteCoinPadding)),
                    usableRectangle.Y,
                    siteCoinWidth,
                    siteCoinWidth);
            }

            return(cardImage);
        }