カスタム ペンは次のように使用できます。
using (Pen pen = new Pen(Color.Gray, 4f) )
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen.DashPattern = new float[] { 0.25F, 0.25F };
// now draw your stuff..
}
MSDNのドキュメントに注意してください。
The elements in the dashArray array set the length of each dash
and space in the dash pattern. The first element sets the length of a dash,
the second element sets the length of a space, the third element sets
the length of a dash, and so on. Consequently, each element should be a
non-zero positive number.
The length of each dash and space in the dash pattern is the product
of the element value in the array and the width of the Pen.
関係を念頭に置いている限り、ペンの幅とダッシュとギャップの長さを選択できます。したがって、最高のダッシュが必要な場合は、1.0 ピクセルに乗算するようにしてください。
結果の行は次のとおりです。
