RectangleF.Intersect Metodo

Definizione

Determina la struttura RectangleF che rappresenta l'intersezione di due rettangoli.

Overload

Intersect(RectangleF)

Sostituisce la struttura RectangleF con la sua intersezione e con la struttura RectangleF specificata.

Intersect(RectangleF, RectangleF)

Restituisce una struttura RectangleF che rappresenta l'intersezione di due rettangoli. Se non è presente alcuna intersezione, verrà restituita una struttura RectangleF vuota.

Intersect(RectangleF)

Sostituisce la struttura RectangleF con la sua intersezione e con la struttura RectangleF specificata.

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

Parametri

rect
RectangleF

Rettangolo da intersecare.

Si applica a

Intersect(RectangleF, RectangleF)

Restituisce una struttura RectangleF che rappresenta l'intersezione di due rettangoli. Se non è presente alcuna intersezione, verrà restituita una struttura RectangleF vuota.

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

Parametri

a
RectangleF

Rettangolo da intersecare.

b
RectangleF

Rettangolo da intersecare.

Restituisce

RectangleF

Terza struttura RectangleF la cui dimensione rappresenta l'area sovrapposta dei due rettangoli specificati.

Esempio

Questo esempio è progettato per l'uso con Windows Forms e richiede PaintEventArgs e, un OnPaint oggetto evento. Il codice crea due RectangleF oggetti e li disegna sullo schermo in nero e rosso. Si noti che devono essere convertiti in Rectangle oggetti a scopo di disegno. Il codice crea quindi un terzo RectangleF usando il Intersect metodo, lo converte in un Rectangleoggetto e lo disegna sullo schermo in blu. Si noti che il terzo rettangolo (blu) è l'area di sovrapposizione degli altri due rettangoli:

public:
   void RectangleFIntersectExample( PaintEventArgs^ e )
   {
      // Create two rectangles.
      RectangleF firstRectangleF = RectangleF(0,0,75,50);
      RectangleF secondRectangleF = RectangleF(50,20,50,50);

      // Convert the RectangleF structures to Rectangle structures and draw them to the
      // screen.
      Rectangle firstRect = Rectangle::Truncate( firstRectangleF );
      Rectangle secondRect = Rectangle::Truncate( secondRectangleF );
      e->Graphics->DrawRectangle( Pens::Black, firstRect );
      e->Graphics->DrawRectangle( Pens::Red, secondRect );

      // Get the intersection.
      RectangleF intersectRectangleF = RectangleF::Intersect( firstRectangleF, secondRectangleF );

      // Draw the intersectRectangleF to the screen.
      Rectangle intersectRect = Rectangle::Truncate( intersectRectangleF );
      e->Graphics->DrawRectangle( Pens::Blue, intersectRect );
   }
public void RectangleFIntersectExample(PaintEventArgs e)
{
             
    // Create two rectangles.
    RectangleF firstRectangleF = new RectangleF(0, 0, 75, 50);
    RectangleF secondRectangleF = new RectangleF(50, 20, 50, 50);
             
    // Convert the RectangleF structures to Rectangle structures and draw them to the
             
    // screen.
    Rectangle firstRect = Rectangle.Truncate(firstRectangleF);
    Rectangle secondRect = Rectangle.Truncate(secondRectangleF);
    e.Graphics.DrawRectangle(Pens.Black, firstRect);
    e.Graphics.DrawRectangle(Pens.Red, secondRect);
             
    // Get the intersection.
    RectangleF intersectRectangleF =
        RectangleF.Intersect(firstRectangleF,
        secondRectangleF);
             
    // Draw the intersectRectangleF to the screen.
    Rectangle intersectRect =
        Rectangle.Truncate(intersectRectangleF);
    e.Graphics.DrawRectangle(Pens.Blue, intersectRect);
}
Public Sub RectangleFIntersectExample(ByVal e As PaintEventArgs)

    ' Create two rectangles.
    Dim firstRectangleF As New RectangleF(0, 0, 75, 50)
    Dim secondRectangleF As New RectangleF(50, 20, 50, 50)

    ' Convert the RectangleF structures to Rectangle structures and

    ' draw them to the screen.
    Dim firstRect As Rectangle = Rectangle.Truncate(firstRectangleF)
    Dim secondRect As Rectangle = Rectangle.Truncate(secondRectangleF)
    e.Graphics.DrawRectangle(Pens.Black, firstRect)
    e.Graphics.DrawRectangle(Pens.Red, secondRect)

    ' Get the intersection.
    Dim intersectRectangleF As RectangleF = _
    RectangleF.Intersect(firstRectangleF, secondRectangleF)

    ' Draw the intersectRectangleF to the screen.
    Dim intersectRect As Rectangle = _
    Rectangle.Truncate(intersectRectangleF)
    e.Graphics.DrawRectangle(Pens.Blue, intersectRect)
End Sub

Si applica a