Region.Union Método

Definição

Atualiza este Region para a união de si mesmo e do GraphicsPath especificado.

Sobrecargas

Union(GraphicsPath)

Atualiza este Region para a união de si mesmo e do GraphicsPath especificado.

Union(Rectangle)

Atualiza este Region para a união de si mesmo e da estrutura Rectangle especificada.

Union(RectangleF)

Atualiza este Region para a união de si mesmo e da estrutura RectangleF especificada.

Union(Region)

Atualiza este Region para a união de si mesmo e do Region especificado.

Union(GraphicsPath)

Atualiza este Region para a união de si mesmo e do GraphicsPath especificado.

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)

Parâmetros

path
GraphicsPath

O GraphicsPath a ser unido a este Region.

Exceções

path é null.

Exemplos

Para obter um exemplo de código, consulte os métodos e Complement(GraphicsPath) os Union(RectangleF) métodos.

Aplica-se a

Union(Rectangle)

Atualiza este Region para a união de si mesmo e da estrutura Rectangle especificada.

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)

Parâmetros

rect
Rectangle

A estrutura Rectangle a ser unida a este Region.

Exemplos

Para obter um exemplo de código, consulte o Union(RectangleF) método.

Aplica-se a

Union(RectangleF)

Atualiza este Region para a união de si mesmo e da estrutura RectangleF especificada.

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)

Parâmetros

rect
RectangleF

A estrutura RectangleF a ser unida a este Region.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgs e. O código executa as seguintes ações:

  • Cria o primeiro retângulo e o desenha para a tela em preto.

  • Cria um segundo retângulo e o desenha para a tela em vermelho.

  • Cria uma região usando o primeiro retângulo.

  • Obtém a área de união para myRegion quando combinado com complementRect.

  • Preenche a área de união com azul e desenha-a para a tela.

Observe que ambos os retângulos são preenchidos com azul, incluindo a área de sobreposição.

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

Aplica-se a

Union(Region)

Atualiza este Region para a união de si mesmo e do Region especificado.

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)

Parâmetros

region
Region

O Region a ser unido a este Region.

Exceções

region é null.

Exemplos

Para obter um exemplo de código, consulte o método e Complement(GraphicsPath) o Union(RectangleF) método.

Aplica-se a