Region 构造函数
定义
重载
| Region() | |
| Region(GraphicsPath) |
使用指定的 GraphicsPath 初始化新的 Region。Initializes a new Region with the specified GraphicsPath. |
| Region(RegionData) |
从指定的数据中初始化新的 Region。Initializes a new Region from the specified data. |
| Region(Rectangle) |
基于指定的 Region 结构初始化一个新的 Rectangle。Initializes a new Region from the specified Rectangle structure. |
| Region(RectangleF) |
基于指定的 Region 结构初始化一个新的 RectangleF。Initializes a new Region from the specified RectangleF structure. |
Region()
Region(GraphicsPath)
使用指定的 GraphicsPath 初始化新的 Region。Initializes a new Region with the specified GraphicsPath.
public:
Region(System::Drawing::Drawing2D::GraphicsPath ^ path);
public Region (System.Drawing.Drawing2D.GraphicsPath path);
new System.Drawing.Region : System.Drawing.Drawing2D.GraphicsPath -> System.Drawing.Region
Public Sub New (path As GraphicsPath)
参数
- path
- GraphicsPath
一个 GraphicsPath,它定义新的 Region。A GraphicsPath that defines the new Region.
例外
path 为 null。path is null.
注解
此方法使用创建一个新的 Region GraphicsPath 。This method creates a new Region with a GraphicsPath. 新区域定义为由参数指定的的内部 GraphicsPath path 。The new region is defined as the interior of the GraphicsPath specified by the path parameter.
适用于
Region(RegionData)
public:
Region(System::Drawing::Drawing2D::RegionData ^ rgnData);
public Region (System.Drawing.Drawing2D.RegionData rgnData);
new System.Drawing.Region : System.Drawing.Drawing2D.RegionData -> System.Drawing.Region
Public Sub New (rgnData As RegionData)
参数
- rgnData
- RegionData
一个 RegionData,它定义新的 Region 的内部。A RegionData that defines the interior of the new Region.
例外
rgnData 为 null。rgnData is null.
注解
此方法创建一个新的 Region ,其中包含由现有的定义的内部 Region 。This method creates a new Region with an interior defined by an existing Region. rgnData参数是一个数组,其中包含现有的定义 Region 。The rgnData parameter is an array that contains the definition of an existing Region.
适用于
Region(Rectangle)
public:
Region(System::Drawing::Rectangle rect);
public Region (System.Drawing.Rectangle rect);
new System.Drawing.Region : System.Drawing.Rectangle -> System.Drawing.Region
Public Sub New (rect As Rectangle)
参数
- rect
- Rectangle
一个 Rectangle 结构,用于定义新 Region 的内部。A Rectangle structure that defines the interior of the new Region.
示例
下面的代码示例演示如何使用 Region 构造函数和 MakeEmpty 方法。The following code example demonstrates how to use the Region constructor and MakeEmpty method. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 创建窗体并将以下代码粘贴到其中。Create a form and paste the following code into it. FillEmptyRegion在窗体的 Paint 事件处理方法中调用方法,并将 e 作为传递 PaintEventArgs 。Call the FillEmptyRegion method in the form's Paint event-handling method, passing e as PaintEventArgs.
private:
void FillEmptyRegion( PaintEventArgs^ e )
{
// Create a region from a rectangle.
Rectangle originalRectangle = Rectangle(40,40,40,50);
System::Drawing::Region^ smallRegion = gcnew System::Drawing::Region( originalRectangle );
// Call MakeEmpty.
smallRegion->MakeEmpty();
// Fill the region in red and draw the original rectangle
// in black. Note there is nothing filled in.
e->Graphics->FillRegion( Brushes::Red, smallRegion );
e->Graphics->DrawRectangle( Pens::Black, originalRectangle );
}
private void FillEmptyRegion(PaintEventArgs e)
{
// Create a region from a rectangle.
Rectangle originalRectangle = new Rectangle(40, 40, 40, 50);
Region smallRegion = new Region(originalRectangle);
// Call MakeEmpty.
smallRegion.MakeEmpty();
// Fill the region in red and draw the original rectangle
// in black. Note there is nothing filled in.
e.Graphics.FillRegion(Brushes.Red, smallRegion);
e.Graphics.DrawRectangle(Pens.Black, originalRectangle);
}
Private Sub FillEmptyRegion(ByVal e As PaintEventArgs)
' Create a region from a rectangle.
Dim originalRectangle As New Rectangle(40, 40, 40, 50)
Dim smallRegion As New Region(originalRectangle)
' Call MakeEmpty.
smallRegion.MakeEmpty()
' Fill the region in red and draw the original rectangle
' in black. Note there is nothing filled in.
e.Graphics.FillRegion(Brushes.Red, smallRegion)
e.Graphics.DrawRectangle(Pens.Black, originalRectangle)
End Sub
注解
此方法使用矩形内部创建一个新的 Region 。This method creates a new Region with a rectangular interior. 内部由 rect 参数定义。The interior is defined by the rect parameter.
适用于
Region(RectangleF)
基于指定的 Region 结构初始化一个新的 RectangleF。Initializes a new Region from the specified RectangleF structure.
public:
Region(System::Drawing::RectangleF rect);
public Region (System.Drawing.RectangleF rect);
new System.Drawing.Region : System.Drawing.RectangleF -> System.Drawing.Region
Public Sub New (rect As RectangleF)
参数
- rect
- RectangleF
一个 RectangleF 结构,用于定义新 Region 的内部。A RectangleF structure that defines the interior of the new Region.
注解
此方法使用矩形内部创建一个新的 Region 。This method creates a new Region with a rectangular interior. 内部由 rect 参数定义。The interior is defined by the rect parameter.