Leggere in inglese

Condividi tramite


Graphics.DrawRectangles Metodo

Definizione

Disegna una serie di rettangoli specificati da Rectangle strutture.

Overload

DrawRectangles(Pen, Rectangle[])

Disegna una serie di rettangoli specificati da Rectangle strutture.

DrawRectangles(Pen, RectangleF[])

Disegna una serie di rettangoli specificati da RectangleF strutture.

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

DrawRectangles(Pen, Rectangle[])

Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs

Disegna una serie di rettangoli specificati da Rectangle strutture.

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);

Parametri

pen
Pen

Pen che determina il colore, la larghezza e lo stile dei contorni dei rettangoli.

rects
Rectangle[]

Matrice di strutture Rectangle che rappresentano i rettangoli da disegnare.

Eccezioni

pen è null.

-o-

rects è null.

rects è una matrice di lunghezza zero.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:

  • Crea una penna nera.

  • Crea una matrice di tre rettangoli.

  • Disegna i rettangoli sullo schermo.

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

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.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[])

Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs
Origine:
Graphics.cs

Disegna una serie di rettangoli specificati da RectangleF strutture.

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);

Parametri

pen
Pen

Pen che determina il colore, la larghezza e lo stile dei contorni dei rettangoli.

rects
RectangleF[]

Matrice di strutture RectangleF che rappresentano i rettangoli da disegnare.

Eccezioni

pen è null.

-o-

rects è null.

rects è una matrice di lunghezza zero.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:

  • Crea una penna nera.

  • Crea una matrice di tre rettangoli.

  • Disegna i rettangoli sullo schermo.

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

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.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>)

Origine:
Graphics.cs
Origine:
Graphics.cs
C#
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Rectangle> rects);

Parametri

pen
Pen

Si applica a

.NET 9 e Windows Desktop 9
Prodotto Versioni
.NET 9
Windows Desktop 9

DrawRectangles(Pen, ReadOnlySpan<RectangleF>)

Origine:
Graphics.cs
Origine:
Graphics.cs
C#
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.RectangleF> rects);

Parametri

pen
Pen

Si applica a

.NET 9 e Windows Desktop 9
Prodotto Versioni
.NET 9
Windows Desktop 9