Rect​Helper Rect​Helper Rect​Helper Class

Definition

Provides helper methods to evaluate or set Rect values. C# and Microsoft Visual Basic code should use members of Rect instead.

public sealed class RectHelper : IRectHelperpublic sealed class RectHelper : IRectHelperPublic NotInheritable Class RectHelper Implements IRectHelper
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Rect is a Windows Runtime structure that represents a rectangle's dimensions with an origin.

RectHelper is one of several Helper classes that are intended to provide utility methods for Windows Runtime structure values. C# and Microsoft Visual Basic code can use members of Rect instead, because utility members are available directly on the structure due to .NET Framework runtime support. C++ code can only access the data values on Rect, for example Left. For C++ developers, approximately the same utility features that a Microsoft Visual Basic developer could use directly on Rect are available in a static form on the RectHelper class.

Properties

Empty Empty Empty

Gets a static Rect value where the Rect has no size or position (all values 0). C# and Microsoft Visual Basic code should use Empty instead.

public static Rect Empty { get; }public static Rect Empty { get; }Public Static ReadOnly Property Empty As Rect
Value
Rect Rect Rect

A Rect with all values as 0.

Attributes

Methods

Contains(Rect, Point) Contains(Rect, Point) Contains(Rect, Point)

Returns whether a given Point is within the bounds of a given Rect, for a shared coordinate reference. C# and Microsoft Visual Basic code should use Contains instead. C# and Microsoft Visual Basic code should use the = operator instead.

public static bool Contains(Rect target, Point point)public static bool Contains(Rect target, Point point)Public Static Function Contains(target As Rect, point As Point) As bool
Parameters
target
Rect Rect Rect

The Rect to evaluate.

point
Point Point Point

The Point to check for containment.

Returns
bool bool bool

true if point is within the target bounds; otherwise, false.

Attributes

Equals(Rect, Rect) Equals(Rect, Rect) Equals(Rect, Rect)

Provides comparison of the values of two Rect values. C# and Microsoft Visual Basic code should use the = operator instead.

public static bool Equals(Rect target, Rect value)public static bool Equals(Rect target, Rect value)Public Static Function Equals(target As Rect, value As Rect) As bool
Parameters
target
Rect Rect Rect

The first Rect to compare.

value
Rect Rect Rect

The second Rect to compare.

Returns
bool bool bool

true if target and value hold equivalent values; otherwise, false.

Attributes
See Also

FromCoordinatesAndDimensions(Single, Single, Single, Single) FromCoordinatesAndDimensions(Single, Single, Single, Single) FromCoordinatesAndDimensions(Single, Single, Single, Single)

Creates a new Rect value based on the element values of a Rect structure. C# and Microsoft Visual Basic code should use Rect(Double,Double,Double,Double) instead.

public static Rect FromCoordinatesAndDimensions(Single x, Single y, Single width, Single height)public static Rect FromCoordinatesAndDimensions(Single x, Single y, Single width, Single height)Public Static Function FromCoordinatesAndDimensions(x As Single, y As Single, width As Single, height As Single) As Rect
Parameters
x
System.Single System.Single System.Single

The pixel value to set for X.

y
System.Single System.Single System.Single

The pixel value to set for Y.

width
System.Single System.Single System.Single

The pixel value to set for Width.

height
System.Single System.Single System.Single

The pixel value to set for Height.

Returns

The created Rect.

Attributes

FromLocationAndSize(Point, Size) FromLocationAndSize(Point, Size) FromLocationAndSize(Point, Size)

Creates a new Rect value based on a Point that specifies the upper-left origin, and a Size that specifies the width and height. C# and Microsoft Visual Basic code should use Rect(Point,Size) instead.

public static Rect FromLocationAndSize(Point location, Size size)public static Rect FromLocationAndSize(Point location, Size size)Public Static Function FromLocationAndSize(location As Point, size As Size) As Rect
Parameters
location
Point Point Point

The Point location of the origin (upper left).

size
Size Size Size

The Size that specifies width and height.

Returns

The created Rect value.

Attributes

FromPoints(Point, Point) FromPoints(Point, Point) FromPoints(Point, Point)

Creates a new Rect value based on two points. C# and Microsoft Visual Basic code should use Rect(Point,Point) instead.

public static Rect FromPoints(Point point1, Point point2)public static Rect FromPoints(Point point1, Point point2)Public Static Function FromPoints(point1 As Point, point2 As Point) As Rect
Parameters
point1
Point Point Point

The first point.

point2
Point Point Point

The second point.

Returns

The created Rect.

Attributes

GetBottom(Rect) GetBottom(Rect) GetBottom(Rect)

Gets a "Bottom" value for the specified Rect. So long as Height is positive, "Bottom" is evaluated as Y + Height. C# and Microsoft Visual Basic code should use Bottom instead.

public static float GetBottom(Rect target)public static float GetBottom(Rect target)Public Static Function GetBottom(target As Rect) As float
Parameters
target
Rect Rect Rect

The Rect to evaluate.

Returns
float float float

The evaluated "Bottom" value.

Attributes

GetIsEmpty(Rect) GetIsEmpty(Rect) GetIsEmpty(Rect)

Returns whether a specified Rect is equivalent to an Empty Rect. C# and Microsoft Visual Basic code should use IsEmpty instead.

public static bool GetIsEmpty(Rect target)public static bool GetIsEmpty(Rect target)Public Static Function GetIsEmpty(target As Rect) As bool
Parameters
target
Rect Rect Rect

The Rect to evaluate.

Returns
bool bool bool

true if the specified Rect is equivalent to an Empty Rect; otherwise, false.

Attributes

GetLeft(Rect) GetLeft(Rect) GetLeft(Rect)

Gets a "Left" value for the specified Rect. So long as Width is positive, "Left" is evaluated as X. C# and Microsoft Visual Basic code should use Left instead.

public static float GetLeft(Rect target)public static float GetLeft(Rect target)Public Static Function GetLeft(target As Rect) As float
Parameters
target
Rect Rect Rect

The Rect to evaluate.

Returns
float float float

The evaluated "Left" value.

Attributes

GetRight(Rect) GetRight(Rect) GetRight(Rect)

Gets a "Right" value for the specified Rect. So long as Width is positive, "Right" is evaluated as X + Width. C# and Microsoft Visual Basic code should use Right instead.

public static float GetRight(Rect target)public static float GetRight(Rect target)Public Static Function GetRight(target As Rect) As float
Parameters
target
Rect Rect Rect

The Rect to evaluate.

Returns
float float float

The evaluated "Right" value.

Attributes

GetTop(Rect) GetTop(Rect) GetTop(Rect)

Gets a "Top" value for the specified Rect. So long as Height is positive, "Top" is evaluated as Y. C# and Microsoft Visual Basic code should use Top instead.

public static float GetTop(Rect target)public static float GetTop(Rect target)Public Static Function GetTop(target As Rect) As float
Parameters
target
Rect Rect Rect

The Rect to evaluate.

Returns
float float float

The evaluated "Top" value.

Attributes

Intersect(Rect, Rect) Intersect(Rect, Rect) Intersect(Rect, Rect)

Returns the areas of two specified Rect values that intersect, as a new Rect. C# and Microsoft Visual Basic code should use Intersect instead.

public static Rect Intersect(Rect target, Rect rect)public static Rect Intersect(Rect target, Rect rect)Public Static Function Intersect(target As Rect, rect As Rect) As Rect
Parameters
target
Rect Rect Rect

The first Rect to check for intersect.

rect
Rect Rect Rect

The second Rect to check for intersect.

Returns

A Rect that represents the areas of target and rect that intersect. Can be an Empty value if there is no intersect.

Attributes

Union(Rect, Point) Union(Rect, Point) Union(Rect, Point)

Creates a rectangle that is exactly large enough to contain the a specified rectangle and a specified point. C# and Microsoft Visual Basic code should use Union(Point) instead.

public static Rect Union(Rect target, Point point)public static Rect Union(Rect target, Point point)Public Static Function Union(target As Rect, point As Point) As Rect
Parameters
target
Rect Rect Rect

The rectangle to include.

point
Point Point Point

The point to include.

Returns

A rectangle that is exactly large enough to contain the specified rectangle and point.

Attributes

Union(Rect, Rect) Union(Rect, Rect) Union(Rect, Rect)

Creates a rectangle that is exactly large enough to contain the two specified rectangles. C# and Microsoft Visual Basic code should use Union(Rect) instead.

public static Rect Union(Rect target, Rect rect)public static Rect Union(Rect target, Rect rect)Public Static Function Union(target As Rect, rect As Rect) As Rect
Parameters
target
Rect Rect Rect

The first rectangle to include.

rect
Rect Rect Rect

The second rectangle to include.

Returns

A rectangle that is exactly large enough to contain the two specified rectangles.

Attributes