Region Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new Region.
Overloads
Region() |
Initializes a new Region. |
Region(GraphicsPath) |
Initializes a new Region with the specified GraphicsPath. |
Region(RegionData) |
Initializes a new Region from the specified data. |
Region(Rectangle) |
Initializes a new Region from the specified Rectangle structure. |
Region(RectangleF) |
Initializes a new Region from the specified RectangleF structure. |
Region()
Region(GraphicsPath)
- Source:
- Region.cs
- Source:
- Region.cs
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)
Parameters
- path
- GraphicsPath
A GraphicsPath that defines the new Region.
Exceptions
path
is null
.
Remarks
This method creates a new Region with a GraphicsPath. The new region is defined as the interior of the GraphicsPath specified by the path
parameter.
Applies to
Region(RegionData)
- Source:
- Region.cs
- Source:
- Region.cs
Initializes a new Region from the specified data.
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)
Parameters
- rgnData
- RegionData
A RegionData that defines the interior of the new Region.
Exceptions
rgnData
is null
.
Remarks
This method creates a new Region with an interior defined by an existing Region. The rgnData
parameter is an array that contains the definition of an existing Region.
Applies to
Region(Rectangle)
- Source:
- Region.cs
- Source:
- Region.cs
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)
Parameters
Examples
The following code example demonstrates how to use the Region constructor and MakeEmpty method. This example is designed to be used with Windows Forms. Create a form and paste the following code into it. 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
Remarks
This method creates a new Region with a rectangular interior. The interior is defined by the rect
parameter.
Applies to
Region(RectangleF)
- Source:
- Region.cs
- Source:
- Region.cs
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)
Parameters
- rect
- RectangleF
A RectangleF structure that defines the interior of the new Region.
Remarks
This method creates a new Region with a rectangular interior. The interior is defined by the rect
parameter.