RectangleRectangleRectangleRectangle Struct

定义

``public value class Rectangle : IEquatable<System::Drawing::Rectangle>``
``````[System.ComponentModel.TypeConverter(typeof(System.Drawing.RectangleConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Rectangle : IEquatable<System.Drawing.Rectangle>``````
``type Rectangle = struct``
``````Public Structure Rectangle
Implements IEquatable(Of Rectangle)``````

RectangleRectangleRectangleRectangle

示例

``````Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 5);
e.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50);
``````
``````Dim blackPen As New Pen(Color.FromArgb(255, 0, 0, 0), 5)
e.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50)
``````

构造函数

 Rectangle(Point, Size) Rectangle(Point, Size) Rectangle(Point, Size) Rectangle(Point, Size) 用指定的位置和大小初始化 Rectangle 类的新实例。Initializes a new instance of the Rectangle class with the specified location and size. Rectangle(Int32, Int32, Int32, Int32) Rectangle(Int32, Int32, Int32, Int32) Rectangle(Int32, Int32, Int32, Int32) Rectangle(Int32, Int32, Int32, Int32) 用指定的位置和大小初始化 Rectangle 类的新实例。Initializes a new instance of the Rectangle class with the specified location and size.

字段

 Empty Empty Empty Empty 表示其属性未被初始化的 Rectangle 结构。Represents a Rectangle structure with its properties left uninitialized.

属性

 Bottom Bottom Bottom Bottom 获取 y 坐标，该坐标是此 Rectangle 结构的 Y 与 Height 属性值之和。Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure. Height Height Height Height 获取或设置此 Rectangle 结构的高度。Gets or sets the height of this Rectangle structure. IsEmpty IsEmpty IsEmpty IsEmpty 测试此 Rectangle 的所有数值属性是否都具有零值。Tests whether all numeric properties of this Rectangle have values of zero. Left Left Left Left 获取此 Rectangle 结构左边缘的 x 坐标。Gets the x-coordinate of the left edge of this Rectangle structure. Location Location Location Location 获取或设置此 Rectangle 结构左上角的坐标。Gets or sets the coordinates of the upper-left corner of this Rectangle structure. Right Right Right Right 获取 x 坐标，该坐标是此 Rectangle 结构的 X与 Width 属性值之和。Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure. Size Size Size Size 获取或设置此 Rectangle 的大小。Gets or sets the size of this Rectangle. Top Top Top Top 获取此 Rectangle 结构上边缘的 y 坐标。Gets the y-coordinate of the top edge of this Rectangle structure. Width Width Width Width 获取或设置此 Rectangle 结构的宽度。Gets or sets the width of this Rectangle structure. X X X X 获取或设置此 Rectangle 结构左上角的 x 坐标。Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure. Y Y Y Y 获取或设置此 Rectangle 结构左上角的 y 坐标。Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.

方法

 Ceiling(RectangleF) Ceiling(RectangleF) Ceiling(RectangleF) Ceiling(RectangleF) 通过将 RectangleF 值舍入到比它大的相邻整数值，将指定的 RectangleF 结构转换为 Rectangle 结构。Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values. Contains(Point) Contains(Point) Contains(Point) Contains(Point) 确定指定的点是否包含在此 Rectangle 结构内。Determines if the specified point is contained within this Rectangle structure. Contains(Rectangle) Contains(Rectangle) Contains(Rectangle) Contains(Rectangle) 确定 `rect` 表示的矩形区域是否完全包含在此 Rectangle 结构内。Determines if the rectangular region represented by `rect` is entirely contained within this Rectangle structure. Contains(Int32, Int32) Contains(Int32, Int32) Contains(Int32, Int32) Contains(Int32, Int32) 确定指定的点是否包含在此 Rectangle 结构内。Determines if the specified point is contained within this Rectangle structure. Equals(Rectangle) Equals(Rectangle) Equals(Rectangle) Equals(Rectangle) Equals(Object) Equals(Object) Equals(Object) Equals(Object) 测试 `obj` 是否为与此 Rectangle 结构具有相同位置和大小的 Rectangle 结构。Tests whether `obj` is a Rectangle structure with the same location and size of this Rectangle structure. FromLTRB(Int32, Int32, Int32, Int32) FromLTRB(Int32, Int32, Int32, Int32) FromLTRB(Int32, Int32, Int32, Int32) FromLTRB(Int32, Int32, Int32, Int32) 创建一个具有指定边缘位置的 Rectangle 结构。Creates a Rectangle structure with the specified edge locations. GetHashCode() GetHashCode() GetHashCode() GetHashCode() 返回此 Rectangle 结构的哈希代码。Returns the hash code for this Rectangle structure. 有关如何使用哈希代码的信息，请参见 GetHashCode()。For information about the use of hash codes, see GetHashCode() . Inflate(Size) Inflate(Size) Inflate(Size) Inflate(Size) 将此 Rectangle 放大指定量。Enlarges this Rectangle by the specified amount. Inflate(Int32, Int32) Inflate(Int32, Int32) Inflate(Int32, Int32) Inflate(Int32, Int32) 将此 Rectangle 放大指定量。Enlarges this Rectangle by the specified amount. Inflate(Rectangle, Int32, Int32) Inflate(Rectangle, Int32, Int32) Inflate(Rectangle, Int32, Int32) Inflate(Rectangle, Int32, Int32) 创建并返回指定 Rectangle 结构的放大副本。Creates and returns an enlarged copy of the specified Rectangle structure. 该副本被放大指定的量。The copy is enlarged by the specified amount. 不修改原始 Rectangle 结构。The original Rectangle structure remains unmodified. Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) 返回第三个 Rectangle 结构，它表示其他两个 Rectangle 结构的交集。Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. 如果没有重叠，将返回空的 Rectangle。If there is no intersection, an empty Rectangle is returned. Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) 将此 Rectangle 替换为其自身与指定 Rectangle 的交集。Replaces this Rectangle with the intersection of itself and the specified Rectangle. IntersectsWith(Rectangle) IntersectsWith(Rectangle) IntersectsWith(Rectangle) IntersectsWith(Rectangle) 确定此矩形是否与 `rect` 相交。Determines if this rectangle intersects with `rect`. Offset(Point) Offset(Point) Offset(Point) Offset(Point) 将此矩形的位置调整指定的量。Adjusts the location of this rectangle by the specified amount. Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32) 将此矩形的位置调整指定的量。Adjusts the location of this rectangle by the specified amount. Round(RectangleF) Round(RectangleF) Round(RectangleF) Round(RectangleF) 通过将 RectangleF 舍入到最近的整数值，将指定的 Rectangle 转换为 RectangleF。Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values. ToString() ToString() ToString() ToString() 将此 Rectangle 的特性转换为可读字符串。Converts the attributes of this Rectangle to a human-readable string. Truncate(RectangleF) Truncate(RectangleF) Truncate(RectangleF) Truncate(RectangleF) 通过截断 RectangleF 值，将指定的 RectangleF 转换为 Rectangle。Converts the specified RectangleF to a Rectangle by truncating the RectangleF values. Union(Rectangle, Rectangle) Union(Rectangle, Rectangle) Union(Rectangle, Rectangle) Union(Rectangle, Rectangle) 获取包含两个 Rectangle 结构的交集的 Rectangle 结构。Gets a Rectangle structure that contains the union of two Rectangle structures.

操作员

 Equality(Rectangle, Rectangle) Equality(Rectangle, Rectangle) Equality(Rectangle, Rectangle) Equality(Rectangle, Rectangle) 测试两个 Rectangle 结构的位置和大小是否相同。Tests whether two Rectangle structures have equal location and size. Inequality(Rectangle, Rectangle) Inequality(Rectangle, Rectangle) Inequality(Rectangle, Rectangle) Inequality(Rectangle, Rectangle) 测试两个 Rectangle 结构的位置或大小是否不同。Tests whether two Rectangle structures differ in location or size.