Rectangle.Contains Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Belirtilen noktanın bu Rectangletarafından tanımlanan dikdörtgen bölgede yer alan olup olmadığını belirler.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| Contains(Point) |
Belirtilen noktanın bu Rectangle yapı içinde yer alan olup olmadığını belirler. |
| Contains(Rectangle) |
tarafından |
| Contains(Int32, Int32) |
Belirtilen noktanın bu Rectangle yapı içinde yer alan olup olmadığını belirler. |
Contains(Point)
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
Belirtilen noktanın bu Rectangle yapı içinde yer alan olup olmadığını belirler.
public:
bool Contains(System::Drawing::Point pt);
public readonly bool Contains(System.Drawing.Point pt);
public bool Contains(System.Drawing.Point pt);
member this.Contains : System.Drawing.Point -> bool
Public Function Contains (pt As Point) As Boolean
Parametreler
Döndürülenler
Bu yöntem, tarafından true temsil edilen nokta bu pt yapı içinde yer alırsa döndürürRectangle; aksi takdirde false.
Açıklamalar
Bu yöntemin doğru sonuçlar döndürmesi için içeren dikdörtgenin normalleştirilmesi gerekir.
Şunlara uygulanır
Contains(Rectangle)
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
tarafından rect temsil edilen dikdörtgen bölgenin tamamen bu Rectangle yapı içinde yer alan olup olmadığını belirler.
public:
bool Contains(System::Drawing::Rectangle rect);
public readonly bool Contains(System.Drawing.Rectangle rect);
public bool Contains(System.Drawing.Rectangle rect);
member this.Contains : System.Drawing.Rectangle -> bool
Public Function Contains (rect As Rectangle) As Boolean
Parametreler
Döndürülenler
Bu yöntem, tarafından true temsil edilen dikdörtgen bölge tamamen bu rect yapı içinde yer alırsa döndürürRectangle; aksi takdirde false.
Örnekler
Aşağıdaki kod örneği, yöntemini ve sınıfını Contains 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öntemin doğru sonuçlar döndürmesi için içeren dikdörtgenin normalleştirilmesi gerekir.
Şunlara uygulanır
Contains(Int32, Int32)
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
- Kaynak:
- Rectangle.cs
Belirtilen noktanın bu Rectangle yapı içinde yer alan olup olmadığını belirler.
public:
bool Contains(int x, int y);
public readonly bool Contains(int x, int y);
public bool Contains(int x, int y);
member this.Contains : int * int -> bool
Public Function Contains (x As Integer, y As Integer) As Boolean
Parametreler
- x
- Int32
Test için noktanın x koordinatı.
- y
- Int32
Test için noktanın y koordinatı.
Döndürülenler
Bu yöntem tarafından true tanımlanan nokta ve x bu y yapı içinde yer alırsa döndürürRectangle; aksi takdirdefalse.
Açıklamalar
Bu yöntemin doğru sonuçlar döndürmesi için içeren dikdörtgenin normalleştirilmesi gerekir.