Exemplo n.º 1
0
        protected override void OnDraw(GameTime gameTime, RenderContext context)
        {
            base.OnDraw(gameTime, context);

            var text = Text;

            if (!string.IsNullOrWhiteSpace(text))
            {
                var textSize   = DirectWriteHelper.MeasureText(context.DirectWriteFactory, text, _font);
                var lineHeight = DirectWriteHelper.PointToDip(FontSize);
                OnBeforeTextRendering(context, textSize, lineHeight);

                var location = Location;
                context.Begin2D();
                context.DrawText(text, _textBrush, _font, location.X, location.Y);
                context.End2D();
            }
        }
Exemplo n.º 2
0
 public static SizeF MeasureText(this RenderContext context, string text, D2DFont font, float maxWidth, float maxHeight)
 {
     return(DirectWriteHelper.MeasureText(context.DirectWriteFactory, text, font, maxWidth, maxHeight));
 }