Export (0) Print
Expand All

Region Class

Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inherited.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public sealed class Region : MarshalByRefObject, 
	IDisposable

The Region type exposes the following members.

  NameDescription
Public methodRegion()Initializes a new Region.
Public methodRegion(GraphicsPath)Initializes a new Region with the specified GraphicsPath.
Public methodRegion(Rectangle)Initializes a new Region from the specified Rectangle structure.
Public methodRegion(RectangleF)Initializes a new Region from the specified RectangleF structure.
Public methodRegion(RegionData)Initializes a new Region from the specified data.
Top

  NameDescription
Public methodCloneCreates an exact copy of this Region.
Public methodComplement(GraphicsPath)Updates this Region to contain the portion of the specified GraphicsPath that does not intersect with this Region.
Public methodComplement(Rectangle)Updates this Region to contain the portion of the specified Rectangle structure that does not intersect with this Region.
Public methodComplement(RectangleF)Updates this Region to contain the portion of the specified RectangleF structure that does not intersect with this Region.
Public methodComplement(Region)Updates this Region to contain the portion of the specified Region that does not intersect with this Region.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDisposeReleases all resources used by this Region.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodEquals(Region, Graphics)Tests whether the specified Region is identical to this Region on the specified drawing surface.
Public methodExclude(GraphicsPath)Updates this Region to contain only the portion of its interior that does not intersect with the specified GraphicsPath.
Public methodExclude(Rectangle)Updates this Region to contain only the portion of its interior that does not intersect with the specified Rectangle structure.
Public methodExclude(RectangleF)Updates this Region to contain only the portion of its interior that does not intersect with the specified RectangleF structure.
Public methodExclude(Region)Updates this Region to contain only the portion of its interior that does not intersect with the specified Region.
Public methodStatic memberFromHrgnInitializes a new Region from a handle to the specified existing GDI region.
Public methodGetBoundsGets a RectangleF structure that represents a rectangle that bounds this Region on the drawing surface of a Graphics object.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetHrgnReturns a Windows handle to this Region in the specified graphics context.
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetRegionDataReturns a RegionData that represents the information that describes this Region.
Public methodGetRegionScansReturns an array of RectangleF structures that approximate this Region after the specified matrix transformation is applied.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodIntersect(GraphicsPath)Updates this Region to the intersection of itself with the specified GraphicsPath.
Public methodIntersect(Rectangle)Updates this Region to the intersection of itself with the specified Rectangle structure.
Public methodIntersect(RectangleF)Updates this Region to the intersection of itself with the specified RectangleF structure.
Public methodIntersect(Region)Updates this Region to the intersection of itself with the specified Region.
Public methodIsEmptyTests whether this Region has an empty interior on the specified drawing surface.
Public methodIsInfiniteTests whether this Region has an infinite interior on the specified drawing surface.
Public methodIsVisible(Point)Tests whether the specified Point structure is contained within this Region.
Public methodIsVisible(PointF)Tests whether the specified PointF structure is contained within this Region.
Public methodIsVisible(Rectangle)Tests whether any portion of the specified Rectangle structure is contained within this Region.
Public methodIsVisible(RectangleF)Tests whether any portion of the specified RectangleF structure is contained within this Region.
Public methodIsVisible(Point, Graphics)Tests whether the specified Point structure is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(PointF, Graphics)Tests whether the specified PointF structure is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(Rectangle, Graphics)Tests whether any portion of the specified Rectangle structure is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(RectangleF, Graphics)Tests whether any portion of the specified RectangleF structure is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(Single, Single)Tests whether the specified point is contained within this Region.
Public methodIsVisible(Int32, Int32, Graphics)Tests whether the specified point is contained within this Region object when drawn using the specified Graphics object.
Public methodIsVisible(Single, Single, Graphics)Tests whether the specified point is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(Int32, Int32, Int32, Int32)Tests whether any portion of the specified rectangle is contained within this Region.
Public methodIsVisible(Single, Single, Single, Single)Tests whether any portion of the specified rectangle is contained within this Region.
Public methodIsVisible(Int32, Int32, Int32, Int32, Graphics)Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.
Public methodIsVisible(Single, Single, Single, Single, Graphics)Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.
Public methodMakeEmptyInitializes this Region to an empty interior.
Public methodMakeInfiniteInitializes this Region object to an infinite interior.
Public methodReleaseHrgnReleases the handle of the Region.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformTransforms this Region by the specified Matrix.
Public methodTranslate(Int32, Int32)Offsets the coordinates of this Region by the specified amount.
Public methodTranslate(Single, Single)Offsets the coordinates of this Region by the specified amount.
Public methodUnion(GraphicsPath)Updates this Region to the union of itself and the specified GraphicsPath.
Public methodUnion(Rectangle)Updates this Region to the union of itself and the specified Rectangle structure.
Public methodUnion(RectangleF)Updates this Region to the union of itself and the specified RectangleF structure.
Public methodUnion(Region)Updates this Region to the union of itself and the specified Region.
Public methodXor(GraphicsPath)Updates this Region to the union minus the intersection of itself with the specified GraphicsPath.
Public methodXor(Rectangle)Updates this Region to the union minus the intersection of itself with the specified Rectangle structure.
Public methodXor(RectangleF)Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.
Public methodXor(Region)Updates this Region to the union minus the intersection of itself with the specified Region.
Top

A region is scalable because its coordinates are specified in world coordinates. On a drawing surface, however, its interior is dependent on the size and shape of the pixels representing it. An application can use regions to clip the output of drawing operations. These regions are called clipping regions. For more information on using regions for clipping, see How to: Use Clipping with a Region.

An application can also use regions in hit-testing operations, such as checking whether a point or a rectangle intersects a region. For more information on using regions for hit-testing, see How to: Use Hit Testing with a Region.

An application can fill a region by using the Graphics.FillRegion method and a Brush object.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code example demonstrates how to use the Data from one RegionData object to set the Data for another RegionData.

private void DemonstrateRegionData2(PaintEventArgs e)
{

    //Create a simple region.
    Region region1 = new Region(new Rectangle(10, 10, 100, 100));

    // Extract the region data.
    System.Drawing.Drawing2D.RegionData region1Data = region1.GetRegionData();
    byte[] data1;
    data1 = region1Data.Data;

    // Create a second region.
    Region region2 = new Region();

    // Get the region data for the second region.
    System.Drawing.Drawing2D.RegionData region2Data = region2.GetRegionData();

    // Set the Data property for the second region to the Data from the first region.
    region2Data.Data = data1;

    // Construct a third region using the modified RegionData of the second region.
    Region region3 = new Region(region2Data);

    // Dispose of the first and second regions.
    region1.Dispose();
    region2.Dispose();

    // Call ExcludeClip passing in the third region.
    e.Graphics.ExcludeClip(region3);

    // Fill in the client rectangle.
    e.Graphics.FillRectangle(Brushes.Red, this.ClientRectangle);

    region3.Dispose();

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft