Region.Complement Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Aggiorna questa Region proprietà alla parte della struttura specificata RectangleF che non si interseca con questo Regionoggetto .
Overload
| Nome | Descrizione |
|---|---|
| Complement(Region) |
Aggiorna questa Region classe in modo che contenga la parte dell'oggetto specificato Region che non si interseca con questo Regionoggetto . |
| Complement(RectangleF) |
Aggiorna questo Region oggetto in modo che contenga la parte della struttura specificata RectangleF che non si interseca con questo Regionoggetto . |
| Complement(GraphicsPath) |
Aggiorna questa Region classe in modo che contenga la parte dell'oggetto specificato GraphicsPath che non si interseca con questo Regionoggetto . |
| Complement(Rectangle) |
Aggiorna questo Region oggetto in modo che contenga la parte della struttura specificata Rectangle che non si interseca con questo Regionoggetto . |
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)
Parametri
Eccezioni
region è null.
Esempio
L'esempio seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:
Crea un rettangolo e lo disegna sullo schermo in nero
Crea un secondo rettangolo che interseca con il primo e lo disegna sullo schermo in rosso.
Crea un'area usando il primo rettangolo e crea una seconda area usando il secondo rettangolo.
Ottiene il complemento della prima area quando viene combinata con la seconda area.
Riempie l'area di complemento con blu e la disegna sullo schermo.
Si noti che l'area della seconda area che non si interseca con la prima area è blu colorato.
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
Si applica a
Complement(RectangleF)
Aggiorna questo Region oggetto in modo che contenga la parte della struttura specificata RectangleF che non si interseca con questo Regionoggetto .
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)
Parametri
- rect
- RectangleF
Struttura RectangleF da integrare in questo Regionoggetto .
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Crea un rettangolo e lo disegna sullo schermo in nero.
Crea un secondo rettangolo che interseca con il primo e lo disegna sullo schermo in rosso.
Crea un'area usando il primo rettangolo.
Ottiene il complemento dell'area in combinazione con il secondo rettangolo.
Riempie l'area di complemento con blu e la disegna sullo schermo.
Si noti che l'area del secondo rettangolo che non si interseca con l'area è blu colorato.
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
Si applica a
Complement(GraphicsPath)
Aggiorna questa Region classe in modo che contenga la parte dell'oggetto specificato GraphicsPath che non si interseca con questo Regionoggetto .
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)
Parametri
- path
- GraphicsPath
Oggetto GraphicsPath da integrare in questo Regionoggetto .
Eccezioni
path è null.
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Crea un rettangolo e lo disegna sullo schermo in nero.
Crea un secondo rettangolo che interseca con il primo e lo disegna sullo schermo in rosso.
Crea un'area usando il primo rettangolo.
Crea un GraphicsPathoggetto e aggiunge il secondo rettangolo.
Ottiene il complemento dell'area quando combinato con .GraphicsPath
Riempie l'area di complemento con blu e la disegna sullo schermo.
Si noti che l'area dell'oggetto GraphicsPath che non si interseca con l'area è di colore blu.
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
Si applica 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)
Parametri
Esempio
Per un esempio, vedere il Complement(RectangleF) metodo .