Rect Constructores

Definición

Inicializa una nueva instancia de la estructura Rect.

Sobrecargas

Rect(Size)

Inicializa una nueva instancia de la estructura Rect que tiene el tamaño especificado y se ubica en (0,0).

Rect(Point, Point)

Inicializa una nueva instancia de la estructura Rect que tiene el largo exacto para contener los dos puntos especificados.

Rect(Point, Size)

Inicializa una nueva instancia de la estructura Rect que tiene la ubicación de la esquina superior izquierda especificada, así como el ancho y alto especificados.

Rect(Point, Vector)

Inicializa una nueva instancia de la estructura Rect que tiene el largo exacto para contener el punto especificado, la suma del punto y el vector especificados.

Rect(Double, Double, Double, Double)

Inicializa una nueva instancia de la estructura Rect que tiene las coordenadas X e Y especificadas, así como el ancho y alto especificados.

Rect(Size)

Inicializa una nueva instancia de la estructura Rect que tiene el tamaño especificado y se ubica en (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)

Parámetros

size
Size

Estructura Size que especifica el ancho y el alto del rectángulo.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una nueva Rect estructura mediante el Rect(Size) constructor .

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

Se aplica a

Rect(Point, Point)

Inicializa una nueva instancia de la estructura Rect que tiene el largo exacto para contener los dos puntos especificados.

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)

Parámetros

point1
Point

Primer punto que debe contener el nuevo rectángulo.

point2
Point

Segundo punto que debe contener el nuevo rectángulo.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una nueva Rect estructura mediante el Rect(Point, Point) constructor .

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

Se aplica a

Rect(Point, Size)

Inicializa una nueva instancia de la estructura Rect que tiene la ubicación de la esquina superior izquierda especificada, así como el ancho y alto especificados.

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)

Parámetros

location
Point

Punto que especifica la ubicación de la esquina superior izquierda del rectángulo.

size
Size

Estructura Size que especifica el ancho y el alto del rectángulo.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una nueva Rect estructura mediante el Rect(Point, Size) constructor .

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

Se aplica a

Rect(Point, Vector)

Inicializa una nueva instancia de la estructura Rect que tiene el largo exacto para contener el punto especificado, la suma del punto y el vector especificados.

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)

Parámetros

point
Point

Primer punto que debe contener el rectángulo.

vector
Vector

Recorrido que se va a desplazar el punto especificado. El rectángulo resultante tendrá el largo exacto para contener ambos puntos.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una nueva Rect estructura mediante el Rect(Point, Vector) constructor .

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

Se aplica a

Rect(Double, Double, Double, Double)

Inicializa una nueva instancia de la estructura Rect que tiene las coordenadas X e Y especificadas, así como el ancho y alto especificados.

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)

Parámetros

x
Double

Coordenada "x" de la esquina superior izquierda del rectángulo.

y
Double

Coordenada Y de la esquina superior izquierda del rectángulo.

width
Double

Ancho del rectángulo.

height
Double

Alto del rectángulo.

Excepciones

width es un valor negativo.

o bien height es un valor negativo.

Comentarios

En el ejemplo siguiente se muestra cómo crear una nueva Rect estructura mediante el Rect(Double, Double, Double, Double) constructor .

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

Se aplica a