System::Drawing::Rectangle 类

Rectangle class

表示图像的矩形区域,由左上角的整数 X 和 Y 坐标以及宽度和高度定义。此类型应在栈上分配,并通过值或引用传递给函数。切勿使用 System::SmartPtr 类来管理此类型的对象。

class Rectangle

方法

方法描述
static Ceiling(const RectangleF&)从指定的 RectangleF 对象构造一个 Rectangle 对象,通过将 RectangleF 对象的位置和大小值向上取整为下一个整数。
Contains(int, int) const确定指定的点是否位于当前对象所表示的矩形内部。
Contains(const Point&) const确定指定的点是否位于当前对象所表示的矩形内部。
Contains(const Rectangle&) const确定指定的矩形是否位于当前对象所表示的矩形内部。
Equals(const Rectangle&) const确定当前对象和指定对象所表示的矩形是否相同。
static FromLTRB(int, int, int, int)构造一个新的 Rectangle 对象,表示具有指定边缘位置的矩形。
get_Bottom() const返回当前对象所表示的矩形底部边缘的 y 坐标。
get_Height() const返回当前对象所表示的矩形的高度。
get_IsEmpty() const确定当前对象所表示的矩形的左上角 X 和 Y 坐标以及其宽度和高度是否为 0。
get_Left() const返回当前对象所表示的矩形左边缘的 X 坐标。
get_Location() const返回一个 Point 类的实例,指定当前对象所表示的矩形左上角的位置。
get_Right() const返回当前对象所表示的矩形右边缘的 X 坐标。
get_Size() const返回一个 Size 类的实例,指定当前对象所表示的矩形的宽度和高度。
get_Top() const返回当前对象所表示的矩形顶部边缘的 Y 坐标。
get_Width() const返回当前对象所表示的矩形的宽度。
get_X() const返回当前对象所表示的矩形左上角的 X 坐标。
get_Y() const返回当前对象所表示的矩形左上角的 Y 坐标。
GetHashCode() const返回当前对象的哈希码。
Inflate(int, int)在保持矩形几何中心位置不变的情况下,增加当前对象所表示的矩形的宽度和高度。宽度和高度在两个方向上均按指定的量增加。
Inflate(const Size&)在保持矩形几何中心位置不变的情况下,增加当前对象所表示的矩形的宽度和高度。宽度和高度分别按指定尺寸对象的宽度和高度值对应的量增加。
static Inflate(const Rectangle&, int, int)在保持矩形几何中心位置不变的情况下,增加指定对象所表示的矩形的宽度和高度。宽度和高度在两个方向上均按指定的量增加。
Intersect(const Rectangle&)用当前对象所表示的矩形与指定对象所表示的矩形相交得到的矩形替换当前对象所表示的矩形。
static Intersect(const Rectangle&, const Rectangle&)返回指定矩形相交的结果矩形。
IntersectsWith(const Rectangle&)确定当前对象和指定对象所表示的矩形是否相交。
Offset(const Point&)按指定的量偏移当前对象所表示的矩形的位置。
Offset(int, int)按指定的量偏移当前对象所表示的矩形的位置。
operator RectangleF() const返回一个 RectangleF 对象,表示等同于当前对象所表示的矩形的矩形。
operator!=(std::nullptr_t) const始终返回 true。
operator==(std::nullptr_t) const始终返回 false。
Rectangle()构造一个新的 Rectangle 对象实例,其 X、Y 坐标以及宽度和高度值均设为 0。
Rectangle(int, int, int, int)构造一个新的 Rectangle 对象实例,表示具有指定左上角坐标以及宽度和高度的矩形。
Rectangle(const Point&, const Size&)构造一个新的 Rectangle 对象实例,表示其左上角坐标由 Point 类的实例指定,宽度和高度由 Size 类的实例指定的矩形。
Rectangle(const System::Windows::Forms::Screen::Rectangle_&)构造一个新的 Rectangle 对象实例,表示等同于指定矩形的矩形。
static Round(const RectangleF&)从指定的 RectangleF 对象构造一个 Rectangle 对象,通过将 RectangleF 对象的位置和大小值四舍五入为最近的整数。
set_Height(int)设置当前对象所表示矩形的高度。
set_Location(Point)设置当前对象所表示矩形左上角的位置。
set_Size(Size)设置当前对象所表示矩形的宽度和高度。
set_Width(int)设置当前对象所表示矩形的宽度。
set_X(int)设置当前对象所表示矩形左上角的 X 坐标。
set_Y(int)设置当前对象所表示矩形左上角的 Y 坐标。
ToString() const返回当前对象的字符串表示形式。
static Truncate(const RectangleF&)从指定的 RectangleF 对象构造一个 Rectangle 对象,通过将 RectangleF 对象的位置和大小值截断为下一个整数。
static Union(const Rectangle&, const Rectangle&)返回由指定矩形合并得到的矩形。

字段

字段描述
static Empty空矩形,即位置和尺寸值均为零的矩形。

另见