Graphics.DrawRectangles Graphics.DrawRectangles Graphics.DrawRectangles Method

정의

Rectangle 구조체에 의해 지정된 일련의 사각형을 그립니다.Draws a series of rectangles specified by Rectangle structures.

오버로드

DrawRectangles(Pen, Rectangle[]) DrawRectangles(Pen, Rectangle[]) DrawRectangles(Pen, Rectangle[])

Rectangle 구조체에 의해 지정된 일련의 사각형을 그립니다.Draws a series of rectangles specified by Rectangle structures.

DrawRectangles(Pen, RectangleF[]) DrawRectangles(Pen, RectangleF[]) DrawRectangles(Pen, RectangleF[])

RectangleF 구조체에 의해 지정된 일련의 사각형을 그립니다.Draws a series of rectangles specified by RectangleF structures.

DrawRectangles(Pen, Rectangle[]) DrawRectangles(Pen, Rectangle[]) DrawRectangles(Pen, Rectangle[])

Rectangle 구조체에 의해 지정된 일련의 사각형을 그립니다.Draws a series of rectangles specified by Rectangle structures.

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

매개 변수

pen
Pen Pen Pen

사각형 윤곽선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the outlines of the rectangles.

rects
Rectangle[]

그릴 사각형을 나타내는 Rectangle 구조체의 배열입니다.Array of Rectangle structures that represent the rectangles to draw.

예외

pennull입니다.pen is null.

또는-or- rectsnull인 경우rects is null.

rects이 길이가 0인 배열입니다.rects is a zero-length array.

예제

다음 코드 예제는 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:

  • Black 펜을 만듭니다.Creates a black pen.

  • 세 개의 사각형의 배열을 만듭니다.Creates an array of three rectangles.

  • 화면에 사각형을 그립니다.Draws the rectangles to the screen.

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

      // Create array of rectangles.
      array<Rectangle>^ rects = {Rectangle(0,0,100,200),Rectangle(100,200,250,50),Rectangle(300,0,50,100)};

      // Draw rectangles to screen.
      e->Graphics->DrawRectangles( blackPen, rects );
   }
public void DrawRectanglesRectangle(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create array of rectangles.
    Rectangle[] rects =
             {
                 new Rectangle( 0,   0, 100, 200),
                 new Rectangle(100, 200, 250,  50),
                 new Rectangle(300,   0,  50, 100)
             };
             
    // Draw rectangles to screen.
    e.Graphics.DrawRectangles(blackPen, rects);
}
Public Sub DrawRectanglesRectangle(ByVal e As PaintEventArgs)

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

    ' Create array of rectangles.
    Dim rects As Rectangle() = {New Rectangle(0, 0, 100, 200), _
    New Rectangle(100, 200, 250, 50), _
    New Rectangle(300, 0, 50, 100)}

    ' Draw rectangles to screen.
    e.Graphics.DrawRectangles(blackPen, rects)
End Sub

DrawRectangles(Pen, RectangleF[]) DrawRectangles(Pen, RectangleF[]) DrawRectangles(Pen, RectangleF[])

RectangleF 구조체에 의해 지정된 일련의 사각형을 그립니다.Draws a series of rectangles specified by RectangleF structures.

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

매개 변수

pen
Pen Pen Pen

사각형 윤곽선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the outlines of the rectangles.

rects
RectangleF[]

그릴 사각형을 나타내는 RectangleF 구조체의 배열입니다.Array of RectangleF structures that represent the rectangles to draw.

예외

pennull입니다.pen is null.

또는-or- rectsnull인 경우rects is null.

rects이 길이가 0인 배열입니다.rects is a zero-length array.

예제

다음 코드 예제는 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:

  • Black 펜을 만듭니다.Creates a black pen.

  • 세 개의 사각형의 배열을 만듭니다.Creates an array of three rectangles.

  • 화면에 사각형을 그립니다.Draws the rectangles to the screen.

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

      // Create array of rectangles.
      array<RectangleF>^ rects = {RectangleF(0.0F,0.0F,100.0F,200.0F),RectangleF(100.0F,200.0F,250.0F,50.0F),RectangleF(300.0F,0.0F,50.0F,100.0F)};

      // Draw rectangles to screen.
      e->Graphics->DrawRectangles( blackPen, rects );
   }
public void DrawRectanglesRectangleF(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create array of rectangles.
    RectangleF[] rects =
             {
                 new RectangleF( 0.0F,   0.0F, 100.0F, 200.0F),
                 new RectangleF(100.0F, 200.0F, 250.0F,  50.0F),
                 new RectangleF(300.0F,   0.0F,  50.0F, 100.0F)
             };
             
    // Draw rectangles to screen.
    e.Graphics.DrawRectangles(blackPen, rects);
}
Public Sub DrawRectanglesRectangleF(ByVal e As PaintEventArgs)

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

    ' Create array of rectangles.
    Dim rects As RectangleF() = {New RectangleF(0.0F, 0.0F, 100.0F, 200.0F), _
    New RectangleF(100.0F, 200.0F, 250.0F, 50.0F), _
    New RectangleF(300.0F, 0.0F, 50.0F, 100.0F)}

    ' Draw rectangles to screen.
    e.Graphics.DrawRectangles(blackPen, rects)
End Sub

적용 대상