Region.Complement Método

Definição

Atualiza este Region para a parte da estrutura RectangleF especificada que não faz intersecção com este Region.

Sobrecargas

Complement(Region)

Atualiza este Region para conter a parte do Region especificado que não se intersecciona com este Region.

Complement(RectangleF)

Atualiza este Region para conter a parte da estrutura RectangleF especificada que não faz intersecção com este Region.

Complement(GraphicsPath)

Atualiza este Region para conter a parte do GraphicsPath especificado que não se intersecciona com este Region.

Complement(Rectangle)

Atualiza este Region para conter a parte da estrutura Rectangle especificada que não faz intersecção com este Region.

Complement(Region)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Atualiza este Region para conter a parte do Region especificado que não se intersecciona com este Region.

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

Parâmetros

region
Region

O objeto Region complementa este objeto Region.

Exceções

region é null.

Exemplos

O exemplo a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, que é um parâmetro do Paint manipulador de eventos. O código executa as seguintes ações:

  • Cria um retângulo e o desenha na tela em preto

  • Cria um segundo retângulo que se cruza com o primeiro e o desenha na tela em vermelho.

  • Cria uma região usando o primeiro retângulo e cria uma segunda região usando o segundo retângulo.

  • Obtém o complemento dessa primeira região quando combinado com a segunda região.

  • Preenche a área de complemento com azul e a desenha na tela.

Observe que a área da segunda região que não se cruza com a primeira região é azul colorida.

public:
   void Complement_Region_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.
      Rectangle complementRect = Rectangle(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, complementRect );

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

      // Create a complement region.
      System::Drawing::Region^ complementRegion = gcnew System::Drawing::Region( complementRect );

      // Get the complement of myRegion when combined with
      // complementRegion.
      myRegion->Complement( complementRegion );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_Region_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.
    Rectangle complementRect = new Rectangle(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red, complementRect);
             
    // Create a region from the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Create a complement region.
    Region complementRegion = new Region(complementRect);
             
    // Get the complement of myRegion when combined with
             
    // complementRegion.
    myRegion.Complement(complementRegion);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_Region_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 complementRect As New Rectangle(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, complementRect)

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

    ' Create a complement region.
    Dim complementRegion As New [Region](complementRect)

    ' Get the complement of myRegion when combined with
    ' complementRegion.
    myRegion.Complement(complementRegion)

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

Aplica-se a

Complement(RectangleF)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Atualiza este Region para conter a parte da estrutura RectangleF especificada que não faz intersecção com este Region.

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

Parâmetros

rect
RectangleF

A estrutura RectangleF para complementar este Region.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, que é um parâmetro do Paint manipulador de eventos. O código executa as seguintes ações:

  • Cria um retângulo e o desenha na tela em preto.

  • Cria um segundo retângulo que se cruza com o primeiro e o desenha na tela em vermelho.

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

  • Obtém o complemento dessa região combinado com o segundo retângulo.

  • Preenche a área de complemento com azul e a desenha na tela.

Observe que a área do segundo retângulo que não se cruza com a região é azul colorida.

public:
   void Complement_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 complementRect = RectangleF(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) );

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

      // Get the complement of the region combined with the second
      // rectangle.
      myRegion->Complement( complementRect );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_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 complementRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(complementRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the complement of the region combined with the second
             
    // rectangle.
    myRegion.Complement(complementRect);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_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 complementRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, _
    Rectangle.Round(complementRect))

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

    ' Get the complement of the region combined with the second
    ' rectangle.
    myRegion.Complement(complementRect)

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

Aplica-se a

Complement(GraphicsPath)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Atualiza este Region para conter a parte do GraphicsPath especificado que não se intersecciona com este Region.

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

Parâmetros

path
GraphicsPath

O GraphicsPath para complementar este Region.

Exceções

path é null.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, que é um parâmetro do Paint manipulador de eventos. O código executa as seguintes ações:

  • Cria um retângulo e o desenha na tela em preto.

  • Cria um segundo retângulo que se cruza com o primeiro e o desenha na tela em vermelho.

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

  • Cria um GraphicsPathe adiciona o segundo retângulo a ele.

  • Obtém o complemento da região quando combinado com o GraphicsPath.

  • Preenche a área de complemento com azul e a desenha na tela.

Observe que a área do GraphicsPath que não se cruza com a região é azul colorida.

public:
   void Complement_Path_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.
      Rectangle complementRect = Rectangle(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, complementRect );

      // Create a graphics path and add the second rectangle to it.
      GraphicsPath^ complementPath = gcnew GraphicsPath;
      complementPath->AddRectangle( complementRect );

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

      // Get the complement of myRegion when combined with
      // complementPath.
      myRegion->Complement( complementPath );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_Path_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.
    Rectangle complementRect = new Rectangle(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red, complementRect);
             
    // Create a graphics path and add the second rectangle to it.
    GraphicsPath complementPath = new GraphicsPath();
    complementPath.AddRectangle(complementRect);
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the complement of myRegion when combined with
             
    // complementPath.
    myRegion.Complement(complementPath);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_Path_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 complementRect As New Rectangle(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, complementRect)

    ' Create a graphics path and add the second rectangle to it.
    Dim complementPath As New GraphicsPath
    complementPath.AddRectangle(complementRect)

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

    ' Get the complement of myRegion when combined with
    ' complementPath.
    myRegion.Complement(complementPath)

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

Aplica-se a

Complement(Rectangle)

Origem:
Region.cs
Origem:
Region.cs
Origem:
Region.cs

Atualiza este Region para conter a parte da estrutura Rectangle especificada que não faz intersecção com este Region.

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

Parâmetros

rect
Rectangle

A estrutura Rectangle para complementar este Region.

Exemplos

Para obter um exemplo, consulte o Complement(RectangleF) método .

Aplica-se a