Freigeben über


Rectangle.Union-Methode

Ruft eine Rectangle-Struktur ab, die die Gesamtmenge zweier Rectangle-Strukturen enthält.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Shared Function Union ( _
    a As Rectangle, _
    b As Rectangle _
) As Rectangle
'Usage
Dim a As Rectangle
Dim b As Rectangle
Dim returnValue As Rectangle

returnValue = Rectangle.Union(a, b)
public static Rectangle Union (
    Rectangle a,
    Rectangle b
)
public:
static Rectangle Union (
    Rectangle a, 
    Rectangle b
)
public static Rectangle Union (
    Rectangle a, 
    Rectangle b
)
public static function Union (
    a : Rectangle, 
    b : Rectangle
) : Rectangle

Parameter

  • a
    Ein Rechteck, mit dem die Gesamtmenge gebildet werden soll.
  • b
    Ein Rechteck, mit dem die Gesamtmenge gebildet werden soll.

Rückgabewert

Eine Rectangle-Struktur, die die Gesamtmenge der beiden Rectangle-Strukturen bindet.

Beispiel

Im folgenden Codebeispiel wird die Verwendung der Union-Methode veranschaulicht. Dieses Beispiel ist für die Verwendung mit einem Windows Form vorgesehen. Fügen Sie diesen Code in ein Formular ein, und rufen Sie beim Behandeln des Paint-Ereignisses des Formulars die ShowRectangleUnion-Methode auf, wobei Sie e als PaintEventArgs übergeben.

Private Sub ShowRectangleUnion(ByVal e As PaintEventArgs)

    ' Declare two rectangles and draw them.
    Dim rectangle1 As New Rectangle(30, 40, 50, 100)
    Dim rectangle2 As New Rectangle(50, 60, 100, 60)
    e.Graphics.DrawRectangle(Pens.Sienna, rectangle1)
    e.Graphics.DrawRectangle(Pens.BlueViolet, rectangle2)

    ' Declare a third rectangle as a union of the first two.
    Dim rectangle3 As Rectangle = Rectangle.Union(rectangle1, _
        rectangle2)

    ' Fill in the third rectangle in a semi-transparent color.
    Dim transparentColor As Color = Color.FromArgb(40, 135, 135, 255)
    e.Graphics.FillRectangle(New SolidBrush(transparentColor), _
        rectangle3)
End Sub
private void ShowRectangleUnion(PaintEventArgs e)
{

    // Declare two rectangles and draw them.
    Rectangle rectangle1 = new Rectangle(30, 40, 50, 100);
    Rectangle rectangle2 = new Rectangle(50, 60, 100, 60);
    e.Graphics.DrawRectangle(Pens.Sienna, rectangle1);
    e.Graphics.DrawRectangle(Pens.BlueViolet, rectangle2);

    // Declare a third rectangle as a union of the first two.
    Rectangle rectangle3 = Rectangle.Union(rectangle1, rectangle2);

    // Fill in the third rectangle in a semi-transparent color.
    Color transparentColor = Color.FromArgb(40, 135, 135, 255);
    e.Graphics.FillRectangle(new SolidBrush(transparentColor), rectangle3);
}
private:
   void ShowRectangleUnion( PaintEventArgs^ e )
   {
      // Declare two rectangles and draw them.
      Rectangle rectangle1 = Rectangle(30,40,50,100);
      Rectangle rectangle2 = Rectangle(50,60,100,60);
      e->Graphics->DrawRectangle( Pens::Sienna, rectangle1 );
      e->Graphics->DrawRectangle( Pens::BlueViolet, rectangle2 );

      // Declare a third rectangle as a union of the first two.
      Rectangle rectangle3 = Rectangle::Union( rectangle1, rectangle2 );

      // Fill in the third rectangle in a semi-transparent color.
      Color transparentColor = Color::FromArgb( 40, 135, 135, 255 );
      e->Graphics->FillRectangle( gcnew SolidBrush( transparentColor ), rectangle3 );
   }

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Rectangle-Struktur
Rectangle-Member
System.Drawing-Namespace