Graphics.DrawRectangles 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
绘制由 Rectangle 结构指定的一系列矩形。
重载
DrawRectangles(Pen, Rectangle[])
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
绘制由 Rectangle 结构指定的一系列矩形。
public:
void DrawRectangles(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Rectangle> ^ rects);
public:
void DrawRectangles(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::Rectangle> ^ rects);
public void DrawRectangles (System.Drawing.Pen pen, System.Drawing.Rectangle[] rects);
public void DrawRectangles (System.Drawing.Pen pen, params System.Drawing.Rectangle[] rects);
member this.DrawRectangles : System.Drawing.Pen * System.Drawing.Rectangle[] -> unit
Public Sub DrawRectangles (pen As Pen, rects As Rectangle())
Public Sub DrawRectangles (pen As Pen, ParamArray rects As Rectangle())
参数
例外
rects
是长度为零的数组。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
创建黑色笔。
创建三个矩形的数组。
将矩形绘制到屏幕。
public:
void DrawRectanglesRectangle( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create array of rectangles.
array<Rectangle>^ rects = {Rectangle(0,0,100,200),Rectangle(100,200,250,50),Rectangle(300,0,50,100)};
// Draw rectangles to screen.
e->Graphics->DrawRectangles( blackPen, rects );
}
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);
}
Public Sub DrawRectanglesRectangle(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create array of rectangles.
Dim rects As Rectangle() = {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)
End Sub
适用于
DrawRectangles(Pen, RectangleF[])
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
绘制由 RectangleF 结构指定的一系列矩形。
public:
void DrawRectangles(System::Drawing::Pen ^ pen, cli::array <System::Drawing::RectangleF> ^ rects);
public:
void DrawRectangles(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::RectangleF> ^ rects);
public void DrawRectangles (System.Drawing.Pen pen, System.Drawing.RectangleF[] rects);
public void DrawRectangles (System.Drawing.Pen pen, params System.Drawing.RectangleF[] rects);
member this.DrawRectangles : System.Drawing.Pen * System.Drawing.RectangleF[] -> unit
Public Sub DrawRectangles (pen As Pen, rects As RectangleF())
Public Sub DrawRectangles (pen As Pen, ParamArray rects As RectangleF())
参数
- rects
- RectangleF[]
表示要绘制的矩形的 RectangleF 结构的数组。
例外
rects
是长度为零的数组。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
创建黑色笔。
创建三个矩形的数组。
将矩形绘制到屏幕。
public:
void DrawRectanglesRectangleF( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create array of rectangles.
array<RectangleF>^ rects = {RectangleF(0.0F,0.0F,100.0F,200.0F),RectangleF(100.0F,200.0F,250.0F,50.0F),RectangleF(300.0F,0.0F,50.0F,100.0F)};
// Draw rectangles to screen.
e->Graphics->DrawRectangles( blackPen, rects );
}
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);
}
Public Sub DrawRectanglesRectangleF(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create array of rectangles.
Dim rects As RectangleF() = {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)
End Sub
适用于
DrawRectangles(Pen, ReadOnlySpan<Rectangle>)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
public:
void DrawRectangles(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::Rectangle> rects);
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Rectangle> rects);
member this.DrawRectangles : System.Drawing.Pen * ReadOnlySpan<System.Drawing.Rectangle> -> unit
Public Sub DrawRectangles (pen As Pen, rects As ReadOnlySpan(Of Rectangle))
参数
- pen
- Pen
- rects
- ReadOnlySpan<Rectangle>
适用于
DrawRectangles(Pen, ReadOnlySpan<RectangleF>)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
public:
void DrawRectangles(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::RectangleF> rects);
public void DrawRectangles (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.RectangleF> rects);
member this.DrawRectangles : System.Drawing.Pen * ReadOnlySpan<System.Drawing.RectangleF> -> unit
Public Sub DrawRectangles (pen As Pen, rects As ReadOnlySpan(Of RectangleF))
参数
- pen
- Pen
- rects
- ReadOnlySpan<RectangleF>