Rect.Offset Método

Definición

Mueve un rectángulo la cantidad especificada.

Sobrecargas

Offset(Vector)

Mueve el rectángulo el vector especificado.

Offset(Double, Double)

Mueve el rectángulo las cantidades horizontal y vertical especificadas.

Offset(Rect, Vector)

Devuelve un rectángulo que se desplaza desde el rectángulo especificado mediante el vector especificado.

Offset(Rect, Double, Double)

Devuelve un rectángulo que se desplaza desde el rectángulo especificado usando las cantidades horizontal y vertical especificadas.

Offset(Vector)

Mueve el rectángulo el vector especificado.

public:
 void Offset(System::Windows::Vector offsetVector);
public void Offset (System.Windows.Vector offsetVector);
member this.Offset : System.Windows.Vector -> unit
Public Sub Offset (offsetVector As Vector)

Parámetros

offsetVector
Vector

Vector que especifica las cantidades horizontal y vertical que se va a mover el rectángulo.

Excepciones

Se llama a este método en el rectángulo de la propiedad Empty.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el Offset(Vector) método para cambiar la posición de un rectángulo.

private Point offsetExample1()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates this rectangle by the specified vector.
    // myRectangle location changed from 10,5 to 30,35.
    myRectangle.Offset(vector1);

    // This rectangle's location changed from 10,5 to 30,35.
    return myRectangle.Location;
}

Comentarios

No se permite llamar a este método en un rectángulo vacío (Rect.Empty).

Tenga en cuenta que llamar al Offset método solo tendrá un efecto si puede cambiar las X propiedades y Y directamente. Dado Rect que es un tipo de valor, si hace referencia a un Rect objeto mediante una propiedad o indexador, se obtiene una copia del objeto, no una referencia al objeto . Si intenta cambiar X o Y en una referencia de propiedad o indexador, se produce un error del compilador. De forma similar, llamar a Offset en la propiedad o indexador no cambiará el objeto subyacente. Si desea cambiar el valor de un Rect objeto al que se hace referencia como una propiedad o indexador, cree un nuevo Rect, modifique sus campos y, a continuación, asigne la Rect devolución a la propiedad o indexador.

Se aplica a

Offset(Double, Double)

Mueve el rectángulo las cantidades horizontal y vertical especificadas.

public:
 void Offset(double offsetX, double offsetY);
public void Offset (double offsetX, double offsetY);
member this.Offset : double * double -> unit
Public Sub Offset (offsetX As Double, offsetY As Double)

Parámetros

offsetX
Double

Cantidad que se va a mover horizontalmente el rectángulo.

offsetY
Double

Cantidad que se va a mover verticalmente el rectángulo.

Excepciones

Se llama a este método en el rectángulo de la propiedad Empty.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el Offset(Double, Double) método para cambiar la posición de un rectángulo.

private Point offsetExample2()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // The Offset method translates this rectangle by the specified horizontal and 
    // vertical amounts. 
    // myRectangle location changed from 10,5 to 30,35.
    myRectangle.Offset(20,30);

    // This rectangle's location changed from 10,5 to 30,35.
    return myRectangle.Location;
}

Comentarios

No se permite llamar a este método en un rectángulo vacío (Rect.Empty).

Tenga en cuenta que llamar al Offset método solo tendrá un efecto si puede cambiar las X propiedades y Y directamente. Dado Rect que es un tipo de valor, si hace referencia a un Rect objeto mediante una propiedad o indexador, se obtiene una copia del objeto, no una referencia al objeto . Si intenta cambiar X o Y en una referencia de propiedad o indexador, se produce un error del compilador. De forma similar, llamar a Offset en la propiedad o indexador no cambiará el objeto subyacente. Si desea cambiar el valor de un Rect objeto al que se hace referencia como una propiedad o indexador, cree un nuevo Rect, modifique sus campos y, a continuación, asigne la Rect devolución a la propiedad o indexador.

Se aplica a

Offset(Rect, Vector)

Devuelve un rectángulo que se desplaza desde el rectángulo especificado mediante el vector especificado.

public:
 static System::Windows::Rect Offset(System::Windows::Rect rect, System::Windows::Vector offsetVector);
public static System.Windows.Rect Offset (System.Windows.Rect rect, System.Windows.Vector offsetVector);
static member Offset : System.Windows.Rect * System.Windows.Vector -> System.Windows.Rect
Public Shared Function Offset (rect As Rect, offsetVector As Vector) As Rect

Parámetros

rect
Rect

Rectángulo original.

offsetVector
Vector

Vector que especifica los desplazamientos horizontal y vertical del nuevo rectángulo.

Devoluciones

Rectángulo resultante.

Excepciones

Ejemplos

En el ejemplo siguiente se muestra cómo usar el Offset(Rect, Vector) método para cambiar la posición de un rectángulo.

private Point offsetExample3()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates the specified rectangle by the specified amount 
    // and returns the resulting Rect. 
    // resultRect location changed from 10,5 to 30,35.
    Rect resultRect = Rect.Offset(myRectangle, vector1);

    // This rectangle's location changed from 10,5 to 30,35.
    return resultRect.Location;
}

Comentarios

No se permite llamar a este método con un rectángulo vacío (Rect.Empty).

Se aplica a

Offset(Rect, Double, Double)

Devuelve un rectángulo que se desplaza desde el rectángulo especificado usando las cantidades horizontal y vertical especificadas.

public:
 static System::Windows::Rect Offset(System::Windows::Rect rect, double offsetX, double offsetY);
public static System.Windows.Rect Offset (System.Windows.Rect rect, double offsetX, double offsetY);
static member Offset : System.Windows.Rect * double * double -> System.Windows.Rect
Public Shared Function Offset (rect As Rect, offsetX As Double, offsetY As Double) As Rect

Parámetros

rect
Rect

Rectángulo que se va a mover.

offsetX
Double

Desplazamiento horizontal del nuevo rectángulo.

offsetY
Double

Desplazamiento vertical del nuevo rectángulo.

Devoluciones

Rectángulo resultante.

Excepciones

Ejemplos

En el ejemplo siguiente se muestra cómo usar el Offset(Rect, Double, Double) método para cambiar la posición de un rectángulo.

private Point offsetExample4()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle.Size = new Size(200, 50);

    // Create a vector to use to offset the position of the rectangle.
    Vector vector1 = new Vector(20, 30);

    // The Offset method translates the specified rectangle by the specified horizontal 
    // and vertical amounts and returns the resulting Rect. 
    // resultRect location changed from 10,5 to 30,35.
    Rect resultRect = Rect.Offset(myRectangle, 20, 30);

    // This rectangle's location changed from 10,5 to 30,35.
    return resultRect.Location;
}

Comentarios

No se permite llamar a este método con un rectángulo vacío (Rect.Empty).

Se aplica a