Region.Exclude Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Überlädt
Exclude(Region) |
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit dem angegebenen Region bildet. |
Exclude(GraphicsPath) |
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit dem angegebenen GraphicsPath bildet. |
Exclude(Rectangle) |
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit der angegebenen Rectangle-Struktur bildet. |
Exclude(RectangleF) |
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit der angegebenen RectangleF-Struktur bildet. |
Exclude(Region)
- Quelle:
- Region.cs
- Quelle:
- Region.cs
- Quelle:
- Region.cs
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)
Parameter
Ausnahmen
region
ist null
.
Beispiele
Codebeispiele finden Sie in den Exclude(RectangleF) Methoden und Complement(Region) .
Gilt für:
Exclude(GraphicsPath)
- Quelle:
- Region.cs
- Quelle:
- Region.cs
- Quelle:
- Region.cs
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit dem angegebenen GraphicsPath bildet.
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)
Parameter
- path
- GraphicsPath
Der aus dieser GraphicsPath auszuschließende Region.
Ausnahmen
path
ist null
.
Beispiele
Im folgenden Codebeispiel werden der Region Konstruktor und die Exclude Methoden und Dispose veranschaulicht.
Dieses Beispiel ist für die Verwendung mit Windows Forms konzipiert. Fügen Sie den Code in ein Formular ein, und rufen Sie die FillRegionExcludingPath
-Methode auf, wenn Sie das Ereignis des Formulars Paint behandeln, und übergeben Sie e
als 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
Gilt für:
Exclude(Rectangle)
- Quelle:
- Region.cs
- Quelle:
- Region.cs
- Quelle:
- Region.cs
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)
Parameter
Beispiele
Ein Codebeispiel finden Sie in der Exclude(RectangleF) -Methode.
Gilt für:
Exclude(RectangleF)
- Quelle:
- Region.cs
- Quelle:
- Region.cs
- Quelle:
- Region.cs
Aktualisiert diese Region, sodass sie nur den Teil des Inneren enthält, der keine Schnittmenge mit der angegebenen RectangleF-Struktur bildet.
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)
Parameter
- rect
- RectangleF
Die aus dieser RectangleF auszuschließende Region-Struktur.
Beispiele
Das folgende Beispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse
, was ein Parameter des Paint Ereignishandlers ist. Der Code führt die folgenden Aktionen aus:
Erstellt ein Rechteck und zeichnet es in Schwarz auf den Bildschirm
Erstellt ein zweites Rechteck, das sich mit dem ersten überschneidet, und zeichnet es rot auf den Bildschirm.
Erstellt eine Region mit dem ersten Rechteck.
Ruft den nicht abgegrenzten Bereich der Region ab, wenn er mit dem zweiten Rechteck kombiniert wird.
Füllt den nicht abgegrenzten Bereich mit Blau aus und zeichnet ihn auf den Bildschirm.
Beachten Sie, dass der Bereich des Bereichs der Region, der sich nicht mit dem Rechteck überschneidet, blau gefärbt ist.
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
Gilt für:
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für