GraphicsPath.AddRectangle Método

Definición

Agrega un rectángulo a este trazado.Adds a rectangle to this path.

Sobrecargas

AddRectangle(Rectangle)

Agrega un rectángulo a este trazado.Adds a rectangle to this path.

AddRectangle(RectangleF)

Agrega un rectángulo a este trazado.Adds a rectangle to this path.

AddRectangle(Rectangle)

Agrega un rectángulo a este trazado.Adds a rectangle to this path.

public:
 void AddRectangle(System::Drawing::Rectangle rect);
public void AddRectangle (System.Drawing.Rectangle rect);
member this.AddRectangle : System.Drawing.Rectangle -> unit
Public Sub AddRectangle (rect As Rectangle)

Parámetros

rect
Rectangle

Rectangle que representa el rectángulo que se va a agregar.A Rectangle that represents the rectangle to add.

Ejemplos

El siguiente ejemplo de código está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un objeto de evento de OnPaint.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. El código realiza las siguientes acciones:The code performs the following actions:

  • Crea una ruta de acceso.Creates a path.

  • Crea un rectángulo y agrega el rectángulo a la ruta de acceso.Creates a rectangle and adds the rectangle to the path.

  • Dibuja la ruta de acceso a la pantalla.Draws the path to the screen.

private:
   void AddRectangleExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object and add a rectangle to it.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle pathRect = Rectangle(20,20,100,200);
      myPath->AddRectangle( pathRect );

      // Draw the path to the screen.
      Pen^ myPen = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }
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);
}
Public Sub AddRectangleExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object and add a rectangle to it.
    Dim myPath As New GraphicsPath
    Dim pathRect As New Rectangle(20, 20, 100, 200)
    myPath.AddRectangle(pathRect)

    ' Draw the path to the screen.
    Dim myPen As New Pen(Color.Black, 2)
    e.Graphics.DrawPath(myPen, myPath)
End Sub

AddRectangle(RectangleF)

Agrega un rectángulo a este trazado.Adds a rectangle to this path.

public:
 void AddRectangle(System::Drawing::RectangleF rect);
public void AddRectangle (System.Drawing.RectangleF rect);
member this.AddRectangle : System.Drawing.RectangleF -> unit
Public Sub AddRectangle (rect As RectangleF)

Parámetros

rect
RectangleF

RectangleF que representa el rectángulo que se va a agregar.A RectangleF that represents the rectangle to add.

Ejemplos

Para obtener un ejemplo, vea AddRectangle(Rectangle).For an example, see AddRectangle(Rectangle).

Se aplica a