Rectangle.IntersectsWith(Rectangle) Yöntem

Tanım

Bu dikdörtgenin ile rectkesişip kesişmediğini belirler.

public:
 bool IntersectsWith(System::Drawing::Rectangle rect);
public readonly bool IntersectsWith (System.Drawing.Rectangle rect);
public bool IntersectsWith (System.Drawing.Rectangle rect);
member this.IntersectsWith : System.Drawing.Rectangle -> bool
Public Function IntersectsWith (rect As Rectangle) As Boolean

Parametreler

rect
Rectangle

Test etmek için dikdörtgen.

Döndürülenler

Bu yöntem herhangi bir kesişim varsa döndürür true , aksi takdirde false.

Örnekler

Aşağıdaki kod örneği, ve IsEmpty üyelerini IntersectsWith gösterirIntersect. Bu örnek bir Windows Formu ile kullanılmalıdır. Bu kodu bir forma yapıştırın ve formun Paint olayını işlerken olarak geçirerek ePaintEventArgsbu yöntemi çağırın.

private:
   void InstanceRectangleIntersection( PaintEventArgs^ e )
   {
      Rectangle rectangle1 = Rectangle(50,50,200,100);
      Rectangle rectangle2 = Rectangle(70,20,100,200);
      e->Graphics->DrawRectangle( Pens::Black, rectangle1 );
      e->Graphics->DrawRectangle( Pens::Red, rectangle2 );
      if ( rectangle1.IntersectsWith( rectangle2 ) )
      {
         rectangle1.Intersect( rectangle2 );
         if (  !rectangle1.IsEmpty )
         {
            e->Graphics->FillRectangle( Brushes::Green, rectangle1 );
         }
      }
   }
private void InstanceRectangleIntersection(PaintEventArgs e)
{

    Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
    Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);

    e.Graphics.DrawRectangle(Pens.Black, rectangle1);
    e.Graphics.DrawRectangle(Pens.Red, rectangle2);

    if (rectangle1.IntersectsWith(rectangle2))
    {
        rectangle1.Intersect(rectangle2);
        if (!rectangle1.IsEmpty)
        {
            e.Graphics.FillRectangle(Brushes.Green, rectangle1);
        }
    }
}
  Private Sub InstanceRectangleIntersection( _
      ByVal e As PaintEventArgs)

      Dim rectangle1 As New Rectangle(50, 50, 200, 100)
      Dim rectangle2 As New Rectangle(70, 20, 100, 200)

      e.Graphics.DrawRectangle(Pens.Black, rectangle1)
      e.Graphics.DrawRectangle(Pens.Red, rectangle2)

      If (rectangle1.IntersectsWith(rectangle2)) Then
          rectangle1.Intersect(rectangle2)
          If Not (rectangle1.IsEmpty) Then
              e.Graphics.FillRectangle(Brushes.Green, rectangle1)
          End If
      End If
  End Sub

Şunlara uygulanır