Rectangle.Offset Méthode

Définition

Ajuste l'emplacement de ce rectangle en fonction de la valeur spécifiée.

Surcharges

Offset(Point)

Ajuste l'emplacement de ce rectangle en fonction de la valeur spécifiée.

Offset(Int32, Int32)

Ajuste l'emplacement de ce rectangle en fonction de la valeur spécifiée.

Offset(Point)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

Ajuste l'emplacement de ce rectangle en fonction de la valeur spécifiée.

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)

Paramètres

pos
Point

Valeur de l'offset de l'emplacement.

Exemples

L’exemple de code suivant illustre les Containsméthodes et et Offset la SystemPens classe . Cet exemple est conçu pour être utilisé avec un Windows Form. Collez ce code dans un formulaire qui contient un bouton nommé Button1, appelez DrawFirstRectangle à partir du constructeur ou Load de la méthode du formulaire, puis associez la Button1_Click méthode à l’événement du Click bouton.

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

Remarques

Cette méthode ajuste horizontalement l’emplacement du coin supérieur gauche par la coordonnée x du point spécifié et verticalement par la coordonnée y du point spécifié.

S’applique à

Offset(Int32, Int32)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

Ajuste l'emplacement de ce rectangle en fonction de la valeur spécifiée.

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)

Paramètres

x
Int32

Offset horizontal.

y
Int32

Offset vertical.

S’applique à