Struct Rect
Describes the width, height, and point origin of a rectangle.
Inherited Members
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public struct Rect
Constructors
| Improve this Doc View SourceRect(Double, Double, Double, Double)
Initializes a Rect structure that has the specified x-coordinate, y-coordinate, width, and height.
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 are less than 0. |
Rect(Point, Point)
Initializes a Rect structure that is exactly large enough to contain the two specified points.
Declaration
public Rect(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | The first point that the new rectangle must contain. |
Point | point2 | The second point that the new rectangle must contain. |
Rect(Point, Size)
Initializes a Rect structure based on an origin and size.
Declaration
public Rect(Point location, Size size)
Parameters
Type | Name | Description |
---|---|---|
Point | location | The origin of the new Rect. |
Size | size | The size of the new Rect. |
Rect(Size)
Initializes a new instance of the Rect structure that is of the specified size and is located at (0,0).
Declaration
public Rect(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The size of the new 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 |
Empty
Gets a special value that represents a rectangle with no position or area.
Declaration
public static readonly Rect Empty { get; }
Property Value
Type | Description |
---|---|
Rect |
Height
Gets or sets the height of the rectangle.
Declaration
public double Height { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
IsEmpty
Gets a value that indicates whether the rectangle is the Windows.Foundation.Rect.Empty rectangle.
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
Gets or sets the position of the top-left corner of the rectangle.
Declaration
public Point Location { get; set; }
Property Value
Type | Description |
---|---|
Point |
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
Gets or sets the width and height of the rectangle.
Declaration
public Size Size { get; set; }
Property Value
Type | Description |
---|---|
Size |
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
Gets or sets the width of the rectangle.
Declaration
public double Width { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
X
Gets or sets the x-axis value of the left side of the rectangle.
Declaration
public double X { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Y
Gets or sets the y-axis value of the top side of the rectangle.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceContains(Point)
Indicates whether the rectangle described by the Windows.Foundation.Rect contains the specified point.
Declaration
public bool Contains(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | The point to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if the rectangle described by the Windows.Foundation.Rect contains the specified point; otherwise, false. |
Equals(Object)
Indicates whether the specified object is equal to the current Windows.Foundation.Rect.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object to compare to the current rectangle. |
Returns
Type | Description |
---|---|
System.Boolean | true if o is a Windows.Foundation.Rect and has the same x,y,width,height values as the current Windows.Foundation.Rect; otherwise, false. |
Overrides
Equals(Rect)
Indicates whether the specified Windows.Foundation.Rect is equal to the current Windows.Foundation.Rect.
Declaration
public bool Equals(Rect value)
Parameters
Type | Name | Description |
---|---|---|
Rect | value | The rectangle to compare to the current rectangle. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified Windows.Foundation.Rect has the same x,y,width,height property values as the current Windows.Foundation.Rect; otherwise, false. |
GetHashCode()
Creates a hash code for the Windows.Foundation.Rect.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the current Windows.Foundation.Rect structure. |
Overrides
Intersect(Rect)
Finds the intersection of the rectangle represented by the current Rect and the rectangle represented by the specified Rect, and stores the result as the current Rect.
Declaration
public void Intersect(Rect rect)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The rectangle to intersect with the current rectangle. |
Parse(String)
Declaration
public static Rect Parse(string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source |
Returns
Type | Description |
---|---|
Rect |
ToString()
Returns a string representation of the Rect structure. structure.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the current Rect structure. The string has the following form: "X,Y,Width,Height". |
Overrides
ToString(IFormatProvider)
Returns a string representation of the rectangle by using the specified format provider.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | Culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.String | A string representation of the current rectangle that is determined by the specified format provider. |
Union(Point)
Expands the rectangle represented by the current Windows.Foundation.Rect exactly enough to contain the specified point.
Declaration
public void Union(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | The point to include. |
Union(Rect)
Expands the rectangle represented by the current Windows.Foundation.Rect exactly enough to contain the specified rectangle.
Declaration
public void Union(Rect rect)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The rectangle to include. |
Operators
| Improve this Doc View SourceEquality(Rect, Rect)
Compares two Windows.Foundation.Rect structures for equality.
Declaration
public static bool operator ==(Rect rect1, Rect rect2)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect1 | The first rectangle to compare. |
Rect | rect2 | The second rectangle to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if the Windows.Foundation.Rect structures have the same x,y,width,height property values; otherwise, false. |
Inequality(Rect, Rect)
Compares two Windows.Foundation.Rect structures for inequality.
Declaration
public static bool operator !=(Rect rect1, Rect rect2)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect1 | The first rectangle to compare. |
Rect | rect2 | The second rectangle to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if the Windows.Foundation.Rect structures do not have the same x,y,width,height property values; otherwise, false. |