GraphicsPath.AddRectangle 方法

定义

向此路径添加一个矩形。

重载

AddRectangle(RectangleF)

向此路径添加一个矩形。

AddRectangle(Rectangle)

向此路径添加一个矩形。

AddRectangle(RectangleF)

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

向此路径添加一个矩形。

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)

参数

rect
RectangleF

表示要添加的矩形的 RectangleF

示例

有关示例,请参阅 AddRectangle(Rectangle)

适用于

AddRectangle(Rectangle)

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

向此路径添加一个矩形。

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)

参数

rect
Rectangle

表示要添加的矩形的 Rectangle

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建路径。

  • 创建一个矩形并将该矩形添加到路径。

  • 绘制屏幕的路径。

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

适用于