Прочетете на английски Редактиране

Споделяне чрез


Region Constructors

Definition

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()

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

Initializes a new Region.

C#
public Region();

Remarks

This constructor initializes a new Region with an infinite interior.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Region(GraphicsPath)

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

Initializes a new Region with the specified GraphicsPath.

C#
public Region(System.Drawing.Drawing2D.GraphicsPath path);

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

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Region(RegionData)

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

Initializes a new Region from the specified data.

C#
public Region(System.Drawing.Drawing2D.RegionData rgnData);

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

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Region(Rectangle)

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

Initializes a new Region from the specified Rectangle structure.

C#
public Region(System.Drawing.Rectangle rect);

Parameters

rect
Rectangle

A Rectangle structure that defines the interior of the new Region.

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.

C#
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);
}

Remarks

This method creates a new Region with a rectangular interior. The interior is defined by the rect parameter.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Region(RectangleF)

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

Initializes a new Region from the specified RectangleF structure.

C#
public Region(System.Drawing.RectangleF rect);

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.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10