Rect.Offset Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Move um retângulo pela quantidade especificada.
Sobrecargas
| Name | Description |
|---|---|
| Offset(Vector) |
Move o retângulo pelo vetor especificado. |
| Offset(Double, Double) |
Move o retângulo pelas quantidades horizontais e verticais especificadas. |
| Offset(Rect, Vector) |
Devolve um retângulo que está deslocado em relação ao retângulo especificado usando o vetor especificado. |
| Offset(Rect, Double, Double) |
Devolve um retângulo que está deslocado em relação ao rectângulo especificado usando as quantidades horizontais e verticais especificadas. |
Offset(Vector)
Move o retângulo pelo vetor 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
Um vetor que especifica os valores horizontal e vertical para mover o retângulo.
Exceções
Este método chama-se no Empty retângulo.
Exemplos
O exemplo seguinte mostra como usar o Offset(Vector) método para alterar a posição de um retâ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;
}
Observações
Chamar este método num retângulo vazio (Rect.Empty) não é permitido.
Note que chamar o Offset método só terá efeito se conseguir alterar diretamente as X propriedades e Y de . Como Rect é um tipo de valor, se referenciar um Rect objeto usando uma propriedade ou indexador, obtém uma cópia do objeto, não uma referência ao objeto. Se tentar alterar X ou Y numa propriedade ou referência ao indexador, ocorre um erro do compilador. De forma semelhante, chamar Offset a propriedade ou o indexador não altera o objeto subjacente. Se quiser alterar o valor de um Rect que é referenciado como propriedade ou indexador, crie um novo Rect, modifique os seus campos e depois atribua o Rect retrocesso à propriedade ou indexador.
Aplica-se a
Offset(Double, Double)
Move o retângulo pelas quantidades horizontais e verticais 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
A quantidade para mover o retângulo horizontalmente.
- offsetY
- Double
A quantidade para mover o retângulo verticalmente.
Exceções
Este método chama-se no Empty retângulo.
Exemplos
O exemplo seguinte mostra como usar o Offset(Double, Double) método para alterar a posição de um retâ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;
}
Observações
Chamar este método num retângulo vazio (Rect.Empty) não é permitido.
Note que chamar o Offset método só terá efeito se conseguir alterar diretamente as X propriedades e Y de . Como Rect é um tipo de valor, se referenciar um Rect objeto usando uma propriedade ou indexador, obtém uma cópia do objeto, não uma referência ao objeto. Se tentar alterar X ou Y numa propriedade ou referência ao indexador, ocorre um erro do compilador. De forma semelhante, chamar Offset a propriedade ou o indexador não altera o objeto subjacente. Se quiser alterar o valor de um Rect que é referenciado como propriedade ou indexador, crie um novo Rect, modifique os seus campos e depois atribua o Rect retrocesso à propriedade ou indexador.
Aplica-se a
Offset(Rect, Vector)
Devolve um retângulo que está deslocado em relação ao retângulo especificado usando o vetor 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
O retângulo original.
- offsetVector
- Vector
Um vetor que especifica os deslocamentos horizontais e verticais para o novo retângulo.
Devoluções
O retângulo resultante.
Exceções
rect é Empty.
Exemplos
O exemplo seguinte mostra como usar o Offset(Rect, Vector) método para alterar a posição de um retâ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;
}
Observações
Chamar este método com um retângulo vazio (Rect.Empty) não é permitido.
Aplica-se a
Offset(Rect, Double, Double)
Devolve um retângulo que está deslocado em relação ao rectângulo especificado usando as quantidades horizontais e verticais 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
O retângulo para se mover.
- offsetX
- Double
O deslocamento horizontal para o novo retângulo.
- offsetY
- Double
O deslocamento vertical para o novo retângulo.
Devoluções
O retângulo resultante.
Exceções
rect é Empty.
Exemplos
O exemplo seguinte mostra como usar o Offset(Rect, Double, Double) método para alterar a posição de um retâ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;
}
Observações
Chamar este método com um retângulo vazio (Rect.Empty) não é permitido.