Partager via


Region.Complement Méthode

Définition

Met à jour cette Region à la partie de la structure RectangleF spécifiée qui ne croise pas cette Region.

Surcharges

Complement(Region)

Met à jour cette Region pour contenir la partie du Region spécifié qui ne croise pas cette Region.

Complement(RectangleF)

Met à jour cette Region pour contenir la partie de la structure de RectangleF spécifiée qui ne croise pas cette Region.

Complement(GraphicsPath)

Met à jour cette Region pour contenir la partie du GraphicsPath spécifié qui ne croise pas cette Region.

Complement(Rectangle)

Met à jour cette Region pour contenir la partie de la structure de Rectangle spécifiée qui ne croise pas cette Region.

Complement(Region)

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

Met à jour cette Region pour contenir la partie du Region spécifié qui ne croise pas cette 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)

Paramètres

region
Region

Objet Region pour compléter cet objet Region.

Exceptions

region est null.

Exemples

L’exemple suivant est conçu pour une utilisation avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. 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 et crée une deuxième région à l’aide du deuxième rectangle.

  • Obtient le complément de cette première région lorsqu’elle est combinée à la deuxième région.

  • Remplit la zone de complément avec du bleu et le dessine à l’écran.

Notez que la zone de la deuxième région qui ne croise pas la première région est colorée en bleu.

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

S’applique à

Complement(RectangleF)

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

Met à jour cette Region pour contenir la partie de la structure de RectangleF spécifiée qui ne croise pas cette 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)

Paramètres

rect
RectangleF

Structure RectangleF pour compléter cette Region.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. 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 le complément de cette région combiné au deuxième rectangle.

  • Remplit la zone de complément avec du bleu et le dessine à l’écran.

Notez que la zone du deuxième rectangle qui ne croise pas la région est colorée en bleu.

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

S’applique à

Complement(GraphicsPath)

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

Met à jour cette Region pour contenir la partie du GraphicsPath spécifié qui ne croise pas cette 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)

Paramètres

path
GraphicsPath

La GraphicsPath pour compléter cette Region.

Exceptions

path est null.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. 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.

  • Crée un GraphicsPathet ajoute le deuxième rectangle à celui-ci.

  • Obtient le complément de la région lorsqu’elle est combinée à la GraphicsPath.

  • Remplit la zone de complément avec du bleu et le dessine à l’écran.

Notez que la zone du GraphicsPath qui ne croise pas la région est colorée en bleu.

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

S’applique à

Complement(Rectangle)

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

Met à jour cette Region pour contenir la partie de la structure de Rectangle spécifiée qui ne croise pas cette 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)

Paramètres

rect
Rectangle

Structure Rectangle pour compléter cette Region.

Exemples

Pour obtenir un exemple, consultez la méthode Complement(RectangleF).

S’applique à