Show / Hide Table of Contents

Struct Rect

Represents a rectangle.

Implements
System.IEquatable<Rect>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: GraphShape
Assembly: GraphShape.dll
Syntax
[Serializable]
public struct Rect : IEquatable<Rect>

Constructors

| Improve this Doc View Source

Rect(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.

| Improve this Doc View Source

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

width or height is negative.

Fields

| Improve this Doc View Source

Empty

Empty rectangle.

Declaration
public static readonly Rect Empty
Field Value
Type Description
Rect

Properties

| Improve this Doc View Source

Bottom

Gets the y-axis value of the bottom of the rectangle.

Declaration
public readonly double Bottom { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

BottomLeft

Gets the position of the bottom-left corner of the rectangle.

Declaration
public readonly Point BottomLeft { get; }
Property Value
Type Description
Point
| Improve this Doc View Source

BottomRight

Gets the position of the bottom-right corner of the rectangle.

Declaration
public readonly Point BottomRight { get; }
Property Value
Type Description
Point
| Improve this Doc View Source

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.

| Improve this Doc View Source

IsEmpty

Indicates if this rectangle is empty.

Declaration
public readonly bool IsEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

Top

Gets the y-axis position of the top of the rectangle.

Declaration
public readonly double Top { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

TopLeft

Gets the position of the top-left corner of the rectangle.

Declaration
public readonly Point TopLeft { get; }
Property Value
Type Description
Point
| Improve this Doc View Source

TopRight

Gets the position of the top-right corner of the rectangle.

Declaration
public readonly Point TopRight { get; }
Property Value
Type Description
Point
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

Equals(Rect)

Declaration
public bool Equals(Rect other)
Parameters
Type Name Description
Rect other
Returns
Type Description
System.Boolean
| Improve this Doc View Source

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.

| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.ValueType.ToString()

Operators

| Improve this Doc View Source

Equality(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.

| Improve this Doc View Source

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.

Implements

System.IEquatable<T>

Extension Methods

GraphHelpers.GetDistances<TVertex, TEdge, TGraph>(TGraph)
GraphHelpers.GetDiameter<TVertex, TEdge, TGraph>(TGraph)
GraphHelpers.GetDiameter<TVertex, TEdge, TGraph>(TGraph, out Double[,])
OverlapRemovalHelpers.GetCenter(Rect)
  • Improve this Doc
  • View Source
In This Article
Back to top GraphShape