Rectangle.Contains Metoda

Definice

Určuje, zda je zadaný bod obsažen v obdélníkové oblasti definované tímto Rectangleobjektem .

Přetížení

Contains(Point)

Určuje, zda je zadaný bod obsažen v této Rectangle struktuře.

Contains(Rectangle)

Určuje, zda je obdélníková oblast reprezentovaná rect objektem zcela obsažena v této Rectangle struktuře.

Contains(Int32, Int32)

Určuje, zda je zadaný bod obsažen v této Rectangle struktuře.

Contains(Point)

Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs

Určuje, zda je zadaný bod obsažen v této Rectangle struktuře.

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

Parametry

pt
Point

Test Point .

Návraty

Tato metoda vrátí true , pokud je bod reprezentovaný pt hodnotou obsažen v této Rectangle struktuře; jinak false.

Poznámky

Obsahující obdélník musí být normalizován, aby tato metoda vrátila přesné výsledky.

Platí pro

Contains(Rectangle)

Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs

Určuje, zda je obdélníková oblast reprezentovaná rect objektem zcela obsažena v této Rectangle struktuře.

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

Parametry

rect
Rectangle

Test Rectangle .

Návraty

Tato metoda vrátí true , pokud je obdélníková oblast reprezentovaná objektem rect zcela obsažena v této Rectangle struktuře; jinak false.

Příklady

Následující příklad kódu ukazuje metodu Contains a SystemPens třídu . Tento příklad je určený pro použití s formulářem Windows Form. Vložte tento kód do formuláře, který obsahuje tlačítko s názvem Button1, zavolejte DrawFirstRectangle z konstruktoru nebo Load metody formuláře a přidružte metodu Button1_Click k události tlačítka Click .

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

Poznámky

Obsahující obdélník musí být normalizován, aby tato metoda vrátila přesné výsledky.

Platí pro

Contains(Int32, Int32)

Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs

Určuje, zda je zadaný bod obsažen v této Rectangle struktuře.

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

Parametry

x
Int32

Souřadnice x bodu, který se má testovat.

y
Int32

Souřadnice y bodu, který se má testovat.

Návraty

Tato metoda vrátí true , pokud bod definovaný a xy je obsažen v této Rectangle struktuře; jinak false.

Poznámky

Obsahující obdélník musí být normalizován, aby tato metoda vrátila přesné výsledky.

Platí pro