C# を使用して、Windows Mobile アプリケーションの致命的なエラー ダイアログを作成しています。問題は、を使用してスタックトレースを描画しようとすると、文字の折り返しではなく単語の折り返しを使用DrawString
するため、スタックトレースの半分が切り取られることです。DrawString
説明が分からない方へ:
スタックトレースを描画すると、次のようになります。
at
company.application.name.space.Funct
at
company.application.name.Function(St
at
etc. etc.
そして、私はそれを次のように印刷したい:
at
company.application.name.space.Funct
ion(String sometext, Int32 somenumbe
r)
at
company.application.name.Function(St
ring sometext, Int32 somenumber, Int
32 anothernumber)
at
etc. etc.
これは Csharp で可能ですか?
問題の再現:
新しいスマート デバイス プロジェクトを作成します。(デバイスアプリケーション)
Form1 コードを次のように置き換えます。
public partial class Form1 : Form { RectangleF _rect = new RectangleF(); String _stackTrace = @"at System.Net.Sockets.Socket.ReceiveNoCheck(Byte[] buffer, Int32 index, Int32 request, SocketFlags socketFlags) at System.Net.Sockets.Socket.ReceiveAsyncRequest.doRequest() at System.Net.Sockets.Socket.AsyncRequest.handleRequest() at System.Net.Sockets.Socket.WorkerThread.doWork() at System.Net.Sockets.Socket.WorkerThread.doWorkI(Object o) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()"; protected override void ScaleControl(SizeF factor, BoundsSpecified specified) { _rect.X = 24 * factor.Width; _rect.Y = 10 * factor.Height; _rect.Width = 192 * factor.Width; _rect.Height = 274 * factor.Height; } public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (Pen borderPen = new Pen(this.ForeColor, 1)) { Rectangle borderRect = Rectangle.Round(_rect); borderRect.Inflate(1, 1); e.Graphics.DrawRectangle(borderPen, borderRect); } using (StringFormat stringFormat = new StringFormat()) using (SolidBrush stringBrush = new SolidBrush(this.ForeColor)) { e.Graphics.DrawString(_stackTrace, this.Font, stringBrush, _rect, stringFormat); } }
}
プロジェクトを実行します。