Struct Rect
Represents a rectangle.
Implements
Inherited Members
Namespace: GraphShape
Assembly: GraphShape.dll
Syntax
[Serializable]
public struct Rect : IEquatable<Rect>
Constructors
| Improve this Doc View SourceRect(Point, Size)
Constructor.
Declaration
public Rect(Point location, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | location | A point that specifies the location of the top-left corner of the rectangle. |
| Size | size | A Size structure that specifies the width and height of the rectangle. |
Rect(Double, Double, Double, Double)
Constructor.
Declaration
public Rect(double x, double y, double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | The x-coordinate of the top-left corner of the rectangle. |
| System.Double | y | The y-coordinate of the top-left corner of the rectangle. |
| System.Double | width | The width of the rectangle. |
| System.Double | height | The height of the rectangle. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
Fields
| Improve this Doc View SourceEmpty
Empty rectangle.
Declaration
public static readonly Rect Empty
Field Value
| Type | Description |
|---|---|
| Rect |
Properties
| Improve this Doc View SourceBottom
Gets the y-axis value of the bottom of the rectangle.
Declaration
public readonly double Bottom { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
Declaration
public readonly Point BottomLeft { get; }
Property Value
| Type | Description |
|---|---|
| Point |
BottomRight
Gets the position of the bottom-right corner of the rectangle.
Declaration
public readonly Point BottomRight { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Height
Height of the rectangle.
Declaration
public double Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
| System.ArgumentOutOfRangeException | Value is negative. |
IsEmpty
Indicates if this rectangle is empty.
Declaration
public readonly bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Left
Gets the x-axis value of the left side of the rectangle.
Declaration
public readonly double Left { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Location
The position of the top-left corner of the rectangle.
Declaration
public Point Location { get; set; }
Property Value
| Type | Description |
|---|---|
| Point |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
Right
Gets the x-axis value of the right side of the rectangle.
Declaration
public readonly double Right { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Size
The width and height of the rectangle.
Declaration
public Size Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
Top
Gets the y-axis position of the top of the rectangle.
Declaration
public readonly double Top { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
TopLeft
Gets the position of the top-left corner of the rectangle.
Declaration
public readonly Point TopLeft { get; }
Property Value
| Type | Description |
|---|---|
| Point |
TopRight
Gets the position of the top-right corner of the rectangle.
Declaration
public readonly Point TopRight { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Width
Width of the rectangle.
Declaration
public double Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
| System.ArgumentOutOfRangeException | Value is negative. |
X
X-axis value of the left side of the rectangle.
Declaration
public double X { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
Y
Y-axis value of the top side of the rectangle.
Declaration
public double Y { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
Methods
| Improve this Doc View SourceEquals(Rect)
Declaration
public bool Equals(Rect other)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Equals(Rect, Rect)
Compares the two specified Rects for equality.
Declaration
public static bool Equals(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | The first Rect to compare. |
| Rect | rect2 | The second Rect to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if both Rect are equal, otherwise false. |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
Intersect(Rect)
Intersects this rectangle with rect and updates to be the intersection
of this and rect. If either this or rect are Empty,
the result is Empty as well.
Declaration
public void Intersect(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The rect to intersect with this. |
IntersectsWith(Rect)
Indicates whether the specified rectangle intersects with the current rectangle.
Declaration
public bool IntersectsWith(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The rectangle to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the specified rectangle intersects with the current rectangle, false otherwise. |
Offset(Double, Double)
Moves the rectangle by the specified horizontal and vertical amounts.
Declaration
public void Offset(double offsetX, double offsetY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | offsetX | The amount to move the rectangle horizontally. |
| System.Double | offsetY | The amount to move the rectangle vertically. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | If trying to update an empty Rect. |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
Operators
| Improve this Doc View SourceEquality(Rect, Rect)
Indicates whether both Rect are equal.
Declaration
public static bool operator ==(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | First Rect to compare. |
| Rect | rect2 | Second Rect to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if both Rect are equal, otherwise false. |
Inequality(Rect, Rect)
Indicates whether both Rect are not equal.
Declaration
public static bool operator !=(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | First Rect to compare. |
| Rect | rect2 | Second Rect to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if both Rect are equal, otherwise false. |