C#でツールを作る その2-文字列の描画-
まずは描画の基本、文字列ですね。
ソース
- フォントの作成
- 文字列の描画
namespace WindowsFormsApplication1 { public partial class Form1 : Form { /*...*/ private Microsoft.DirectX.Direct3D.Font font = null; /*...*/ private void Form1_Load(object sender, EventArgs e) { /*...*/ FontDescription fd = new FontDescription(); fd.Height = 16; fd.FaceName = "MS ゴシック"; font = new Microsoft.DirectX.Direct3D.Font( device, fd ); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { if (font != null) { font.Dispose(); font = null; } /*...*/ } private void Form1_Paint(object sender, PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.FromArgb( 0x333333 ), 1.0f, 0); device.BeginScene(); font.DrawText( null, "hoge", 0, 0, Color.White ); device.EndScene(); device.Present(); } } }