Struct Rectangle
Implements
Namespace: MarcusW.VncClient
Assembly: MarcusW.VncClient.dll
Syntax
public struct Rectangle : IEquatable<Rectangle>
Constructors
| Improve this Doc View SourceRectangle(Position, Size)
Initializes a new instance of the Rectangle structure.
Declaration
public Rectangle(Position position, Size size)
Parameters
Type | Name | Description |
---|---|---|
Position | position | The position of the upper left corner of the rectangle. |
Size | size | The size of the rectangle. |
Rectangle(Int32, Int32, Int32, Int32)
Initializes a new instance of the Rectangle structure.
Declaration
public Rectangle(int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x coordinate of the upper left corner of the rectangle. |
System.Int32 | y | The y coordinate of the upper left corner of the rectangle. |
System.Int32 | width | The width of the rectangle. |
System.Int32 | height | The height of the rectangle. |
Fields
| Improve this Doc View SourceZero
A rectangle with the size zero at the origin of the coordinate system.
Declaration
public static readonly Rectangle Zero
Field Value
Type | Description |
---|---|
Rectangle |
Properties
| Improve this Doc View SourcePosition
Gets the position of the upper left corner of the rectangle.
Declaration
public Position Position { get; }
Property Value
Type | Description |
---|---|
Position |
Size
Gets the size of the rectangle.
Declaration
public Size Size { get; }
Property Value
Type | Description |
---|---|
Size |
Methods
| Improve this Doc View SourceCroppedTo(Rectangle)
Returns a new Rectangle that is reduced enough to make it fit inside the given area.
Declaration
public Rectangle CroppedTo(in Rectangle area)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | area | The area in which the rectangle should fit in. |
Returns
Type | Description |
---|---|
Rectangle | A new rectangle. |
Equals(Rectangle)
Declaration
public bool Equals(Rectangle other)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | other |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Nullable<Object>)
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | obj |
Returns
Type | Description |
---|---|
System.Boolean |
FitsInside(Rectangle)
Returns whether this rectangle completely fits inside the given area.
Declaration
public bool FitsInside(in Rectangle area)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | area | The area in which the rectangle should fit in. |
Returns
Type | Description |
---|---|
System.Boolean | True if it fits inside, otherwise false. |
FitsInside(Size)
Returns whether this rectangle completely fits inside an area in the origin with the given size.
Declaration
public bool FitsInside(in Size areaSize)
Parameters
Type | Name | Description |
---|---|---|
Size | areaSize | The size of the area in which the rectangle should fit in. |
Returns
Type | Description |
---|---|
System.Boolean | True if it fits inside, otherwise false. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
IsEmpty()
Returns whether this rectangle has no content (one side is zero)
Declaration
public bool IsEmpty()
Returns
Type | Description |
---|---|
System.Boolean | True if it has no content, otherwise false. |
Overlaps(Rectangle)
Returns whether this rectangle overlaps the given area.
Declaration
public bool Overlaps(in Rectangle area)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | area | The area to test for. |
Returns
Type | Description |
---|---|
System.Boolean | True if they overlap, otherwise false. |
ToString()
Returns the string representation of the rectangle.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The string representation of the rectangle. |
WithPosition(Position)
Returns a new Rectangle with the specified position.
Declaration
public Rectangle WithPosition(Position position)
Parameters
Type | Name | Description |
---|---|---|
Position | position | The position. |
Returns
Type | Description |
---|---|
Rectangle | A new rectangle. |
WithSize(Size)
Returns a new Rectangle with the specified size.
Declaration
public Rectangle WithSize(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The size. |
Returns
Type | Description |
---|---|
Rectangle | A new rectangle. |
Operators
| Improve this Doc View SourceEquality(Rectangle, Rectangle)
Checks for equality between two Rectangles.
Declaration
public static bool operator ==(Rectangle left, Rectangle right)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | left | The first rectangle. |
Rectangle | right | The second rectangle. |
Returns
Type | Description |
---|---|
System.Boolean | True if the rectangles are equal, otherwise false. |
Inequality(Rectangle, Rectangle)
Checks for inequality between two Rectangles.
Declaration
public static bool operator !=(Rectangle left, Rectangle right)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | left | The first rectangle. |
Rectangle | right | The second rectangle. |
Returns
Type | Description |
---|---|
System.Boolean | True if the rectangles are unequal, otherwise false. |