Rect.Union 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個恰好足夠大的矩形,能容納給定的矩形與指定的點或第二個矩形。
多載
| 名稱 | Description |
|---|---|
| Union(Point) |
將當前矩形正好展開到包含指定點的位置。 |
| Union(Rect) |
將當前矩形擴展到足以容納指定的矩形。 |
| Union(Rect, Point) |
建立一個剛好足夠大的矩形,以包含指定的矩形和指定的點。 |
| Union(Rect, Rect) |
建立一個剛好足夠容納兩個指定矩形的矩形。 |
Union(Point)
將當前矩形正好展開到包含指定點的位置。
public:
void Union(System::Windows::Point point);
public void Union(System.Windows.Point point);
member this.Union : System.Windows.Point -> unit
Public Sub Union (point As Point)
參數
- point
- Point
要包含的重點。
範例
以下範例說明如何利用該 Union(Point) 方法將當前矩形恰好展開到足夠容納給定 Point的 。
private Rect unionExample1()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// The Union method expands the current rectangle exactly enough to contain
// the specified point. myRectangle expands to a location of 0,0 and a size
// of 210,55.
myRectangle.Union(new Point(0,0));
// Returns 0,0,210,55
return myRectangle;
}
另請參閱
適用於
Union(Rect)
將當前矩形擴展到足以容納指定的矩形。
public:
void Union(System::Windows::Rect rect);
public void Union(System.Windows.Rect rect);
member this.Union : System.Windows.Rect -> unit
Public Sub Union (rect As Rect)
參數
- rect
- Rect
要包含的矩形。
範例
以下範例展示了如何利用該 Union(Rect) 方法將當前矩形恰好展開到足夠容納指定的矩形。
private Rect unionExample2()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Create second rectangle.
Rect myRectangle2 = new Rect();
myRectangle2.Location = new Point(0, 0);
myRectangle2.Size = new Size(200, 50);
// The Union method expands the current rectangle exactly enough to contain
// the specified rectangle. myRectangle expands to a location of 0,0 and a size
// of 210,55.
myRectangle.Union(myRectangle2);
// Returns 0,0,210,55
return myRectangle;
}
另請參閱
適用於
Union(Rect, Point)
建立一個剛好足夠大的矩形,以包含指定的矩形和指定的點。
public:
static System::Windows::Rect Union(System::Windows::Rect rect, System::Windows::Point point);
public static System.Windows.Rect Union(System.Windows.Rect rect, System.Windows.Point point);
static member Union : System.Windows.Rect * System.Windows.Point -> System.Windows.Rect
Public Shared Function Union (rect As Rect, point As Point) As Rect
參數
- rect
- Rect
要包含的矩形。
- point
- Point
要包含的重點。
傳回
一個剛好夠大,能容納指定的矩形和指定點的矩形。
範例
以下範例說明如何利用此 Union(Rect, Point) 方法建立一個恰好足夠大以容納給定矩形與給定 Point矩形的矩形。
private Rect unionExample3()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Create second rectangle.
Rect myRectangle2 = new Rect();
myRectangle2.Location = new Point(0, 0);
myRectangle2.Size = new Size(200, 50);
// The Union method expands the current rectangle exactly enough to contain
// the specified rectangle and the specified Point. In this example, returnRect
// expands to a location of 0,0 and a size of 250,60.
Rect returnRect = Rect.Union(myRectangle2, new Point(250,60));
// Returns 0,0,250,60
return returnRect;
}
另請參閱
適用於
Union(Rect, Rect)
建立一個剛好足夠容納兩個指定矩形的矩形。
public:
static System::Windows::Rect Union(System::Windows::Rect rect1, System::Windows::Rect rect2);
public static System.Windows.Rect Union(System.Windows.Rect rect1, System.Windows.Rect rect2);
static member Union : System.Windows.Rect * System.Windows.Rect -> System.Windows.Rect
Public Shared Function Union (rect1 As Rect, rect2 As Rect) As Rect
參數
- rect1
- Rect
第一個包含的矩形。
- rect2
- Rect
第二個要包含的矩形。
傳回
結果就是長方形。
範例
以下範例展示了如何利用此 Union(Rect, Rect) 方法建立一個恰好足夠容納兩個指定矩形的矩形。
private Rect unionExample4()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Create second rectangle.
Rect myRectangle2 = new Rect();
myRectangle2.Location = new Point(0, 0);
myRectangle2.Size = new Size(200, 50);
// Create a third rectangle.
Rect myRectangle3 = new Rect();
myRectangle3.Location = new Point(210, 60);
myRectangle3.Size = new Size(50, 50);
// The Union method expands the current rectangle exactly enough to contain
// the two specified rectangles. In this example, returnRect expands to
// a location of 0,0 and a size of 260,110.
Rect returnRect = Rect.Union(myRectangle2, myRectangle3);
// Returns 0,0,260,110
return returnRect;
}