Ejemplo n.º 1
0
        private void PrintCardText(string text, CardImage cardImage, int top, int textBoxWidth, int textRectangleHeight, int xOffset, bool addTranslucentBackground, Brush defaultBrush)
        {
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;
            var rectangle       = new Rectangle(usableRectangle.X + xOffset, top, textBoxWidth, textRectangleHeight);
            var words           = text.Split(new[] { " " }, StringSplitOptions.None);
            var fragments       = words
                                  .Select(word => GetFragmentForWord(word, defaultBrush))
                                  .ToList();

            GraphicsUtilities.DrawFragmentsCentered(graphics, fragments, rectangle, addTranslucentBackground);
        }
Ejemplo n.º 2
0
        private void PrintCardName(string name, CardImage cardImage, Brush brush, int translucentBackgroundOpacity, int xOffset, int maxTextBoxWidth, int yOffset)
        {
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var usableRectangle = cardImage.UsableRectangle;
            var cardNameFont    = new Font(boldFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var fragments       = name.ToUpper().Split(" ")
                                  .Select((word, index) => new TextFragment
            {
                Brush         = brush,
                Font          = cardNameFont,
                ForcesNewline = index > 0,
                Text          = AddThreePerEmSpaces(word)
            })
                                  .ToList();
            var textRectangle = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, maxTextBoxWidth, usableRectangle.Height);

            GraphicsUtilities.DrawFragmentsCentered(graphics, fragments, textRectangle, translucentBackgroundOpacity, false, false);
        }
Ejemplo n.º 3
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);
        }