Rectangle.Offset Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
A téglalap helyét a megadott mennyiség szerint módosítja.
Túlterhelések
| Name | Description |
|---|---|
| Offset(Point) |
A téglalap helyét a megadott mennyiség szerint módosítja. |
| Offset(Int32, Int32) |
A téglalap helyét a megadott mennyiség szerint módosítja. |
Offset(Point)
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
A téglalap helyét a megadott mennyiség szerint módosítja.
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éterek
- pos
- Point
A hely eltolásának mértéke.
Példák
Az alábbi példakód bemutatja a , és Contains a Offsetmetódusokat és az osztálytSystemPens. Ez a példa egy Windows űrlaphoz készült. Illessze be ezt a kódot egy olyan űrlapba, amely tartalmaz egy gombot, amely az Button1űrlap konstruktorának vagy DrawFirstRectangle metódusának hívását Load tartalmazza, és társítja a Button1_Click metódust a gomb eseményévelClick.
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
Megjegyzések
Ez a módszer a bal felső sarok helyét vízszintesen a megadott pont x koordinátája, függőlegesen pedig a megadott pont y koordinátája alapján állítja be.
A következőre érvényes:
Offset(Int32, Int32)
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
- Forrás:
- Rectangle.cs
A téglalap helyét a megadott mennyiség szerint módosítja.
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éterek
- x
- Int32
A vízszintes eltolás.
- y
- Int32
A függőleges eltolás.