Region.Exclude Método

Definição

Atualiza este Region para a parte do seu interior que não faz interseção com a estrutura Rectangle especificada.

Sobrecargas

Exclude(Region)

Atualiza essa Region para conter apenas a parte do seu interior que não faz interseção com o Region especificado.

Exclude(GraphicsPath)

Atualiza essa Region para conter apenas a parte do seu interior que não faz interseção com o GraphicsPath especificado.

Exclude(Rectangle)

Atualiza este Region para conter apenas a parte do seu interior que não faz interseção com o Rectangle especificada.

Exclude(RectangleF)

Atualiza este Region para conter apenas a parte do seu interior que não faz interseção com o RectangleF especificada.

Exclude(Region)

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

Atualiza essa Region para conter apenas a parte do seu interior que não faz interseção com o Region especificado.

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

Parâmetros

region
Region

O Region a excluir deste Region.

Exceções

region é null.

Exemplos

Para obter exemplos de código, consulte os Exclude(RectangleF) métodos e Complement(Region) .

Aplica-se a

Exclude(GraphicsPath)

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

Atualiza essa Region para conter apenas a parte do seu interior que não faz interseção com o GraphicsPath especificado.

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

Parâmetros

path
GraphicsPath

O GraphicsPath a excluir deste Region.

Exceções

path é null.

Exemplos

O exemplo de código a seguir demonstra o Region construtor e os Exclude métodos e Dispose .

Este exemplo foi projetado para ser usado com Windows Forms. Cole o código em um formulário e chame o FillRegionExcludingPath método ao manipular o evento do Paint formulário, passando e como PaintEventArgs.

private:
   void FillRegionExcludingPath( PaintEventArgs^ e )
   {
      // Create the region using a rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( Rectangle(20,20,100,100) );

      // Create the GraphicsPath.
      System::Drawing::Drawing2D::GraphicsPath^ path = gcnew System::Drawing::Drawing2D::GraphicsPath;

      // Add a circle to the graphics path.
      path->AddEllipse( 50, 50, 25, 25 );

      // Exclude the circle from the region.
      myRegion->Exclude( path );

      // Retrieve a Graphics object from the form.
      Graphics^ formGraphics = e->Graphics;

      // Fill the region in blue.
      formGraphics->FillRegion( Brushes::Blue, myRegion );

      // Dispose of the path and region objects.
      delete path;
      delete myRegion;
   }
private void FillRegionExcludingPath(PaintEventArgs e)
{

    // Create the region using a rectangle.
    Region myRegion = new Region(new Rectangle(20, 20, 100, 100));

    // Create the GraphicsPath.
    System.Drawing.Drawing2D.GraphicsPath path = 
        new System.Drawing.Drawing2D.GraphicsPath();

    // Add a circle to the graphics path.
    path.AddEllipse(50, 50, 25, 25);

    // Exclude the circle from the region.
    myRegion.Exclude(path);

    // Retrieve a Graphics object from the form.
    Graphics formGraphics = e.Graphics;

    // Fill the region in blue.
    formGraphics.FillRegion(Brushes.Blue, myRegion);

    // Dispose of the path and region objects.
    path.Dispose();
    myRegion.Dispose();
}
Private Sub FillRegionExcludingPath(ByVal e As PaintEventArgs)

    ' Create the region using a rectangle.
    Dim myRegion As New Region(New Rectangle(20, 20, 100, 100))

    ' Create the GraphicsPath.
    Dim path As New System.Drawing.Drawing2D.GraphicsPath

    ' Add a circle to the graphics path.
    path.AddEllipse(50, 50, 25, 25)

    ' Exclude the circle from the region.
    myRegion.Exclude(path)

    ' Retrieve a Graphics object from the form.
    Dim formGraphics As Graphics = e.Graphics

    ' Fill the region in blue.
    formGraphics.FillRegion(Brushes.Blue, myRegion)

    ' Dispose of the path and region objects.
    path.Dispose()
    myRegion.Dispose()

End Sub

Aplica-se a

Exclude(Rectangle)

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

Atualiza este Region para conter apenas a parte do seu interior que não faz interseção com o Rectangle especificada.

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

Parâmetros

rect
Rectangle

A estrutura Rectangle a ser excluída deste Region.

Exemplos

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

Aplica-se a

Exclude(RectangleF)

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

Atualiza este Region para conter apenas a parte do seu interior que não faz interseção com o RectangleF especificada.

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

Parâmetros

rect
RectangleF

A estrutura RectangleF a ser excluída deste Region.

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 para a tela em preto

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

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

  • Obtém a área inexcluída da região quando combinada com o segundo retângulo.

  • Preenche a área inexcluída com azul e a desenha para a tela.

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

public:
   void Exclude_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 nonexcluded area of myRegion when combined with
      // complementRect.
      myRegion->Exclude( complementRect );
      
      // Fill the nonexcluded area of myRegion with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Exclude_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 nonexcluded area of myRegion when combined with
             
    // complementRect.
    myRegion.Exclude(complementRect);
             
    // Fill the nonexcluded area of myRegion with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Exclude_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 nonexcluded area of myRegion when combined with
    ' complementRect.
    myRegion.Exclude(complementRect)

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

Aplica-se a