Questo articolo è stato tradotto automaticamente. Per visualizzare l'articolo in inglese, selezionare la casella di controllo Inglese. È possibile anche visualizzare il testo inglese in una finestra popup posizionando il puntatore del mouse sopra il testo.
Traduzione
Inglese

Metodo Region.Complement (Region)

 

Aggiorna questa Region per contenere la parte dell'oggetto Region specificato che non si interseca con questa Region.

Spazio dei nomi:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public void Complement(
	Region region
)

Parametri

region
Type: System.Drawing.Region

Oggetto Region da aggiungere come complemento all'oggetto Region.

Exception Condition
ArgumentNullException

region è null.

The following example is designed for use with Windows Forms, and it requires T:System.Windows.Forms.PaintEventArgse, which is a parameter of the E:System.Windows.Forms.Control.Paint event handler. The code performs the following actions:

  • Creates a rectangle and draws it to the screen in black

  • Creates a second rectangle that intersects with the first and draws it to the screen in red.

  • Creates one region using the first rectangle and creates a second region using the second rectangle.

  • Gets the complement of that first region when combined with the second region.

  • Fills the complement area with blue and draws it to the screen.

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 = 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);
}

.NET Framework
Disponibile da 1.1
Torna all'inizio
Mostra: