Rect Konstruktory

Definicja

Inicjuje Rect nowe wystąpienie struktury.

Przeciążenia

Rect(Size)

Inicjuje Rect nowe wystąpienie struktury o określonym rozmiarze i znajduje się w lokalizacji (0,0).

Rect(Point, Point)

Inicjuje Rect nowe wystąpienie struktury, która jest wystarczająco duża, aby zawierała dwa określone punkty.

Rect(Point, Size)

Inicjuje nowe wystąpienie Rect struktury, która ma określoną lokalizację lewego górnego rogu oraz określoną szerokość i wysokość.

Rect(Point, Vector)

Inicjuje nowe wystąpienie Rect struktury, która jest wystarczająco duża, aby zawierać określony punkt i sumę określonego punktu i określonego wektora.

Rect(Double, Double, Double, Double)

Inicjuje Rect nowe wystąpienie struktury, która ma określoną współrzędną x, współrzędną y, szerokość i wysokość.

Rect(Size)

Inicjuje Rect nowe wystąpienie struktury o określonym rozmiarze i znajduje się w lokalizacji (0,0).

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)

Parametry

size
Size

Struktura Size określająca szerokość i wysokość prostokąta.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć nową Rect strukturę przy użyciu konstruktora 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;
}

Dotyczy

Rect(Point, Point)

Inicjuje Rect nowe wystąpienie struktury, która jest wystarczająco duża, aby zawierała dwa określone punkty.

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)

Parametry

point1
Point

Pierwszy punkt, który musi zawierać nowy prostokąt.

point2
Point

Drugi punkt, który musi zawierać nowy prostokąt.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć nową Rect strukturę przy użyciu konstruktora 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;
}

Dotyczy

Rect(Point, Size)

Inicjuje nowe wystąpienie Rect struktury, która ma określoną lokalizację lewego górnego rogu oraz określoną szerokość i wysokość.

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)

Parametry

location
Point

Punkt określający lokalizację lewego górnego rogu prostokąta.

size
Size

Struktura Size określająca szerokość i wysokość prostokąta.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć nową Rect strukturę przy użyciu konstruktora 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;
}

Dotyczy

Rect(Point, Vector)

Inicjuje nowe wystąpienie Rect struktury, która jest wystarczająco duża, aby zawierać określony punkt i sumę określonego punktu i określonego wektora.

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)

Parametry

point
Point

Pierwszy punkt musi zawierać prostokąt.

vector
Vector

Kwota przesunięcia określonego punktu. Wynikowy prostokąt będzie dokładnie wystarczająco duży, aby zawierał oba punkty.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć nową Rect strukturę przy użyciu konstruktora 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;
}

Dotyczy

Rect(Double, Double, Double, Double)

Inicjuje Rect nowe wystąpienie struktury, która ma określoną współrzędną x, współrzędną y, szerokość i wysokość.

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)

Parametry

x
Double

Współrzędna x lewego górnego rogu prostokąta.

y
Double

Współrzędna y lewego górnego rogu prostokąta.

width
Double

Szerokość prostokąta.

height
Double

Wysokość prostokąta.

Wyjątki

width jest wartością ujemną.

-lub- height jest wartością ujemną.

Uwagi

W poniższym przykładzie pokazano, jak utworzyć nową Rect strukturę przy użyciu konstruktora 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;
}

Dotyczy