Rect 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化结构的新实例 Rect 。
重载
| 名称 | 说明 |
|---|---|
| Rect(Size) |
初始化具有指定大小且位于 (0,0) 的结构的新实例 Rect 。 |
| Rect(Point, Point) |
初始化结构的新实例,该实例 Rect 的大小正好足以包含两个指定点。 |
| Rect(Point, Size) |
初始化具有指定左上角位置和指定宽度和高度的结构的新实例 Rect 。 |
| Rect(Point, Vector) |
初始化结构的新实例,该实例 Rect 的大小正好足以包含指定点和指定点和指定向量的总和。 |
| Rect(Double, Double, Double, Double) |
初始化具有指定 x 坐标、y 坐标、宽度和高度的结构的新实例 Rect 。 |
Rect(Size)
初始化具有指定大小且位于 (0,0) 的结构的新实例 Rect 。
public:
Rect(System::Windows::Size size);
public Rect(System.Windows.Size size);
new System.Windows.Rect : System.Windows.Size -> System.Windows.Rect
Public Sub New (size As Size)
参数
示例
以下示例演示如何使用Rect构造函数创建新Rect(Size)结构。
private Rect createRectExample2()
{
// This constructor initializes a new instance of the Rect structure that
// is of the specified size and is located at (0,0).
Rect myRectangle = new Rect(new Size(200, 50));
// Returns a rectangle with a width of 200, a height of 50 and a position
// of 0,0.
return myRectangle;
}
适用于
Rect(Point, Point)
初始化结构的新实例,该实例 Rect 的大小正好足以包含两个指定点。
public:
Rect(System::Windows::Point point1, System::Windows::Point point2);
public Rect(System.Windows.Point point1, System.Windows.Point point2);
new System.Windows.Rect : System.Windows.Point * System.Windows.Point -> System.Windows.Rect
Public Sub New (point1 As Point, point2 As Point)
参数
- point1
- Point
新矩形必须包含的第一个点。
- point2
- Point
新矩形必须包含的第二个点。
示例
以下示例演示如何使用Rect构造函数创建新Rect(Point, Point)结构。
private Rect createRectExample3()
{
// This constructor intializes a new instance of the Rect structure that is
// exactly large enough to contain the two specified points.
Rect myRectangle = new Rect(new Point(15, 30), new Point(50,70));
// Returns a rectangle with a position of 15,30, a width of 35 and height of 40.
return myRectangle;
}
适用于
Rect(Point, Size)
初始化具有指定左上角位置和指定宽度和高度的结构的新实例 Rect 。
public:
Rect(System::Windows::Point location, System::Windows::Size size);
public Rect(System.Windows.Point location, System.Windows.Size size);
new System.Windows.Rect : System.Windows.Point * System.Windows.Size -> System.Windows.Rect
Public Sub New (location As Point, size As Size)
参数
- location
- Point
一个指定矩形左上角位置的点。
示例
以下示例演示如何使用Rect构造函数创建新Rect(Point, Size)结构。
private Rect createRectExample4()
{
// This constructor initializes a new instance of the Rect structure that has the
// specified top-left corner location and the specified width and height (Size).
Rect myRectangle = new Rect(new Point(15, 30), new Size(35, 40));
// Returns a rectangle with a position of 15,30, a width of 35 and height of 40.
return myRectangle;
}
适用于
Rect(Point, Vector)
初始化结构的新实例,该实例 Rect 的大小正好足以包含指定点和指定点和指定向量的总和。
public:
Rect(System::Windows::Point point, System::Windows::Vector vector);
public Rect(System.Windows.Point point, System.Windows.Vector vector);
new System.Windows.Rect : System.Windows.Point * System.Windows.Vector -> System.Windows.Rect
Public Sub New (point As Point, vector As Vector)
参数
- point
- Point
矩形必须包含的第一个点。
- vector
- Vector
偏移指定点的量。 生成的矩形的大小将完全足以包含这两个点。
示例
以下示例演示如何使用Rect构造函数创建新Rect(Point, Vector)结构。
private Rect createRectExample5()
{
// This constructor Intializes a new instance of the Rect structure that is exactly
// large enough to contain the specified point and the sum of the specified point
// and the specified vector.
Rect myRectangle = new Rect(new Point(15, 30), new Vector(35, 40));
// Returns a rectangle with a position of 15,30, a width of 35 and height of 40.
return myRectangle;
}
适用于
Rect(Double, Double, Double, Double)
初始化具有指定 x 坐标、y 坐标、宽度和高度的结构的新实例 Rect 。
public:
Rect(double x, double y, double width, double height);
public Rect(double x, double y, double width, double height);
new System.Windows.Rect : double * double * double * double -> System.Windows.Rect
Public Sub New (x As Double, y As Double, width As Double, height As Double)
参数
- x
- Double
矩形左上角的 x 坐标。
- y
- Double
矩形左上角的 y 坐标。
- width
- Double
矩形的宽度。
- height
- Double
矩形的高度。
例外
注解
以下示例演示如何使用Rect构造函数创建新Rect(Double, Double, Double, Double)结构。
private Rect createRectExample6()
{
// This constructor intializes a new instance of the Rect structure with the specified
// x- and y-coordinates and the specified width and height.
Rect myRectangle = new Rect(15, 30, 35, 40);
// Returns a rectangle with a position of 15,30, a width of 35 and height of 40.
return myRectangle;
}