Region.Union 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將此 Region 更新為本身的聯集和指定的 GraphicsPath。
多載
Union(GraphicsPath) |
將此 Region 更新為本身的聯集和指定的 GraphicsPath。 |
Union(Rectangle) | |
Union(RectangleF) |
將此 Region 更新為本身的聯集和指定的 RectangleF 結構。 |
Union(Region) |
Union(GraphicsPath)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
將此 Region 更新為本身的聯集和指定的 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)
參數
- path
- GraphicsPath
要與這個 Region聯合的 GraphicsPath。
例外狀況
path
null
。
範例
如需程式代碼範例,請參閱 Union(RectangleF) 和 Complement(GraphicsPath) 方法。
適用於
Union(Rectangle)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
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)
參數
範例
如需程式代碼範例,請參閱 Union(RectangleF) 方法。
適用於
Union(RectangleF)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
將此 Region 更新為本身的聯集和指定的 RectangleF 結構。
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)
參數
- rect
- RectangleF
要與這個 Region聯合的 RectangleF 結構。
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
。 程式代碼會執行下列動作:
建立第一個矩形,並將它繪製到黑色的畫面。
建立第二個矩形,並以紅色將它繪製到畫面。
使用第一個矩形建立區域。
當與
complementRect
結合時,取得myRegion
的聯集區域。以藍色填滿等位區域,並將其繪製到螢幕。
請注意,這兩個矩形都填滿藍色,包括重疊的區域。
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
適用於
Union(Region)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
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)
參數
例外狀況
region
null
。
範例
如需程式代碼範例,請參閱 Union(RectangleF) 和 Complement(GraphicsPath) 方法。