Pen.DashPattern プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)

public: property array<float>^ DashPattern { array<float>^ get (); void set (array<float>^ value); }
/** @property */ public float[] get_DashPattern () /** @property */ public void set_DashPattern (float[] value)
破線内の代替ダッシュと空白の長さを指定する実数の配列。

このプロパティに null 参照 (Visual Basic では Nothing) 以外の値を割り当てると、この Pen の DashStyle プロパティが Custom に設定されます。
dashArray 配列の要素は、ダッシュ パターンの各ダッシュと空白の長さを設定します。最初の要素はダッシュの長さ、2 番目の要素は空白の長さ、3 番目の要素は再びダッシュの長さと以降同様に設定します。

次のコード例は、DashCap プロパティ、DashPattern プロパティ、および SmoothingMode プロパティを設定する効果を示しています。
この例は、Windows フォームでの使用を意図してデザインされています。コードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して ShowPensAndSmoothingMode メソッドを呼び出します。
Private Sub ShowPensAndSmoothingMode(ByVal e As PaintEventArgs) ' Set the SmoothingMode property to smooth the line. e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias ' Create a new Pen object. Dim greenPen As New Pen(Color.Green) ' Set the width to 6. greenPen.Width = 6.0F ' Set the DashCap to round. greenPen.DashCap = Drawing2D.DashCap.Round ' Create a custom dash pattern. greenPen.DashPattern = New Single() {4.0F, 2.0F, 1.0F, 3.0F} ' Draw a line. e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F) ' Change the SmoothingMode to none. e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None ' Draw another line. e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F) ' Dispose of the custom pen. greenPen.Dispose() End Sub
private void ShowPensAndSmoothingMode(PaintEventArgs e) { // Set the SmoothingMode property to smooth the line. e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Create a new Pen object. Pen greenPen = new Pen(Color.Green); // Set the width to 6. greenPen.Width = 6.0F; // Set the DashCap to round. greenPen.DashCap = System.Drawing.Drawing2D.DashCap.Round; // Create a custom dash pattern. greenPen.DashPattern = new float[]{4.0F, 2.0F, 1.0F, 3.0F}; // Draw a line. e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F); // Change the SmoothingMode to none. e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; // Draw another line. e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F); // Dispose of the custom pen. greenPen.Dispose(); }
private: void ShowPensAndSmoothingMode( PaintEventArgs^ e ) { // Set the SmoothingMode property to smooth the line. e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias; // Create a new Pen object. Pen^ greenPen = gcnew Pen( Color::Green ); // Set the width to 6. greenPen->Width = 6.0F; // Set the DashCap to round. greenPen->DashCap = System::Drawing::Drawing2D::DashCap::Round; // Create a custom dash pattern. array<Single>^temp0 = {4.0F,2.0F,1.0F,3.0F}; greenPen->DashPattern = temp0; // Draw a line. e->Graphics->DrawLine( greenPen, 20.0F, 20.0F, 100.0F, 240.0F ); // Change the SmoothingMode to none. e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::None; // Draw another line. e->Graphics->DrawLine( greenPen, 100.0F, 240.0F, 160.0F, 20.0F ); // Dispose of the custom pen. delete greenPen; }
private void ShowPensAndSmoothingMode(PaintEventArgs e) { // Set the SmoothingMode property to smooth the line. e.get_Graphics().set_SmoothingMode( System.Drawing.Drawing2D.SmoothingMode.AntiAlias); // Create a new Pen object. Pen greenPen = new Pen(Color.get_Green()); // Set the width to 6. greenPen.set_Width(6); // Set the DashCap to round. greenPen.set_DashCap(System.Drawing.Drawing2D.DashCap.Round); // Create a custom dash pattern. greenPen.set_DashPattern(new float[] { 4, 2, 1, 3 }); // Draw a line. e.get_Graphics().DrawLine(greenPen, 20, 20, 100, 240); // Change the SmoothingMode to none. e.get_Graphics().set_SmoothingMode( System.Drawing.Drawing2D.SmoothingMode.None); // Draw another line. e.get_Graphics().DrawLine(greenPen, 100, 240, 160, 20); // Dispose of the custom pen. greenPen.Dispose(); } //ShowPensAndSmoothingMode

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からPen.DashPattern プロパティを検索する場合は、下記のリンクをクリックしてください。

- Pen.DashPattern プロパティのページへのリンク