Share via


Region 建構函式

定義

初始化新的 Region

多載

Region()

初始化新的 Region

Region(GraphicsPath)

使用指定的 GraphicsPath,將新的 Region 初始化。

Region(RegionData)

從指定的資料將新的 Region 初始化。

Region(Rectangle)

從指定的 Region 結構,初始化新的 Rectangle

Region(RectangleF)

從指定的 Region 結構,初始化新的 RectangleF

Region()

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

初始化新的 Region

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

備註

這個建構函式會初始化具有無限內部的新 Region

適用於

Region(GraphicsPath)

來源:
Region.cs
來源:
Region.cs
來源:
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

備註

這個方法會使用 GraphicsPath建立新的 Region 。 新區域會定義為 參數所path指定的 內部GraphicsPath

適用於

Region(RegionData)

來源:
Region.cs
來源:
Region.cs
來源:
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

定義新 Region 內部的 RegionData

例外狀況

rgnDatanull

備註

這個方法會使用現有 Region所定義的內部建立新的 Region 。 參數 rgnData 是包含現有 Region定義的陣列。

適用於

Region(Rectangle)

來源:
Region.cs
來源:
Region.cs
來源:
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 Forms 搭配使用。 Create 表單,並將下列程式代碼貼到窗體中。 FillEmptyRegion在表單的事件Paint處理方法中呼叫 方法,並e傳遞為 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 。 內部是由 rect 參數所定義。

適用於

Region(RectangleF)

來源:
Region.cs
來源:
Region.cs
來源:
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 參數所定義。

適用於