Rectangle.Offset Yöntem

Tanım

Bu dikdörtgenin konumunu belirtilen miktara göre ayarlar.

Aşırı Yüklemeler

Name Description
Offset(Point)

Bu dikdörtgenin konumunu belirtilen miktara göre ayarlar.

Offset(Int32, Int32)

Bu dikdörtgenin konumunu belirtilen miktara göre ayarlar.

Offset(Point)

Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs

Bu dikdörtgenin konumunu belirtilen miktara göre ayarlar.

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)

Parametreler

pos
Point

Konumun uzaklığı için tutar.

Örnekler

Aşağıdaki kod örneği, ve yöntemlerini ve Contains sınıfını Offset gösterirSystemPens. Bu örnek, Windows Formu ile kullanılmak üzere tasarlanmıştır. Bu kodu, adlı Button1bir düğme içeren bir forma yapıştırın, formun oluşturucusundan veya DrawFirstRectangle yönteminden çağırın Load ve yöntemini düğmenin Button1_Click olayıyla ilişkilendirinClick.

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

Açıklamalar

Bu yöntem, sol üst köşenin konumunu belirtilen noktanın x koordinatı ile yatay olarak ve dikey olarak belirtilen noktanın y koordinatı ile ayarlar.

Şunlara uygulanır

Offset(Int32, Int32)

Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs
Kaynak:
Rectangle.cs

Bu dikdörtgenin konumunu belirtilen miktara göre ayarlar.

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)

Parametreler

x
Int32

Yatay uzaklık.

y
Int32

Dikey uzaklık.

Şunlara uygulanır