Region.Exclude Método

Definición

Actualiza esta Region a la parte de su interior que no forma una intersección con la estructura Rectangle especificada.

Sobrecargas

Exclude(Region)

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con el Region especificado.

Exclude(GraphicsPath)

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con el GraphicsPath especificado.

Exclude(Rectangle)

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con la estructura Rectangle especificada.

Exclude(RectangleF)

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con la estructura RectangleF especificada.

Exclude(Region)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con el 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

Region que se va a excluir de esta Region.

Excepciones

region es null.

Ejemplos

Para obtener ejemplos de código, consulte los Exclude(RectangleF) métodos y Complement(Region) .

Se aplica a

Exclude(GraphicsPath)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con el 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

GraphicsPath que se va a excluir de esta Region.

Excepciones

path es null.

Ejemplos

En el ejemplo de código siguiente se muestra el Region constructor y los Exclude métodos y Dispose .

Este ejemplo está diseñado para usarse con Windows Forms. Pegue el código en un formulario y llame al FillRegionExcludingPath método al controlar el evento del Paint formulario, pasando 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

Se aplica a

Exclude(Rectangle)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con la estructura 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

Estructura Rectangle que se va a excluir de esta Region.

Ejemplos

Para obtener un ejemplo de código, vea el Exclude(RectangleF) método .

Se aplica a

Exclude(RectangleF)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

Actualiza esta Region para que contenga solo la parte de su interior que no forma una intersección con la estructura 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

Estructura RectangleF que se va a excluir de esta Region.

Ejemplos

El ejemplo siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza las siguientes acciones:

  • Crea un rectángulo y lo dibuja en la pantalla en negro

  • Crea un segundo rectángulo que interseca con el primero y lo dibuja en la pantalla en rojo.

  • Crea una región con el primer rectángulo.

  • Obtiene el área no aislada de la región cuando se combina con el segundo rectángulo.

  • Rellena el área no aislada con azul y la dibuja en la pantalla.

Observe que el área del área de la región que no forma intersección con el rectángulo está coloreado en azul.

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

Se aplica a