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

NameDescription
System_CAPS_pubmethodRegion()

Initializes a new Region.

System_CAPS_pubmethodRegion(GraphicsPath)

Initializes a new Region with the specified GraphicsPath.

System_CAPS_pubmethodRegion(Rectangle)

Initializes a new Region from the specified Rectangle structure.

System_CAPS_pubmethodRegion(RectangleF)

Initializes a new Region from the specified RectangleF structure.

System_CAPS_pubmethodRegion(RegionData)

Initializes a new Region from the specified data.

NameDescription
System_CAPS_pubmethodClone()

Creates an exact copy of this Region.

System_CAPS_pubmethodComplement(GraphicsPath)

Updates this Region to contain the portion of the specified GraphicsPath that does not intersect with this Region.

System_CAPS_pubmethodComplement(Rectangle)

Updates this Region to contain the portion of the specified Rectangle structure that does not intersect with this Region.

System_CAPS_pubmethodComplement(RectangleF)

Updates this Region to contain the portion of the specified RectangleF structure that does not intersect with this Region.

System_CAPS_pubmethodComplement(Region)

Updates this Region to contain the portion of the specified Region that does not intersect with this Region.

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by this Region.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodEquals(Region, Graphics)

Tests whether the specified Region is identical to this Region on the specified drawing surface.

System_CAPS_pubmethodExclude(GraphicsPath)

Updates this Region to contain only the portion of its interior that does not intersect with the specified GraphicsPath.

System_CAPS_pubmethodExclude(Rectangle)

Updates this Region to contain only the portion of its interior that does not intersect with the specified Rectangle structure.

System_CAPS_pubmethodExclude(RectangleF)

Updates this Region to contain only the portion of its interior that does not intersect with the specified RectangleF structure.

System_CAPS_pubmethodExclude(Region)

Updates this Region to contain only the portion of its interior that does not intersect with the specified Region.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Overrides Object.Finalize().)

System_CAPS_pubmethodSystem_CAPS_staticFromHrgn(IntPtr)

Initializes a new Region from a handle to the specified existing GDI region.

System_CAPS_pubmethodGetBounds(Graphics)

Gets a RectangleF structure that represents a rectangle that bounds this Region on the drawing surface of a Graphics object.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetHrgn(Graphics)

Returns a Windows handle to this Region in the specified graphics context.

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetRegionData()

Returns a RegionData that represents the information that describes this Region.

System_CAPS_pubmethodGetRegionScans(Matrix)

Returns an array of RectangleF structures that approximate this Region after the specified matrix transformation is applied.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodIntersect(GraphicsPath)

Updates this Region to the intersection of itself with the specified GraphicsPath.

System_CAPS_pubmethodIntersect(Rectangle)

Updates this Region to the intersection of itself with the specified Rectangle structure.

System_CAPS_pubmethodIntersect(RectangleF)

Updates this Region to the intersection of itself with the specified RectangleF structure.

System_CAPS_pubmethodIntersect(Region)

Updates this Region to the intersection of itself with the specified Region.

System_CAPS_pubmethodIsEmpty(Graphics)

Tests whether this Region has an empty interior on the specified drawing surface.

System_CAPS_pubmethodIsInfinite(Graphics)

Tests whether this Region has an infinite interior on the specified drawing surface.

System_CAPS_pubmethodIsVisible(Int32, Int32, Graphics)

Tests whether the specified point is contained within this Region object when drawn using the specified Graphics object.

System_CAPS_pubmethodIsVisible(Int32, Int32, Int32, Int32)

Tests whether any portion of the specified rectangle is contained within this Region.

System_CAPS_pubmethodIsVisible(Int32, Int32, Int32, Int32, Graphics)

Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(Point)

Tests whether the specified Point structure is contained within this Region.

System_CAPS_pubmethodIsVisible(Point, Graphics)

Tests whether the specified Point structure is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(PointF)

Tests whether the specified PointF structure is contained within this Region.

System_CAPS_pubmethodIsVisible(PointF, Graphics)

Tests whether the specified PointF structure is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(Rectangle)

Tests whether any portion of the specified Rectangle structure is contained within this Region.

System_CAPS_pubmethodIsVisible(Rectangle, Graphics)

Tests whether any portion of the specified Rectangle structure is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(RectangleF)

Tests whether any portion of the specified RectangleF structure is contained within this Region.

System_CAPS_pubmethodIsVisible(RectangleF, Graphics)

Tests whether any portion of the specified RectangleF structure is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(Single, Single)

Tests whether the specified point is contained within this Region.

System_CAPS_pubmethodIsVisible(Single, Single, Graphics)

Tests whether the specified point is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodIsVisible(Single, Single, Single, Single)

Tests whether any portion of the specified rectangle is contained within this Region.

System_CAPS_pubmethodIsVisible(Single, Single, Single, Single, Graphics)

Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.

System_CAPS_pubmethodMakeEmpty()

Initializes this Region to an empty interior.

System_CAPS_pubmethodMakeInfinite()

Initializes this Region object to an infinite interior.

System_CAPS_pubmethodReleaseHrgn(IntPtr)

Releases the handle of the Region.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodTransform(Matrix)

Transforms this Region by the specified Matrix.

System_CAPS_pubmethodTranslate(Int32, Int32)

Offsets the coordinates of this Region by the specified amount.

System_CAPS_pubmethodTranslate(Single, Single)

Offsets the coordinates of this Region by the specified amount.

System_CAPS_pubmethodUnion(GraphicsPath)

Updates this Region to the union of itself and the specified GraphicsPath.

System_CAPS_pubmethodUnion(Rectangle)

Updates this Region to the union of itself and the specified Rectangle structure.

System_CAPS_pubmethodUnion(RectangleF)

Updates this Region to the union of itself and the specified RectangleF structure.

System_CAPS_pubmethodUnion(Region)

Updates this Region to the union of itself and the specified Region.

System_CAPS_pubmethodXor(GraphicsPath)

Updates this Region to the union minus the intersection of itself with the specified GraphicsPath.

System_CAPS_pubmethodXor(Rectangle)

Updates this Region to the union minus the intersection of itself with the specified Rectangle structure.

System_CAPS_pubmethodXor(RectangleF)

Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.

System_CAPS_pubmethodXor(Region)

Updates this Region to the union minus the intersection of itself with the specified Region.

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 PaintEventArgse, 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
Available since 1.1

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

Return to top
Show: