GraphicsPath.AddRectangles 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將一系列矩形新增至此路徑。
多載
AddRectangles(Rectangle[]) |
將一系列矩形新增至此路徑。 |
AddRectangles(RectangleF[]) |
將一系列矩形新增至此路徑。 |
AddRectangles(ReadOnlySpan<Rectangle>) | |
AddRectangles(ReadOnlySpan<RectangleF>) |
AddRectangles(Rectangle[])
將一系列矩形新增至此路徑。
public:
void AddRectangles(cli::array <System::Drawing::Rectangle> ^ rects);
public:
void AddRectangles(... cli::array <System::Drawing::Rectangle> ^ rects);
public void AddRectangles (System.Drawing.Rectangle[] rects);
public void AddRectangles (params System.Drawing.Rectangle[] rects);
member this.AddRectangles : System.Drawing.Rectangle[] -> unit
Public Sub AddRectangles (rects As Rectangle())
Public Sub AddRectangles (ParamArray rects As Rectangle())
參數
範例
下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgse
OnPaint 事件物件。 程式代碼會執行下列動作:
建立路徑。
建立矩形陣列,並將矩形新增至路徑。
繪製畫面的路徑。
private:
void AddRectanglesExample( PaintEventArgs^ e )
{
// Adds a pattern of rectangles to a GraphicsPath object.
GraphicsPath^ myPath = gcnew GraphicsPath;
array<Rectangle>^ pathRects = {Rectangle(20,20,100,200),Rectangle(40,40,120,220),Rectangle(60,60,240,140)};
myPath->AddRectangles( pathRects );
// Draw the path to the screen.
Pen^ myPen = gcnew Pen( Color::Black,2.0f );
e->Graphics->DrawPath( myPen, myPath );
}
private void AddRectanglesExample(PaintEventArgs e)
{
// Adds a pattern of rectangles to a GraphicsPath object.
GraphicsPath myPath = new GraphicsPath();
Rectangle[] pathRects =
{
new Rectangle(20,20,100,200),
new Rectangle(40,40,120,220),
new Rectangle(60,60,240,140)
};
myPath.AddRectangles(pathRects);
// Draw the path to the screen.
Pen myPen = new Pen(Color.Black, 2);
e.Graphics.DrawPath(myPen, myPath);
}
Public Sub AddRectanglesExample(ByVal e As PaintEventArgs)
' Adds a pattern of rectangles to a GraphicsPath object.
Dim myPath As New GraphicsPath
Dim pathRects As Rectangle() = {New Rectangle(20, 20, 100, 200), _
New Rectangle(40, 40, 120, 220), New Rectangle(60, 60, 240, 140)}
myPath.AddRectangles(pathRects)
' Draw the path to the screen.
Dim myPen As New Pen(Color.Black, 2)
e.Graphics.DrawPath(myPen, myPath)
End Sub
適用於
AddRectangles(RectangleF[])
將一系列矩形新增至此路徑。
public:
void AddRectangles(cli::array <System::Drawing::RectangleF> ^ rects);
public:
void AddRectangles(... cli::array <System::Drawing::RectangleF> ^ rects);
public void AddRectangles (System.Drawing.RectangleF[] rects);
public void AddRectangles (params System.Drawing.RectangleF[] rects);
member this.AddRectangles : System.Drawing.RectangleF[] -> unit
Public Sub AddRectangles (rects As RectangleF())
Public Sub AddRectangles (ParamArray rects As RectangleF())
參數
- rects
- RectangleF[]
RectangleF 結構的陣列,表示要加入的矩形。
範例
如需範例,請參閱 AddRectangles(Rectangle[])。
適用於
AddRectangles(ReadOnlySpan<Rectangle>)
public:
void AddRectangles(ReadOnlySpan<System::Drawing::Rectangle> rects);
public void AddRectangles (scoped ReadOnlySpan<System.Drawing.Rectangle> rects);
member this.AddRectangles : ReadOnlySpan<System.Drawing.Rectangle> -> unit
Public Sub AddRectangles (rects As ReadOnlySpan(Of Rectangle))
參數
- rects
- ReadOnlySpan<Rectangle>
適用於
AddRectangles(ReadOnlySpan<RectangleF>)
public:
void AddRectangles(ReadOnlySpan<System::Drawing::RectangleF> rects);
public void AddRectangles (scoped ReadOnlySpan<System.Drawing.RectangleF> rects);
member this.AddRectangles : ReadOnlySpan<System.Drawing.RectangleF> -> unit
Public Sub AddRectangles (rects As ReadOnlySpan(Of RectangleF))
參數
- rects
- ReadOnlySpan<RectangleF>