GraphicsPath.AddRectangle Méthode

Définition

Ajoute un rectangle à ce chemin d’accès.

Surcharges

AddRectangle(RectangleF)

Ajoute un rectangle à ce chemin d’accès.

AddRectangle(Rectangle)

Ajoute un rectangle à ce chemin d’accès.

AddRectangle(RectangleF)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Ajoute un rectangle à ce chemin d’accès.

C#
public void AddRectangle (System.Drawing.RectangleF rect);

Paramètres

rect
RectangleF

Un RectangleF qui représente le rectangle à ajouter.

Exemples

Pour obtenir un exemple, consultez AddRectangle(Rectangle).

S’applique à

.NET 9 et autres versions
Produit Versions
.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

AddRectangle(Rectangle)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Ajoute un rectangle à ce chemin d’accès.

C#
public void AddRectangle (System.Drawing.Rectangle rect);

Paramètres

rect
Rectangle

Un Rectangle qui représente le rectangle à ajouter.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, un objet d’événement OnPaint. Le code effectue les actions suivantes :

  • Crée un chemin d’accès.

  • Crée un rectangle et ajoute le rectangle au chemin d’accès.

  • Dessine le chemin d’accès à l’écran.

C#
private void AddRectangleExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object and add a rectangle to it.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle pathRect = new Rectangle(20, 20, 100, 200);
    myPath.AddRectangle(pathRect);
             
    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}

S’applique à

.NET 9 et autres versions
Produit Versions
.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