コード例 #1
0
 /// <param name="width">Twips</param>
 public TextCell(string text, int width, int borderWidth = 10, TextAlignement horizontalAlignement = TextAlignement.Left, bool isBold = false)
 {
     Text           = text;
     TextAlignement = horizontalAlignement;
     IsBold         = isBold;
     Width          = width;
     BorderWidth    = borderWidth;
 }
コード例 #2
0
        public static void DrawString(this SpriteBatch spriteBatch, SpriteFont font, string text, Rectangle boundary,
                                      TextAlignement alignement, TextStyle style, Color color, float scale = 1f)
        {
            var textSize = font.MeasureString(text) * scale;
            var pos      = boundary.Center.ToVector2();
            var origin   = textSize / 2;

            if (alignement.HasFlag(TextAlignement.Left))
            {
                origin.X += boundary.Width / 2f - textSize.X / 2;
            }

            if (alignement.HasFlag(TextAlignement.Right))
            {
                origin.X -= boundary.Width / 2f - textSize.X / 2;
            }

            if (alignement.HasFlag(TextAlignement.Top))
            {
                origin.Y += boundary.Height / 2f - textSize.Y / 2;
            }

            if (alignement.HasFlag(TextAlignement.Bottom))
            {
                origin.Y -= boundary.Height / 2f - textSize.Y / 2;
            }

            switch (style)
            {
            case TextStyle.Bold:
                spriteBatch.DrawString(font, text, new Vector2(pos.X + 1, pos.Y + 1), color, 0, origin, 1,
                                       SpriteEffects.None, 0);
                break;

            case TextStyle.DropShadow:
                spriteBatch.DrawString(font, text, pos - origin + new Vector2(2 * Rise.Ui.ScaleFactor),
                                       new Color(0, 0, 0, (int)(100f * (color.A / 255f))), 0, Vector2.Zero, scale,
                                       SpriteEffects.None, 0);
                break;

            case TextStyle.Rectangle:
                spriteBatch.FillRectangle(
                    new Rectangle((pos - origin).ToPoint(),
                                  new Point((int)textSize.X, (int)textSize.Y)), Color.Black * 0.5f);
                break;
            }

            spriteBatch.DrawString(font, text, pos - origin, color, 0f, Vector2.Zero, new Vector2(scale, scale),
                                   SpriteEffects.None, 1f);
        }
コード例 #3
0
        protected void AddText(ShapedGraphic graphic, string text,
                               bool bold = false, TextAlignement align = TextAlignement.Center)
        {
            var str = (bold ? @"\b " : "");

            str += (align == TextAlignement.Left ? @"\ql " : "");
            str += (align == TextAlignement.Right ? @"\qr " : "");
            str += (align == TextAlignement.Center ? @"\qc " : "");
            str += GetRtfUnicodeEscapedString(text);

            graphic.Text = new Omnigraffle.TextInfo(str)
            {
                Alignement      = KAOSTools.OmnigraffleExport.Omnigraffle.TextAlignement.Center,
                SideMargin      = 10,
                TopBottomMargin = 3
            };
            graphic.Style.Shadow.Draws = false;
            graphic.FitText            = KAOSTools.OmnigraffleExport.Omnigraffle.FitText.Vertical;
            graphic.Flow          = KAOSTools.OmnigraffleExport.Omnigraffle.Flow.Resize;
            graphic.FontInfo.Size = 10;
        }
コード例 #4
0
 public TextInfo(string text)
 {
     Text       = text;
     Alignement = TextAlignement.Left;
     SideMargin = 0; TopBottomMargin = 0;
 }
コード例 #5
0
        protected void AddText(ShapedGraphic graphic, string text, 
                                bool bold = false, TextAlignement align = TextAlignement.Center)
        {
            var str = (bold ? @"\b " : "");
            str += (align == TextAlignement.Left ? @"\ql " : "");
            str += (align == TextAlignement.Right ? @"\qr " : "");
            str += (align == TextAlignement.Center ? @"\qc " : "");
            str += GetRtfUnicodeEscapedString (text);

            graphic.Text = new Omnigraffle.TextInfo (str) {
                Alignement = KAOSTools.OmnigraffleExport.Omnigraffle.TextAlignement.Center,
                SideMargin = 10,
                TopBottomMargin = 3
            };
            graphic.Style.Shadow.Draws = false;
            graphic.FitText = KAOSTools.OmnigraffleExport.Omnigraffle.FitText.Vertical;
            graphic.Flow = KAOSTools.OmnigraffleExport.Omnigraffle.Flow.Resize;
            graphic.FontInfo.Size = 10;
        }