Region.Complement Método
Definição
Atualiza este Region para a parte da estrutura RectangleF especificada que não faz intersecção com este Region.Updates this Region to the portion of the specified RectangleF structure that does not intersect with this Region.
Sobrecargas
| Complement(Region) |
Atualiza este Region para conter a parte do Region especificado que não se intersecciona com este Region.Updates this Region to contain the portion of the specified Region that does not intersect with this Region. |
| Complement(RectangleF) |
Atualiza este Region para conter a parte da estrutura RectangleF especificada que não faz intersecção com este Region.Updates this Region to contain the portion of the specified RectangleF structure that does not intersect with this Region. |
| Complement(GraphicsPath) |
Atualiza este Region para conter a parte do GraphicsPath especificado que não se intersecciona com este Region.Updates this Region to contain the portion of the specified GraphicsPath that does not intersect with this Region. |
| Complement(Rectangle) |
Atualiza este Region para conter a parte da estrutura Rectangle especificada que não faz intersecção com este Region.Updates this Region to contain the portion of the specified Rectangle structure that does not intersect with this 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)
Parâmetros
- region
- Region
O objeto Region complementa este objeto Region.The Region object to complement this Region object.
Exceções
region é null.region is null.
Exemplos
O exemplo a seguir foi projetado para uso com Windows Forms e requer PaintEventArgs e , que é um parâmetro do manipulador de Paint eventos.The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. O código executa as seguintes ações:The code performs the following actions:
Cria um retângulo e o desenha na tela em pretoCreates a rectangle and draws it to the screen in black
Cria um segundo retângulo que faz interseção com o primeiro e o desenha na tela em vermelho.Creates a second rectangle that intersects with the first and draws it to the screen in red.
Cria uma região usando o primeiro retângulo e cria uma segunda região usando o segundo retângulo.Creates one region using the first rectangle and creates a second region using the second rectangle.
Obtém o complemento dessa primeira região quando combinada com a segunda região.Gets the complement of that first region when combined with the second region.
Preenche a área de complemento com azul e a desenha na tela.Fills the complement area with blue and draws it to the screen.
Observe que a área da segunda região que não faz interseção com a primeira região é azul colorida.Notice that the area of the second region that does not intersect with the first region is colored blue.
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
Aplica-se a
Complement(RectangleF)
Atualiza este Region para conter a parte da estrutura RectangleF especificada que não faz intersecção com este Region.Updates this Region to contain the portion of the specified RectangleF structure that does not intersect with this 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)
Parâmetros
- rect
- RectangleF
A estrutura RectangleF para complementar este Region.The RectangleF structure to complement this Region.
Exemplos
O exemplo de código a seguir foi projetado para uso com Windows Forms, e ele requer PaintEventArgs e , que é um parâmetro do Paint manipulador de eventos.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. O código executa as seguintes ações:The code performs the following actions:
Cria um retângulo e o desenha na tela em preto.Creates a rectangle and draws it to the screen in black.
Cria um segundo retângulo que faz interseção com o primeiro e o desenha na tela em vermelho.Creates a second rectangle that intersects with the first and draws it to the screen in red.
Cria uma região usando o primeiro retângulo.Creates a region using the first rectangle.
Obtém o complemento dessa região combinada com o segundo retângulo.Gets the complement of that region combined with the second rectangle.
Preenche a área de complemento com azul e a desenha na tela.Fills the complement area with blue and draws it to the screen.
Observe que a área do segundo retângulo que não faz interseção com a região é azul colorida.Notice that the area of the second rectangle that does not intersect with the region is colored blue.
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
Aplica-se a
Complement(GraphicsPath)
Atualiza este Region para conter a parte do GraphicsPath especificado que não se intersecciona com este Region.Updates this Region to contain the portion of the specified GraphicsPath that does not intersect with this 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)
Parâmetros
- path
- GraphicsPath
O GraphicsPath para complementar este Region.The GraphicsPath to complement this Region.
Exceções
path é null.path is null.
Exemplos
O exemplo de código a seguir foi projetado para uso com Windows Forms, e ele requer PaintEventArgs e , que é um parâmetro do Paint manipulador de eventos.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. O código executa as seguintes ações:The code performs the following actions:
Cria um retângulo e o desenha na tela em preto.Creates a rectangle and draws it to the screen in black.
Cria um segundo retângulo que faz interseção com o primeiro e o desenha na tela em vermelho.Creates a second rectangle that intersects with the first and draws it to the screen in red.
Cria uma região usando o primeiro retângulo.Creates a region using the first rectangle.
Cria um GraphicsPath e adiciona o segundo retângulo a ele.Creates a GraphicsPath, and adds the second rectangle to it.
Obtém o complemento da região quando combinado com o GraphicsPath .Gets the complement of the region when combined with the GraphicsPath.
Preenche a área de complemento com azul e a desenha na tela.Fills the complement area with blue and draws it to the screen.
Observe que a área do GraphicsPath que não faz interseção com a região é azul colorida.Notice that the area of the GraphicsPath that does not intersect with the region is colored blue.
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
Aplica-se a
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)
Parâmetros
- rect
- Rectangle
A estrutura Rectangle para complementar este Region.The Rectangle structure to complement this Region.
Exemplos
Para obter um exemplo, consulte o Complement(RectangleF) método.For an example, see the Complement(RectangleF) method.