Region.Exclude Méthode

Définition

Met à jour cette Region valeur à la partie de son intérieur qui ne croise pas la structure spécifiée Rectangle .

Surcharges

Nom Description
Exclude(Region)

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas avec le spécifié Region.

Exclude(GraphicsPath)

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas avec le spécifié GraphicsPath.

Exclude(Rectangle)

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas la structure spécifiée Rectangle .

Exclude(RectangleF)

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas la structure spécifiée RectangleF .

Exclude(Region)

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

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas avec le spécifié Region.

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)

Paramètres

region
Region

À Region exclure de ce Region.

Exceptions

region a la valeur null.

Exemples

Pour obtenir des exemples de code, consultez les méthodes et Exclude(RectangleF) les Complement(Region) méthodes.

S’applique à

Exclude(GraphicsPath)

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

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas avec le spécifié GraphicsPath.

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)

Paramètres

path
GraphicsPath

À GraphicsPath exclure de ce Region.

Exceptions

path a la valeur null.

Exemples

L’exemple de code suivant illustre le Region constructeur et les ExcludeDispose méthodes.

Cet exemple est conçu pour être utilisé avec Windows Forms. Collez le code dans un formulaire et appelez la méthode lors de la FillRegionExcludingPath gestion de l’événement du Paint formulaire, en passant e en tant que 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

S’applique à

Exclude(Rectangle)

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

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas la structure spécifiée Rectangle .

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)

Paramètres

rect
Rectangle

Structure Rectangle à exclure de ce Region.

Exemples

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

S’applique à

Exclude(RectangleF)

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

Met à jour ceci Region pour contenir uniquement la partie de son intérieur qui ne croise pas la structure spécifiée RectangleF .

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)

Paramètres

rect
RectangleF

Structure RectangleF à exclure de ce Region.

Exemples

L’exemple suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

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

  • Crée un deuxième rectangle qui se croise avec le premier et le dessine sur l’écran en rouge.

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

  • Obtient la zone non inexclude de la région lorsqu’elle est combinée au deuxième rectangle.

  • Remplit la zone non inexcludeée avec du bleu et la dessine à l’écran.

Notez que la zone de la zone de la région qui ne croise pas le rectangle est colorée en bleu.

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

S’applique à