Graphics.DrawPolygon Graphics.DrawPolygon Graphics.DrawPolygon Method

Определение

Рисует многоугольник, определяемый массивом структур Point.Draws a polygon defined by an array of Point structures.

Перегрузки

DrawPolygon(Pen, PointF[]) DrawPolygon(Pen, PointF[]) DrawPolygon(Pen, PointF[])

Рисует многоугольник, определяемый массивом структур PointF.Draws a polygon defined by an array of PointF structures.

DrawPolygon(Pen, Point[]) DrawPolygon(Pen, Point[]) DrawPolygon(Pen, Point[])

Рисует многоугольник, определяемый массивом структур Point.Draws a polygon defined by an array of Point structures.

DrawPolygon(Pen, PointF[]) DrawPolygon(Pen, PointF[]) DrawPolygon(Pen, PointF[])

Рисует многоугольник, определяемый массивом структур PointF.Draws a polygon defined by an array of PointF structures.

public:
 void DrawPolygon(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points);
public void DrawPolygon (System.Drawing.Pen pen, System.Drawing.PointF[] points);
member this.DrawPolygon : System.Drawing.Pen * System.Drawing.PointF[] -> unit

Параметры

pen
Pen Pen Pen

Структура Pen, определяющая цвет, ширину и стиль многоугольника.Pen that determines the color, width, and style of the polygon.

points
PointF[]

Массив структур PointF, которые представляют собой вершины многоугольника.Array of PointF structures that represent the vertices of the polygon.

Исключения

Свойство pen имеет значение null.pen is null.

-или--or- pointsnull.points is null.

Примеры

Следующий пример кода предназначен для использования с Windows Forms и требует PaintEventArgs e, что Paint является параметром обработчика событий.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. Код выполняет следующие действия.The code performs the following actions:

  • Создает черное перо.Creates a black pen.

  • Создает массив из семи точек для вершин многоугольника.Creates an array of seven points for the vertices of the polygon.

  • Рисует многоугольник на экране.Draws the polygon to the screen.

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

      // Create points that define polygon.
      PointF point1 = PointF(50.0F,50.0F);
      PointF point2 = PointF(100.0F,25.0F);
      PointF point3 = PointF(200.0F,5.0F);
      PointF point4 = PointF(250.0F,50.0F);
      PointF point5 = PointF(300.0F,100.0F);
      PointF point6 = PointF(350.0F,200.0F);
      PointF point7 = PointF(250.0F,250.0F);
      array<PointF>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

      // Draw polygon curve to screen.
      e->Graphics->DrawPolygon( blackPen, curvePoints );
   }
public void DrawPolygonPointF(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points that define polygon.
    PointF point1 = new PointF(50.0F,  50.0F);
    PointF point2 = new PointF(100.0F,  25.0F);
    PointF point3 = new PointF(200.0F,   5.0F);
    PointF point4 = new PointF(250.0F,  50.0F);
    PointF point5 = new PointF(300.0F, 100.0F);
    PointF point6 = new PointF(350.0F, 200.0F);
    PointF point7 = new PointF(250.0F, 250.0F);
    PointF[] curvePoints =
             {
                 point1,
                 point2,
                 point3,
                 point4,
                 point5,
                 point6,
                 point7
             };
             
    // Draw polygon curve to screen.
    e.Graphics.DrawPolygon(blackPen, curvePoints);
}
Public Sub DrawPolygonPointF(ByVal e As PaintEventArgs)

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

    ' Create points that define polygon.
    Dim point1 As New PointF(50.0F, 50.0F)
    Dim point2 As New PointF(100.0F, 25.0F)
    Dim point3 As New PointF(200.0F, 5.0F)
    Dim point4 As New PointF(250.0F, 50.0F)
    Dim point5 As New PointF(300.0F, 100.0F)
    Dim point6 As New PointF(350.0F, 200.0F)
    Dim point7 As New PointF(250.0F, 250.0F)
    Dim curvePoints As PointF() = {point1, point2, point3, point4, _
    point5, point6, point7}

    ' Draw polygon curve to screen.
    e.Graphics.DrawPolygon(blackPen, curvePoints)
End Sub

Комментарии

Каждая пара двух последовательных точек в массиве указывает сторону многоугольника.Every pair of two consecutive points in the array specifies a side of the polygon. Кроме того, если последняя и первая точки массива не совпадают, они указывают последнюю сторону многоугольника.In addition, if the last point and the first of the array point do not coincide, they specify the last side of the polygon.

DrawPolygon(Pen, Point[]) DrawPolygon(Pen, Point[]) DrawPolygon(Pen, Point[])

Рисует многоугольник, определяемый массивом структур Point.Draws a polygon defined by an array of Point structures.

public:
 void DrawPolygon(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points);
public void DrawPolygon (System.Drawing.Pen pen, System.Drawing.Point[] points);
member this.DrawPolygon : System.Drawing.Pen * System.Drawing.Point[] -> unit

Параметры

pen
Pen Pen Pen

Структура Pen, определяющая цвет, ширину и стиль многоугольника.Pen that determines the color, width, and style of the polygon.

points
Point[]

Массив структур Point, которые представляют собой вершины многоугольника.Array of Point structures that represent the vertices of the polygon.

Исключения

Примеры

Следующий пример кода предназначен для использования с Windows Forms и требует PaintEventArgs e, что Paint является параметром обработчика событий.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. Код выполняет следующие действия.The code performs the following actions:

  • Создает черное перо.Creates a black pen.

  • Создает массив из семи точек для вершин многоугольника.Creates an array of seven points for the vertices of the polygon.

  • Рисует многоугольник на экране.Draws the polygon to the screen.

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

      // Create points that define polygon.
      Point point1 = Point(50,50);
      Point point2 = Point(100,25);
      Point point3 = Point(200,5);
      Point point4 = Point(250,50);
      Point point5 = Point(300,100);
      Point point6 = Point(350,200);
      Point point7 = Point(250,250);
      array<Point>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7};

      // Draw polygon to screen.
      e->Graphics->DrawPolygon( blackPen, curvePoints );
   }
public void DrawPolygonPoint(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points that define polygon.
    Point point1 = new Point(50,  50);
    Point point2 = new Point(100,  25);
    Point point3 = new Point(200,   5);
    Point point4 = new Point(250,  50);
    Point point5 = new Point(300, 100);
    Point point6 = new Point(350, 200);
    Point point7 = new Point(250, 250);
    Point[] curvePoints =
             {
                 point1,
                 point2,
                 point3,
                 point4,
                 point5,
                 point6,
                 point7
             };
             
    // Draw polygon to screen.
    e.Graphics.DrawPolygon(blackPen, curvePoints);
}
Public Sub DrawPolygonPoint(ByVal e As PaintEventArgs)

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

    ' Create points that define polygon.
    Dim point1 As New Point(50, 50)
    Dim point2 As New Point(100, 25)
    Dim point3 As New Point(200, 5)
    Dim point4 As New Point(250, 50)
    Dim point5 As New Point(300, 100)
    Dim point6 As New Point(350, 200)
    Dim point7 As New Point(250, 250)
    Dim curvePoints As Point() = {point1, point2, point3, point4, _
    point5, point6, point7}

    ' Draw polygon to screen.
    e.Graphics.DrawPolygon(blackPen, curvePoints)
End Sub

Комментарии

Каждая пара двух последовательных точек в массиве указывает сторону многоугольника.Every pair of two consecutive points in the array specifies a side of the polygon. Кроме того, если последняя и первая точки массива не совпадают, они указывают последнюю сторону многоугольника.In addition, if the last point and the first point of the array do not coincide, they specify the last side of the polygon.

Применяется к