語言

Region.Union 方法

定義

將此 Region 更新為自身與指定的 GraphicsPath聯集。

多載

名稱 Description
Union(GraphicsPath)

將此 Region 更新為自身與指定的 GraphicsPath聯集。

Union(Rectangle)

將此 Region 更新為自身與指定 Rectangle 結構的聯集。

Union(RectangleF)

將此 Region 更新為自身與指定 RectangleF 結構的聯集。

Union(Region)

將此 Region 更新為自身與指定的 Region聯集。

Union(GraphicsPath)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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

他們 GraphicsPath 要與此 Region結合。

例外狀況

path 是 null。

範例

關於程式碼範例,請參見 and Union(RectangleF) 方法。Complement(GraphicsPath)

適用於

Union(Rectangle)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為自身與指定 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)

參數

rect
Rectangle

與此Rectangle結合的結構。Region

範例

程式碼範例請參見該 Union(RectangleF) 方法。

適用於

Union(RectangleF)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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

與此RectangleF結合的結構。Region

範例

以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse。 此程式碼會執行下列動作:

  • 建立第一個矩形,並以黑色繪製到螢幕上。

  • 建立第二個矩形,並以紅色畫到螢幕上。

  • 用第一個矩形建立一個區域。

  • 當與 myRegion結合時,得到 的complementRect聯集面積。

  • 會用藍色填滿 並 並把它畫到螢幕上。

注意兩個矩形都被藍色填滿,包括重疊區域。

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
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為自身與指定的 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)

參數

region
Region

他們 Region 要與此 Region結合。

例外狀況

region 是 null。

範例

程式碼範例請參見 Union(RectangleF) and Complement(GraphicsPath) 方法。

適用於