Share via


Region 构造函数

定义

初始化新的 Region

重载

Region()

初始化新的 Region

Region(GraphicsPath)

使用指定的 GraphicsPath 初始化新的 Region

Region(RegionData)

从指定的数据中初始化新的 Region

Region(Rectangle)

基于指定的 Region 结构初始化一个新的 Rectangle

Region(RectangleF)

基于指定的 Region 结构初始化一个新的 RectangleF

Region()

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

初始化新的 Region

public:
 Region();
public Region ();
Public Sub New ()

注解

此构造函数使用无限内部初始化新的 Region

适用于

Region(GraphicsPath)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 GraphicsPath 初始化新的 Region

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

例外

pathnull

注解

此方法使用 RegionGraphicsPath创建新的 。 新区域定义为 由 path 参数指定的 的内部GraphicsPath

适用于

Region(RegionData)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

从指定的数据中初始化新的 Region

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 的内部。

例外

rgnDatanull

注解

此方法使用由现有 Region定义的内部创建新的 Region 。 参数 rgnData 是一个数组,其中包含现有 Region的定义。

适用于

Region(Rectangle)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

基于指定的 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 的内部。

示例

下面的代码示例演示如何使用 Region 构造函数和 MakeEmpty 方法。 此示例旨在与 Windows 窗体 一起使用。 Create窗体并将以下代码粘贴到其中。 FillEmptyRegion在窗体的事件Paint处理方法中调用 方法,作为 ePaintEventArgs传递。

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 。 内部由 rect 参数定义。

适用于

Region(RectangleF)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

基于指定的 Region 结构初始化一个新的 RectangleF

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 的内部。

注解

此方法使用矩形内部创建一个新的 Region 。 内部由 rect 参数定义。

适用于