Rectangle.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.
Ajusta a localização deste retângulo pela quantidade especificada.
Sobrecargas
| Name | Description |
|---|---|
| Offset(Point) |
Ajusta a localização deste retângulo pela quantidade especificada. |
| Offset(Int32, Int32) |
Ajusta a localização deste retângulo pela quantidade especificada. |
Offset(Point)
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
Ajusta a localização deste retângulo pela quantidade especificada.
public:
void Offset(System::Drawing::Point pos);
public void Offset(System.Drawing.Point pos);
member this.Offset : System.Drawing.Point -> unit
Public Sub Offset (pos As Point)
Parâmetros
- pos
- Point
Montante para compensar a localização.
Exemplos
O seguinte exemplo de código demonstra os Containsmétodos , e Offset e a SystemPens classe. Este exemplo foi concebido para uso com um Windows Form. Cole este código num formulário que contenha um botão chamado Button1, chamada DrawFirstRectangle do construtor ou Load método do formulário, e associe o Button1_Click método ao evento do Click botão.
private:
[UIPermission(SecurityAction::Demand, Window=UIPermissionWindow::AllWindows)]
void DrawFirstRectangle()
{
Rectangle rectangle1 = Rectangle(70,70,100,150);
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
}
void Button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
Rectangle rectangle1 = Rectangle(70,70,100,150);
// Get the bounds of the screen.
Rectangle screenRectangle = Screen::PrimaryScreen->Bounds;
// Check to see if the rectangle is within the bounds of the screen.
if ( screenRectangle.Contains( rectangle1 ) )
{
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
// Call the Offset method to move the rectangle.
rectangle1.Offset( 20, 20 );
// Draw the new, offset rectangle.
ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
}
}
Rectangle rectangle1 = new Rectangle(70, 70, 100, 150);
private void DrawFirstRectangle()
{
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
}
private void Button1_Click(object sender, EventArgs e)
{
// Get the bounds of the screen.
Rectangle screenRectangle = Screen.PrimaryScreen.Bounds;
// Check to see if the rectangle is within the bounds of the screen.
if (screenRectangle.Contains(rectangle1))
// If so, erase the previous rectangle.
{
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
// Call the Offset method to move the rectangle.
rectangle1.Offset(20, 20);
// Draw the new, offset rectangle.
ControlPaint.DrawReversibleFrame(rectangle1,
SystemColors.Highlight, FrameStyle.Thick);
}
}
Dim rectangle1 As New Rectangle(70, 70, 100, 150)
Private Sub DrawFirstRectangle()
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles Button1.Click
' Get the bounds of the screen.
Dim screenRectangle As Rectangle = Screen.PrimaryScreen.Bounds
' Check to see if the rectangle is within the bounds of the screen.
If (screenRectangle.Contains(rectangle1)) Then
' If so, erase the previous rectangle.
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
' Call the Offset method to move the rectangle.
rectangle1.Offset(20, 20)
' Draw the new, offset rectangle.
ControlPaint.DrawReversibleFrame(rectangle1, _
SystemColors.Highlight, FrameStyle.Thick)
End If
End Sub
Observações
Este método ajusta a localização do canto superior esquerdo horizontalmente pela coordenada x do ponto especificado, e verticalmente pela coordenada y do ponto especificado.
Aplica-se a
Offset(Int32, Int32)
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
Ajusta a localização deste retângulo pela quantidade especificada.
public:
void Offset(int x, int y);
public void Offset(int x, int y);
member this.Offset : int * int -> unit
Public Sub Offset (x As Integer, y As Integer)
Parâmetros
- x
- Int32
O deslocamento horizontal.
- y
- Int32
O deslocamento vertical.