Region.Union 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 själva unionen och den angivna GraphicsPath.
Överlagringar
| Name | Description |
|---|---|
| Union(GraphicsPath) |
Uppdaterar detta Region till själva unionen och den angivna GraphicsPath. |
| Union(Rectangle) |
Uppdaterar detta Region till själva unionen och den angivna Rectangle strukturen. |
| Union(RectangleF) |
Uppdaterar detta Region till själva unionen och den angivna RectangleF strukturen. |
| Union(Region) |
Uppdaterar detta Region till själva unionen och den angivna Region. |
Union(GraphicsPath)
Uppdaterar detta Region till själva unionen och den angivna GraphicsPath.
public:
void Union(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Union(System.Drawing.Drawing2D.GraphicsPath path);
member this.Union : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Union (path As GraphicsPath)
Parametrar
- path
- GraphicsPath
Att GraphicsPath förena med detta Region.
Undantag
path är null.
Exempel
Ett kodexempel finns i Union(RectangleF) metoderna och Complement(GraphicsPath) .
Gäller för
Union(Rectangle)
public:
void Union(System::Drawing::Rectangle rect);
public void Union(System.Drawing.Rectangle rect);
member this.Union : System.Drawing.Rectangle -> unit
Public Sub Union (rect As Rectangle)
Parametrar
Exempel
Ett kodexempel finns i Union(RectangleF) metoden.
Gäller för
Union(RectangleF)
Uppdaterar detta Region till själva unionen och den angivna RectangleF strukturen.
public:
void Union(System::Drawing::RectangleF rect);
public void Union(System.Drawing.RectangleF rect);
member this.Union : System.Drawing.RectangleF -> unit
Public Sub Union (rect As RectangleF)
Parametrar
- rect
- RectangleF
Strukturen RectangleF som ska förenas med den här Region.
Exempel
Följande kodexempel är utformat för användning med Windows Forms och kräver PaintEventArgse. Koden utför följande åtgärder:
Skapar den första rektangeln och drar den till skärmen i svart.
Skapar en andra rektangel och drar den till skärmen i rött.
Skapar en region med hjälp av den första rektangeln.
Hämtar unionsområdet för
myRegionnär det kombineras medcomplementRect.Fyller området i unionen med blått och drar det till skärmen.
Observera att båda rektanglarna är fyllda med blått, inklusive överlappningsområdet.
void Union_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 unionRect = RectangleF(90,30,100,100);
e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( unionRect ) );
// Create a region using the first rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
// Get the area of union for myRegion when combined with
// complementRect.
myRegion->Union( unionRect );
// Fill the union area of myRegion with blue.
SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
e->Graphics->FillRegion( myBrush, myRegion );
}
public void Union_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 unionRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red,
Rectangle.Round(unionRect));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Get the area of union for myRegion when combined with
// complementRect.
myRegion.Union(unionRect);
// Fill the union area of myRegion with blue.
SolidBrush myBrush = new SolidBrush(Color.Blue);
e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Union_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 unionRect As New RectangleF(90, 30, 100, 100)
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(unionRect))
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Get the area of union for myRegion when combined with
' complementRect.
myRegion.Union(unionRect)
' Fill the intersection area of myRegion with blue.
Dim myBrush As New SolidBrush(Color.Blue)
e.Graphics.FillRegion(myBrush, myRegion)
End Sub
Gäller för
Union(Region)
public:
void Union(System::Drawing::Region ^ region);
public void Union(System.Drawing.Region region);
member this.Union : System.Drawing.Region -> unit
Public Sub Union (region As Region)
Parametrar
Undantag
region är null.
Exempel
Ett kodexempel finns i Union(RectangleF) metoden och Complement(GraphicsPath) .