Region.Union Méthode

Définition

Met à jour cela Region à l’union de lui-même et au spécifié GraphicsPath.

Surcharges

Nom Description
Union(GraphicsPath)

Met à jour cela Region à l’union de lui-même et au spécifié GraphicsPath.

Union(Rectangle)

Met à jour cette Region opération vers l’union de lui-même et la structure spécifiée Rectangle .

Union(RectangleF)

Met à jour cette Region opération vers l’union de lui-même et la structure spécifiée RectangleF .

Union(Region)

Met à jour cela Region à l’union de lui-même et au spécifié Region.

Union(GraphicsPath)

Met à jour cela Region à l’union de lui-même et au spécifié GraphicsPath.

public:
 void Union(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Union(System.Drawing.Drawing2D.GraphicsPath path);
member this.Union : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Union (path As GraphicsPath)

Paramètres

path
GraphicsPath

L’union GraphicsPath avec ce Region.

Exceptions

path a la valeur null.

Exemples

Pour obtenir un exemple de code, consultez les méthodes et Complement(GraphicsPath) les Union(RectangleF) méthodes.

S’applique à

Union(Rectangle)

Met à jour cette Region opération vers l’union de lui-même et la structure spécifiée Rectangle .

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

Paramètres

rect
Rectangle

Structure Rectangle à unir avec ce Region.

Exemples

Pour obtenir un exemple de code, consultez la Union(RectangleF) méthode.

S’applique à

Union(RectangleF)

Met à jour cette Region opération vers l’union de lui-même et la structure spécifiée RectangleF .

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

Paramètres

rect
RectangleF

Structure RectangleF à unir avec ce Region.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse. Le code effectue les actions suivantes :

  • Crée le premier rectangle et le dessine sur l’écran en noir.

  • Crée un deuxième rectangle et le dessine sur l’écran en rouge.

  • Crée une région à l’aide du premier rectangle.

  • Obtient la zone d’union pour myRegion laquelle elle est combinée avec complementRect.

  • Remplit la zone d’union avec du bleu et la dessine à l’écran.

Notez que les deux rectangles sont remplis de bleu, y compris la zone de chevauchement.

void Union_RectF_Example( PaintEventArgs^ e )
{
   // Create the first rectangle and draw it to the screen in black.
   Rectangle regionRect = Rectangle(20,20,100,100);
   e->Graphics->DrawRectangle( Pens::Black, regionRect );

   // create the second rectangle and draw it to the screen in red.
   RectangleF unionRect = RectangleF(90,30,100,100);
   e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( unionRect ) );

   // Create a region using the first rectangle.
   System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

   // Get the area of union for myRegion when combined with
   // complementRect.
   myRegion->Union( unionRect );

   // Fill the union area of myRegion with blue.
   SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
   e->Graphics->FillRegion( myBrush, myRegion );
}
public void Union_RectF_Example(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in black.
    Rectangle regionRect = new Rectangle(20, 20, 100, 100);
    e.Graphics.DrawRectangle(Pens.Black, regionRect);
             
    // create the second rectangle and draw it to the screen in red.
    RectangleF unionRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(unionRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the area of union for myRegion when combined with
             
    // complementRect.
    myRegion.Union(unionRect);
             
    // Fill the union area of myRegion with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Union_RectF_Example(ByVal e As PaintEventArgs)

    ' Create the first rectangle and draw it to the screen in black.
    Dim regionRect As New Rectangle(20, 20, 100, 100)
    e.Graphics.DrawRectangle(Pens.Black, regionRect)

    ' create the second rectangle and draw it to the screen in red.
    Dim unionRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(unionRect))

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the area of union for myRegion when combined with
    ' complementRect.
    myRegion.Union(unionRect)

    ' Fill the intersection area of myRegion with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

S’applique à

Union(Region)

Met à jour cela Region à l’union de lui-même et au spécifié Region.

public:
 void Union(System::Drawing::Region ^ region);
public void Union(System.Drawing.Region region);
member this.Union : System.Drawing.Region -> unit
Public Sub Union (region As Region)

Paramètres

region
Region

L’union Region avec ce Region.

Exceptions

region a la valeur null.

Exemples

Pour obtenir un exemple de code, consultez la méthode et Complement(GraphicsPath) la Union(RectangleF) méthode.

S’applique à