Region.Complement Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Uppdaterar detta Region till den del av den angivna RectangleF strukturen som inte korsar den här Region.
Överlagringar
| Name | Description |
|---|---|
| Complement(Region) |
Uppdaterar detta Region så att det innehåller den del av den angivna Region som inte korsas med den här Region. |
| Complement(RectangleF) |
Uppdaterar detta Region så att det innehåller den del av den angivna RectangleF strukturen som inte korsar den här Region. |
| Complement(GraphicsPath) |
Uppdaterar detta Region så att det innehåller den del av den angivna GraphicsPath som inte korsas med den här Region. |
| Complement(Rectangle) |
Uppdaterar detta Region så att det innehåller den del av den angivna Rectangle strukturen som inte korsar den här Region. |
Complement(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)
Parametrar
Undantag
region är null.
Exempel
Följande exempel är utformat för användning med Windows Forms och kräver PaintEventArgse, vilket är en parameter för händelsehanteraren Paint. Koden utför följande åtgärder:
Skapar en rektangel och drar den till skärmen i svart
Skapar en andra rektangel som korsar med den första och drar den till skärmen i rött.
Skapar en region med hjälp av den första rektangeln och skapar en andra region med hjälp av den andra rektangeln.
Hämtar komplementet för den första regionen i kombination med den andra regionen.
Fyller komplementområdet med blått och drar det till skärmen.
Observera att området i den andra regionen som inte korsar den första regionen är färgad blå.
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
Gäller för
Complement(RectangleF)
Uppdaterar detta Region så att det innehåller den del av den angivna RectangleF strukturen som inte korsar den här 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)
Parametrar
- rect
- RectangleF
Strukturen RectangleF för att komplettera den här Region.
Exempel
Följande kodexempel är utformat för användning med Windows Forms och kräver PaintEventArgse, vilket är en parameter för händelsehanteraren Paint. Koden utför följande åtgärder:
Skapar en rektangel och drar den till skärmen i svart.
Skapar en andra rektangel som korsar med den första och drar den till skärmen i rött.
Skapar en region med hjälp av den första rektangeln.
Hämtar komplementet för den regionen i kombination med den andra rektangeln.
Fyller komplementområdet med blått och drar det till skärmen.
Observera att området för den andra rektangeln som inte korsar regionen är färgad blå.
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
Gäller för
Complement(GraphicsPath)
Uppdaterar detta Region så att det innehåller den del av den angivna GraphicsPath som inte korsas med den här 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)
Parametrar
- path
- GraphicsPath
För GraphicsPath att komplettera detta Region.
Undantag
path är null.
Exempel
Följande kodexempel är utformat för användning med Windows Forms och kräver PaintEventArgse, vilket är en parameter för händelsehanteraren Paint. Koden utför följande åtgärder:
Skapar en rektangel och drar den till skärmen i svart.
Skapar en andra rektangel som korsar med den första och drar den till skärmen i rött.
Skapar en region med hjälp av den första rektangeln.
Skapar en GraphicsPath, och lägger till den andra rektangeln i den.
Hämtar komplementet för regionen när det kombineras med GraphicsPath.
Fyller komplementområdet med blått och drar det till skärmen.
Observera att området för GraphicsPath det som inte korsar regionen är färgat blått.
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
Gäller för
Complement(Rectangle)
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)
Parametrar
Exempel
Ett exempel finns i Complement(RectangleF) metoden.