Bagikan melalui


Graphics.DrawLines Metode

Definisi

Menggambar serangkaian segmen garis yang menyambungkan array struktur Point.

Overload

DrawLines(Pen, ReadOnlySpan<Point>)
DrawLines(Pen, ReadOnlySpan<PointF>)
DrawLines(Pen, Point[])

Menggambar serangkaian segmen garis yang menyambungkan array struktur Point.

DrawLines(Pen, PointF[])

Menggambar serangkaian segmen garis yang menyambungkan array struktur PointF.

DrawLines(Pen, ReadOnlySpan<Point>)

Sumber:
Graphics.cs
Sumber:
Graphics.cs
public:
 void DrawLines(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::Point> points);
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);
member this.DrawLines : System.Drawing.Pen * ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub DrawLines (pen As Pen, points As ReadOnlySpan(Of Point))

Parameter

pen
Pen

Berlaku untuk

DrawLines(Pen, ReadOnlySpan<PointF>)

Sumber:
Graphics.cs
Sumber:
Graphics.cs
public:
 void DrawLines(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::PointF> points);
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);
member this.DrawLines : System.Drawing.Pen * ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub DrawLines (pen As Pen, points As ReadOnlySpan(Of PointF))

Parameter

pen
Pen

Berlaku untuk

DrawLines(Pen, Point[])

Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs

Menggambar serangkaian segmen garis yang menyambungkan array struktur Point.

public:
 void DrawLines(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points);
public:
 void DrawLines(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::Point> ^ points);
public void DrawLines (System.Drawing.Pen pen, System.Drawing.Point[] points);
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.Point[] points);
member this.DrawLines : System.Drawing.Pen * System.Drawing.Point[] -> unit
Public Sub DrawLines (pen As Pen, points As Point())
Public Sub DrawLines (pen As Pen, ParamArray points As Point())

Parameter

pen
Pen

Pen yang menentukan warna, lebar, dan gaya segmen garis.

points
Point[]

Array struktur Point yang mewakili titik yang akan disambungkan.

Pengecualian

pen null.

-atau-

points null.

Contoh

Contoh kode berikut dirancang untuk digunakan dengan Windows Forms, dan memerlukan PaintEventArgse, yang merupakan parameter penanganan aktivitas Paint. Kode melakukan tindakan berikut:

  • Membuat pena hitam.

  • Membuat array titik segmen garis.

  • Menggambar segmen garis yang tersambung ke layar.

public:
   void DrawLinesPoint( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ pen = gcnew Pen( Color::Black,3.0f );

      // Create array of points that define lines to draw.
      array<Point>^ points = {Point(10,10),Point(10,100),Point(200,50),Point(250,300)};

      //Draw lines to screen.
      e->Graphics->DrawLines( pen, points );
   }
public void DrawLinesPoint(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    Point[] points =
             {
                 new Point(10,  10),
                 new Point(10, 100),
                 new Point(200,  50),
                 new Point(250, 300)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, points);
}
Public Sub DrawLinesPoint(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create array of points that define lines to draw.
    Dim points As Point() = {New Point(10, 10), New Point(10, 100), _
    New Point(200, 50), New Point(250, 300)}

    'Draw lines to screen.
    e.Graphics.DrawLines(blackPen, points)
End Sub

Keterangan

Metode ini menggambar serangkaian garis yang menghubungkan array titik akhir. Dua poin pertama dalam array menentukan baris pertama. Setiap titik tambahan menentukan akhir segmen garis yang titik awalnya adalah titik akhir segmen baris sebelumnya.

Berlaku untuk

DrawLines(Pen, PointF[])

Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs
Sumber:
Graphics.cs

Menggambar serangkaian segmen garis yang menyambungkan array struktur PointF.

public:
 void DrawLines(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points);
public:
 void DrawLines(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::PointF> ^ points);
public void DrawLines (System.Drawing.Pen pen, System.Drawing.PointF[] points);
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.PointF[] points);
member this.DrawLines : System.Drawing.Pen * System.Drawing.PointF[] -> unit
Public Sub DrawLines (pen As Pen, points As PointF())
Public Sub DrawLines (pen As Pen, ParamArray points As PointF())

Parameter

pen
Pen

Pen yang menentukan warna, lebar, dan gaya segmen garis.

points
PointF[]

Array struktur PointF yang mewakili titik yang akan disambungkan.

Pengecualian

pen null.

-atau-

points null.

Contoh

Contoh kode berikut dirancang untuk digunakan dengan Windows Forms, dan memerlukan PaintEventArgse, yang merupakan parameter penanganan aktivitas Paint. Kode melakukan tindakan berikut:

  • Kode membuat pena hitam.

  • Membuat array titik segmen garis.

  • Menggambar segmen garis yang tersambung ke layar.

public:
   void DrawLinesPointF( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ pen = gcnew Pen( Color::Black,3.0f );

      // Create array of points that define lines to draw.
      array<PointF>^ points = {PointF(10.0F,10.0F),PointF(10.0F,100.0F),PointF(200.0F,50.0F),PointF(250.0F,300.0F)};

      //Draw lines to screen.
      e->Graphics->DrawLines( pen, points );
   }
public void DrawLinesPointF(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    PointF[] points =
             {
                 new PointF(10.0F,  10.0F),
                 new PointF(10.0F, 100.0F),
                 new PointF(200.0F,  50.0F),
                 new PointF(250.0F, 300.0F)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, points);
}
Public Sub DrawLinesPointF(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create array of points that define lines to draw.
    Dim points As PointF() = {New PointF(10.0F, 10.0F), _
    New PointF(10.0F, 100.0F), New PointF(200.0F, 50.0F), _
    New PointF(250.0F, 300.0F)}

    'Draw lines to screen.
    e.Graphics.DrawLines(blackPen, points)
End Sub

Keterangan

Metode ini menggambar serangkaian garis yang menghubungkan array titik akhir. Dua poin pertama dalam array menentukan baris pertama. Setiap titik tambahan menentukan akhir segmen garis yang titik awalnya adalah titik akhir segmen baris sebelumnya.

Berlaku untuk