Rectangle.Intersect Rectangle.Intersect Rectangle.Intersect Rectangle.Intersect Method

Définition

Détermine la structure Rectangle qui représente l'intersection de deux rectangles.Determines the Rectangle structure that represents the intersection of two rectangles.

Surcharges

Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle)

Retourne une troisième structure Rectangle qui représente l'intersection de deux autres structures Rectangle.Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. En l'absence d'intersection, un Rectangle vide est retourné.If there is no intersection, an empty Rectangle is returned.

Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle)

Remplace ce Rectangle par l'intersection entre celui-ci et le Rectangle spécifié.Replaces this Rectangle with the intersection of itself and the specified Rectangle.

Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle)

Retourne une troisième structure Rectangle qui représente l'intersection de deux autres structures Rectangle.Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. En l'absence d'intersection, un Rectangle vide est retourné.If there is no intersection, an empty Rectangle is returned.

public:
 static System::Drawing::Rectangle Intersect(System::Drawing::Rectangle a, System::Drawing::Rectangle b);
public static System.Drawing.Rectangle Intersect (System.Drawing.Rectangle a, System.Drawing.Rectangle b);
static member Intersect : System.Drawing.Rectangle * System.Drawing.Rectangle -> System.Drawing.Rectangle
Public Shared Function Intersect (a As Rectangle, b As Rectangle) As Rectangle

Paramètres

a
Rectangle Rectangle Rectangle Rectangle

Rectangle faisant l'objet d'une intersection.A rectangle to intersect.

b
Rectangle Rectangle Rectangle Rectangle

Rectangle faisant l'objet d'une intersection.A rectangle to intersect.

Retours

Rectangle qui représente l'intersection de a et b.A Rectangle that represents the intersection of a and b.

Exemples

L’exemple de code suivant montre le Intersect, IsEmpty et le IntersectsWith membres.The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. Cet exemple doit être utilisé avec un Windows Form.This example should be used with a Windows Form. Collez ce code dans un formulaire et appelez cette méthode lors du traitement de Paint l’événement du e formulaire PaintEventArgs, en passant comme.Paste this code into a form and call this method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void StaticRectangleIntersection( 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 ) )
      {
         Rectangle rectangle3 = Rectangle::Intersect( rectangle1, rectangle2 );
         if (  !rectangle3.IsEmpty )
         {
            e->Graphics->FillRectangle( Brushes::Green, rectangle3 );
         }
      }
   }
private void StaticRectangleIntersection(PaintEventArgs e)
{
    Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
    Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);
    Rectangle rectangle3 = new Rectangle();

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

    if (rectangle1.IntersectsWith(rectangle2))
    {
        rectangle3 = Rectangle.Intersect(rectangle1, rectangle2);
        if (!rectangle3.IsEmpty)
        {
            e.Graphics.FillRectangle(Brushes.Green, rectangle3);
        }
    }
}
Private Sub StaticRectangleIntersection(ByVal e As PaintEventArgs)
    Dim rectangle1 As New Rectangle(50, 50, 200, 100)
    Dim rectangle2 As New Rectangle(70, 20, 100, 200)
    Dim rectangle3 As New Rectangle

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

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

Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle)

Remplace ce Rectangle par l'intersection entre celui-ci et le Rectangle spécifié.Replaces this Rectangle with the intersection of itself and the specified Rectangle.

public:
 void Intersect(System::Drawing::Rectangle rect);
public void Intersect (System.Drawing.Rectangle rect);
member this.Intersect : System.Drawing.Rectangle -> unit
Public Sub Intersect (rect As Rectangle)

Paramètres

rect
Rectangle Rectangle Rectangle Rectangle

Rectangle avec lequel effectuer l'intersection.The Rectangle with which to intersect.

Exemples

L’exemple de code suivant montre le Intersect, IsEmpty et le IntersectsWith membres.The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. Cet exemple doit être utilisé avec un Windows Form.This example should be used with a Windows Form. Collez ce code dans un formulaire et appelez cette méthode lors du traitement de Paint l’événement du e formulaire PaintEventArgs, en passant comme.Paste this code into a form and call this method when handling the form's Paint event, passing e as PaintEventArgs.

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

S’applique à