Rect コンストラクター

定義

Rect 構造体の新しいインスタンスを初期化します。

オーバーロード

Rect(Size)

指定したサイズを持ち、座標 (0,0) に位置する Rect 構造体の新しいインスタンスを初期化します。

Rect(Point, Point)

指定した 2 つの点をちょうど格納できる大きさを持つ、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)

パラメーター

size
Size

四角形の幅および高さを指定する 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)

指定した 2 つの点をちょうど格納できる大きさを持つ、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

新しい四角形に格納する必要がある 2 番目の点。

次の例は、コンストラクターを使用して新しい 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

四角形の左上隅の場所を指定する点。

size
Size

四角形の幅および高さを指定する Size 構造体。

次の例は、コンストラクターを使用して新しい 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

指定した点をオフセットする量。 結果として得られる四角形は、2 つの点をちょうど格納できる大きさになります。

次の例は、コンストラクターを使用して新しい 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

四角形の高さ。

例外

width は負の値です。

  • または - height は負の値です。

注釈

次の例は、コンストラクターを使用して新しい 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;
}

適用対象