本文整理汇总了C#中Paragraph.ToLines方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.ToLines方法的具体用法?C# Paragraph.ToLines怎么用?C# Paragraph.ToLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paragraph
的用法示例。
在下文中一共展示了Paragraph.ToLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
++frames;
var fx = e.Graphics;
using ( var buffer = new Bitmap( ClientSize.Width, ClientSize.Height ) ) {
using ( var clr = Graphics.FromImage(buffer) ) clr.Clear( Color.Transparent );
var target = buffer.LockBits( ClientRectangle, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
int y = 0;
while ( y < ClientSize.Height ) {
#if false
string text = "Hello, World!";
Font.RenderLineTo( target, text, new Rectangle(0,y,ClientSize.Width,ClientSize.Height-y), Industry.FX.HorizontalAlignment.Center, VerticalAlignment.Top );
y += Font.MeasureLine(text).Advance.Y;
#else
Paragraph text = new Paragraph();
text.Add( new TextRun() { Font = RedFont , Text = "He" } );
text.Add( new TextRun() { Font = BlueFont, Text = "llo, W" } );
text.Add( new TextRun() { Font = RedFont , Text = "orld!" } );
var lines = text.ToLines(ClientSize.Width);
FX.Font.RenderLinesTo( target, lines, new Rectangle(0,y,ClientSize.Width,int.MaxValue), FX.HorizontalAlignment.Center, VerticalAlignment.Top );
y += FX.Font.MeasureLines(lines).Advance.Y;
#endif
}
DateTime now = DateTime.Now;
var span = now-prev;
if ( span.TotalSeconds >= 1.0 ) {
prev = now;
framedisplay = frames;
frames = 0;
}
RedFont.RenderLineTo( target, "FPS: "+framedisplay, ClientRectangle, Industry.FX.HorizontalAlignment.Right, VerticalAlignment.Top );
buffer.UnlockBits(target);
fx.DrawImage(buffer,0,0);
}
Invalidate();
}