Rect Costruttori

Definizione

Inizializza una nuova istanza della struttura Rect.

Overload

Rect(Size)

Inizializza una nuova istanza della struttura Rect che è della dimensione specificata ed è individuata a (0,0).

Rect(Point, Point)

Inizializza una nuova istanza della struttura Rect che è abbastanza grande per contenere i due punti specificati.

Rect(Point, Size)

Inizializza una nuova istanza della struttura Rect che possiede il percorso specificato dell'angolo superiore sinistro e la larghezza e l’altezza specificate.

Rect(Point, Vector)

Inizializza una nuova istanza della struttura Rect che è abbastanza grande per contenere il punto specificato e la somma del punto specificato e del vettore specificato.

Rect(Double, Double, Double, Double)

Inizializza una nuova istanza della struttura Rect che ha le coordinate x e y, la larghezza e l’altezza specificate.

Rect(Size)

Inizializza una nuova istanza della struttura Rect che è della dimensione specificata ed è individuata a (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)

Parametri

size
Size

Struttura Size che specifica la larghezza e l'altezza del rettangolo.

Esempio

Nell'esempio seguente viene illustrato come creare una nuova Rect struttura usando il Rect(Size) costruttore .

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;
}

Si applica a

Rect(Point, Point)

Inizializza una nuova istanza della struttura Rect che è abbastanza grande per contenere i due punti specificati.

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)

Parametri

point1
Point

Il primo punto che il nuovo rettangolo deve contenere.

point2
Point

Il secondo punto che il nuovo rettangolo deve contenere.

Esempio

Nell'esempio seguente viene illustrato come creare una nuova Rect struttura usando il Rect(Point, Point) costruttore .

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;
}

Si applica a

Rect(Point, Size)

Inizializza una nuova istanza della struttura Rect che possiede il percorso specificato dell'angolo superiore sinistro e la larghezza e l’altezza specificate.

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)

Parametri

location
Point

Un punto che specifica il percorso dell'angolo superiore sinistro del rettangolo.

size
Size

Struttura Size che specifica la larghezza e l'altezza del rettangolo.

Esempio

Nell'esempio seguente viene illustrato come creare una nuova Rect struttura usando il Rect(Point, Size) costruttore .

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;
}

Si applica a

Rect(Point, Vector)

Inizializza una nuova istanza della struttura Rect che è abbastanza grande per contenere il punto specificato e la somma del punto specificato e del vettore specificato.

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)

Parametri

point
Point

Il primo punto che il rettangolo deve contenere.

vector
Vector

Quantità di cui eseguire l’offset del punto specificato. Il rettangolo risultante sarà abbastanza grande per contenere entrambi i punti.

Esempio

Nell'esempio seguente viene illustrato come creare una nuova Rect struttura usando il Rect(Point, Vector) costruttore .

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;
}

Si applica a

Rect(Double, Double, Double, Double)

Inizializza una nuova istanza della struttura Rect che ha le coordinate x e y, la larghezza e l’altezza specificate.

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)

Parametri

x
Double

Coordinata x dell'angolo superiore sinistro del rettangolo.

y
Double

Coordinata Y dell'angolo superiore sinistro del rettangolo.

width
Double

Larghezza del rettangolo.

height
Double

Altezza del rettangolo.

Eccezioni

width è un valore negativo.

-oppure- height è un valore negativo.

Commenti

Nell'esempio seguente viene illustrato come creare una nuova Rect struttura usando il Rect(Double, Double, Double, Double) costruttore .

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;
}

Si applica a