Graphics.DrawRectangles Metoda

Definicja

Rysuje serię prostokątów określonych przez struktury Rectangle.

Przeciążenia

DrawRectangles(Pen, Rectangle[])

Rysuje serię prostokątów określonych przez struktury Rectangle.

DrawRectangles(Pen, RectangleF[])

Rysuje serię prostokątów określonych przez struktury RectangleF.

DrawRectangles(Pen, ReadOnlySpan<Rectangle>)
DrawRectangles(Pen, ReadOnlySpan<RectangleF>)

DrawRectangles(Pen, Rectangle[])

Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs

Rysuje serię prostokątów określonych przez struktury Rectangle.

C#
public void DrawRectangles (System.Drawing.Pen pen, System.Drawing.Rectangle[] rects);
C#
public void DrawRectangles (System.Drawing.Pen pen, params System.Drawing.Rectangle[] rects);

Parametry

pen
Pen

Pen, który określa kolor, szerokość i styl konturów prostokątów.

rects
Rectangle[]

Tablica struktur Rectangle reprezentujących prostokąty do rysowania.

Wyjątki

pen jest null.

-lub-

rects jest null.

rects jest tablicą o zerowej długości.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:

  • Tworzy długopis.

  • Tworzy tablicę trzech prostokątów.

  • Rysuje prostokąty na ekranie.

C#
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);
}

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawRectangles(Pen, RectangleF[])

Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs
Źródło:
Graphics.cs

Rysuje serię prostokątów określonych przez struktury RectangleF.

C#
public void DrawRectangles (System.Drawing.Pen pen, System.Drawing.RectangleF[] rects);
C#
public void DrawRectangles (System.Drawing.Pen pen, params System.Drawing.RectangleF[] rects);

Parametry

pen
Pen

Pen, który określa kolor, szerokość i styl konturów prostokątów.

rects
RectangleF[]

Tablica struktur RectangleF reprezentujących prostokąty do rysowania.

Wyjątki

pen jest null.

-lub-

rects jest null.

rects jest tablicą o zerowej długości.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:

  • Tworzy długopis.

  • Tworzy tablicę trzech prostokątów.

  • Rysuje prostokąty na ekranie.

C#
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);
}

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawRectangles(Pen, ReadOnlySpan<Rectangle>)

Źródło:
Graphics.cs
Źródło:
Graphics.cs
C#
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Rectangle> rects);

Parametry

pen
Pen

Dotyczy

.NET 9 i Windows Desktop 9
Produkt Wersje
.NET 9
Windows Desktop 9

DrawRectangles(Pen, ReadOnlySpan<RectangleF>)

Źródło:
Graphics.cs
Źródło:
Graphics.cs
C#
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.RectangleF> rects);

Parametry

pen
Pen

Dotyczy

.NET 9 i Windows Desktop 9
Produkt Wersje
.NET 9
Windows Desktop 9