Rectangle

Rectangle class

Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left corner and its width and height. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

class Rectangle

Methods

MethodDescription
static Rectangle Ceiling(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object’s location and size values to the next higher integer values.
bool Contains(int, int) constDetermines if the specified point is located within the rectangle represented by the current object.
bool Contains(const Point&) constDetermines if the specified point is located within the rectangle represented by the current object.
bool Contains(const Rectangle&) constDetermines if the specified rectangle is located within the rectangle represented by the current object.
bool Equals(const Rectangle&) constDetermines if the rectangles represented by the current and the specified objects are identical.
static Rectangle FromLTRB(int, int, int, int)Constructs a new Rectangle object that represents a rectangle with the specified edge locations.
int get_Bottom() constReturns the y coordinate of the bottom edge of the rectangle represented by the current object.
int get_Height() constReturns the height of the rectangle represented by the current object.
bool get_IsEmpty() constDetermines if X and Y coordinates of the upper left corner of the recangle represented by the current object as well as its width and height have values of 0.
int get_Left() constReturns the X coordinate of the left edge of the rectangle represented by the current object.
Point get_Location() constReturns an instance of the Point class that specifies the location of the upper left corner of the rectangle represented by the current object.
int get_Right() constReturns the X coordinate of the right edge of the rectangle represented by the current object.
Size get_Size() constReturns an instance of the Size class that specifies the width and height of the rectangle represented by the current object.
int get_Top() constReturns the Y coordinate of the top edge of the rectangle represented by the current object.
int get_Width() constReturns the width of the rectangle represented by the current object.
int get_X() constReturns the X coordinate of the upper left corner of the rectangle represented by the current object.
int get_Y() constReturns the Y coordinate of the upper left corner of the rectangle represented by the current object.
int GetHashCode() constReturns a hash code of the current object.
void Inflate(int, int)Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.
void Inflate(const Size&)Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the amounts specified by width and height values of the specified size object correspondingly.
static Rectangle Inflate(const Rectangle&, int, int)Increases the width and height of the rectangle represented by the specified object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.
void Intersect(const Rectangle&)Replaces the rectangle represented by the current object with the rectangle that results from the its intersection with the rectangle represented by the specified object.
static Rectangle Intersect(const Rectangle&, const Rectangle&)Returns a rectangle that is a result of intersection of the specified rectangles.
bool IntersectsWith(const Rectangle&)Determines if the rectangles represented by the current and specified objects intesect.
void Offset(const Point&)Offsets the position of the rectangle represented by the current object by the specified amounts.
void Offset(int, int)Offsets the position of the rectangle represented by the current object by the specified amounts.
operator RectangleF() constReturns a RectangleF object that represents a rectangle equivalent to the rectangle represented by the current object.
bool operator!=(std::nullptr_t) constAlways returns true.
bool operator==(std::nullptr_t) constAlways returns false.
Rectangle()Constructs a new instance of Rectangle object that represents a rectangle with X and Y coordinates and width and hegiht values set to 0.
Rectangle(int, int, int, int)Constructs a new instance of Rectangle object that represents a rectangle with the specified coordinates of its upper left corner and width and height.
Rectangle(const Point&, const Size&)Constructs a new instance of Rectangle object that represents a rectangle with the coordinates of its upper left corner specified as an instance of Point class and its width and height as an instance of Size class.
Rectangle(const System::Windows::Forms::Screen::Rectangle_&)Constructs a new instance of Rectangle object that represents the rectangle equivalent to the specified one.
static Rectangle Round(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object’s location and size values to the nearest integer values.
void set_Height(int)Sets the height of the rectangle represented by the current object.
void set_Location(Point)Sets the location of the upper left corner of the rectangle represented by the current object.
void set_Size(Size)Sets the width and height of the rectangle represented by the current object.
void set_Width(int)Sets the width of the rectangle represented by the current object.
void set_X(int)Sets the X coordinate of the upper left corner of the rectangle represented by the current object.
void set_Y(int)Sets the Y coordinate of the upper left corner of the rectangle represented by the current object.
String ToString() constReturns the string representation of the current object.
static Rectangle Truncate(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by truncating the RectangleF object’s location and size values to the next lower integer values.
static Rectangle Union(const Rectangle&, const Rectangle&)Returns a rectangle that is a result of union of the specified rectangles.

Fields

FieldDescription
static EmptyAn empty rectangle i.e. a rectangle whose location and size values have zero values.

See Also