Class Region
Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inherited.
public sealed class Region
- Inheritance
-
Region
- Inherited Members
Constructors
Region()
Initializes a new Region.
public Region()
Region(GraphicsPath)
Initializes a new Region with the specified GraphicsPath.
public Region(GraphicsPath path)
Parameters
path
GraphicsPathA GraphicsPath that defines the new Region.
Exceptions
- ArgumentNullException
path
is null.
Region(Rectangle)
public Region(Rectangle rect)
Parameters
Region(RectangleF)
Initializes a new Region from the specified RectangleF structure.
public Region(RectangleF rect)
Parameters
rect
RectangleFA RectangleF structure that defines the interior of the new Region.
Methods
Complement(GraphicsPath)
Updates this Region to contain the portion of the specified GraphicsPath that does not intersect with this Region.
public void Complement(GraphicsPath path)
Parameters
path
GraphicsPathThe GraphicsPath to complement this Region.
Exceptions
- ArgumentNullException
path
isnull.
Complement(Rectangle)
Updates this Region to contain the portion of the specified Rectangle structure that does not intersect with this Region.
public void Complement(Rectangle rect)
Parameters
Complement(RectangleF)
Updates this Region to contain the portion of the specified RectangleF structure that does not intersect with this Region.
public void Complement(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to complement this Region.
Complement(Region)
Updates this Region to contain the portion of the specified Region that does not intersect with this Region.
public void Complement(Region region)
Parameters
Exceptions
- ArgumentNullException
region
isnull.
DeepClone()
Creates an exact deep copy of this Region.
public Region DeepClone()
Returns
Equals(Region, Graphics)
public bool Equals(Region region, Graphics g)
Parameters
Returns
- bool
True if the interior of region is identical to the interior of this region when the transformation associated with the
g
parameter is applied; otherwise, false.
Exceptions
- ArgumentNullException
g
orregion
is null.
Equals(object)
Check if objects are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe other object.
Returns
- bool
The equality comparison result.
Exclude(GraphicsPath)
Updates this Region to contain only the portion of its interior that does not intersect with the specified GraphicsPath.
public void Exclude(GraphicsPath path)
Parameters
path
GraphicsPathThe GraphicsPath to exclude from this Region.
Exceptions
- ArgumentNullException
path
is null.
Exclude(Rectangle)
Updates this Region to contain only the portion of its interior that does not intersect with the specified Rectangle structure.
public void Exclude(Rectangle rect)
Parameters
Exclude(RectangleF)
Updates this Region to contain only the portion of its interior that does not intersect with the specified RectangleF structure.
public void Exclude(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to exclude from this Region.
Exclude(Region)
Updates this Region to contain only the portion of its interior that does not intersect with the specified Region.
public void Exclude(Region region)
Parameters
Exceptions
- ArgumentNullException
region
is null.
GetHashCode()
Get hash code of the current object.
public override int GetHashCode()
Returns
- int
The hash code.
Intersect(GraphicsPath)
Updates this Region to the intersection of itself with the specified GraphicsPath.
public void Intersect(GraphicsPath path)
Parameters
path
GraphicsPathThe GraphicsPath to intersect with this Region.
Intersect(Rectangle)
public void Intersect(Rectangle rect)
Parameters
Intersect(RectangleF)
Updates this Region to the intersection of itself with the specified RectangleF structure.
public void Intersect(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to intersect with this Region.
Intersect(Region)
public void Intersect(Region region)
Parameters
IsEmpty(Graphics)
Tests whether this Region has an empty interior on the specified drawing surface.
public bool IsEmpty(Graphics g)
Parameters
Returns
- bool
true if the interior of this Region is empty when the transformation associated with
g
is applied; otherwise, false.
Exceptions
- ArgumentNullException
g
is null.
IsInfinite(Graphics)
Tests whether this Region has an infinite interior on the specified drawing surface.
public bool IsInfinite(Graphics g)
Parameters
Returns
- bool
true if the interior of this Region is infinite when the transformation associated with
g
is applied; otherwise, false.
Exceptions
- ArgumentNullException
g
is null.
IsVisible(Point)
public bool IsVisible(Point point)
Parameters
Returns
IsVisible(Point, Graphics)
Tests whether the specified Point structure is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(Point point, Graphics g)
Parameters
Returns
IsVisible(PointF)
public bool IsVisible(PointF point)
Parameters
Returns
IsVisible(PointF, Graphics)
Tests whether the specified PointF structure is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(PointF point, Graphics g)
Parameters
point
PointFThe PointF structure to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
IsVisible(Rectangle)
public bool IsVisible(Rectangle rect)
Parameters
Returns
- bool
This method returns true when any portion of
rect
is contained within this Region; otherwise, false.
IsVisible(Rectangle, Graphics)
Tests whether any portion of the specified Rectangle structure is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(Rectangle rect, Graphics g)
Parameters
rect
RectangleThe Rectangle structure to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
IsVisible(RectangleF)
Tests whether any portion of the specified RectangleF structure is contained within this Region.
public bool IsVisible(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to test.
Returns
IsVisible(RectangleF, Graphics)
Tests whether any portion of the specified RectangleF structure is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(RectangleF rect, Graphics g)
Parameters
rect
RectangleFThe RectangleF structure to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
IsVisible(int, int, Graphics)
Tests whether the specified point is contained within this Region object when drawn using the specified Graphics object.
public bool IsVisible(int x, int y, Graphics g)
Parameters
x
intThe x-coordinate of the point to test.
y
intThe y-coordinate of the point to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
IsVisible(int, int, int, int)
Tests whether any portion of the specified rectangle is contained within this Region.
public bool IsVisible(int x, int y, int width, int height)
Parameters
x
intThe x-coordinate of the upper-left corner of the rectangle to test.
y
intThe y-coordinate of the upper-left corner of the rectangle to test.
width
intThe width of the rectangle to test.
height
intThe height of the rectangle to test.
Returns
- bool
true when any portion of the specified rectangle is contained within this Region; otherwise, false.
IsVisible(int, int, int, int, Graphics)
Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(int x, int y, int width, int height, Graphics g)
Parameters
x
intThe x-coordinate of the upper-left corner of the rectangle to test.
y
intThe y-coordinate of the upper-left corner of the rectangle to test.
width
intThe width of the rectangle to test.
height
intThe height of the rectangle to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
- bool
true when any portion of the specified rectangle is contained within this Region; otherwise, false.
IsVisible(float, float)
Tests whether the specified point is contained within this Region.
public bool IsVisible(float x, float y)
Parameters
Returns
IsVisible(float, float, Graphics)
Tests whether the specified point is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(float x, float y, Graphics g)
Parameters
x
floatThe x-coordinate of the point to test.
y
floatThe y-coordinate of the point to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
IsVisible(float, float, float, float)
Tests whether any portion of the specified rectangle is contained within this Region.
public bool IsVisible(float x, float y, float width, float height)
Parameters
x
floatThe x-coordinate of the upper-left corner of the rectangle to test.
y
floatThe y-coordinate of the upper-left corner of the rectangle to test.
width
floatThe width of the rectangle to test.
height
floatThe height of the rectangle to test.
Returns
- bool
true when any portion of the specified rectangle is contained within this Region object; otherwise, false.
IsVisible(float, float, float, float, Graphics)
Tests whether any portion of the specified rectangle is contained within this Region when drawn using the specified Graphics.
public bool IsVisible(float x, float y, float width, float height, Graphics g)
Parameters
x
floatThe x-coordinate of the upper-left corner of the rectangle to test.
y
floatThe y-coordinate of the upper-left corner of the rectangle to test.
width
floatThe width of the rectangle to test.
height
floatThe height of the rectangle to test.
g
GraphicsA Graphics that represents a graphics context.
Returns
- bool
true when any portion of the specified rectangle is contained within this Region; otherwise, false.
MakeEmpty()
Initializes this Region to an empty interior.
public void MakeEmpty()
MakeInfinite()
Initializes this Region object to an infinite interior.
public void MakeInfinite()
Transform(Matrix)
public void Transform(Matrix matrix)
Parameters
Exceptions
- ArgumentNullException
matrix
is null.
Translate(int, int)
Offsets the coordinates of this Region by the specified amount.
public void Translate(int dx, int dy)
Parameters
dx
intThe amount to offset this Region horizontally.
dy
intThe amount to offset this Region vertically.
Translate(float, float)
Offsets the coordinates of this Region by the specified amount.
public void Translate(float dx, float dy)
Parameters
dx
floatThe amount to offset this Region horizontally.
dy
floatThe amount to offset this Region vertically.
Union(GraphicsPath)
Updates this Region to the union of itself and the specified GraphicsPath.
public void Union(GraphicsPath path)
Parameters
path
GraphicsPathThe GraphicsPath to unite with this Region.
Exceptions
- ArgumentNullException
path
is null.
Union(Rectangle)
public void Union(Rectangle rect)
Parameters
Union(RectangleF)
Updates this Region to the union of itself and the specified RectangleF structure.
public void Union(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to unite with this Region.
Union(Region)
public void Union(Region region)
Parameters
Exceptions
- ArgumentNullException
region
is null.
Xor(GraphicsPath)
Updates this Region to the union minus the intersection of itself with the specified GraphicsPath.
public void Xor(GraphicsPath path)
Parameters
path
GraphicsPathThe GraphicsPath to xor with this Region.
Exceptions
- ArgumentNullException
path
is null.
Xor(Rectangle)
Updates this Region to the union minus the intersection of itself with the specified Rectangle structure.
public void Xor(Rectangle rect)
Parameters
Xor(RectangleF)
Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.
public void Xor(RectangleF rect)
Parameters
rect
RectangleFThe RectangleF structure to xor with this Region.
Xor(Region)
public void Xor(Region region)
Parameters
Exceptions
- ArgumentNullException
region
is null.