Rect.Inflate 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
透過按指定幅度將矩形膨脹或縮小,產生一個矩形。
多載
| 名稱 | Description |
|---|---|
| Inflate(Size) |
利用指定的 Size,向所有方向展開矩形。 |
| Inflate(Double, Double) |
利用指定的寬度與高度,向所有方向擴展或縮小矩形。 |
| Inflate(Rect, Size) |
回傳將指定矩形 Size向所有方向展開所產生的矩形。 |
| Inflate(Rect, Double, Double) |
透過將指定的矩形在各方向以指定的寬度和高度膨脹或縮小,產生一個矩形。 |
Inflate(Size)
利用指定的 Size,向所有方向展開矩形。
public:
void Inflate(System::Windows::Size size);
public void Inflate(System.Windows.Size size);
member this.Inflate : System.Windows.Size -> unit
Public Sub Inflate (size As Size)
參數
例外狀況
此方法在矩形上稱為 Empty 。
範例
以下範例展示了如何利用此 Inflate(Size) 方法來增加矩形大小。
private Size inflateExample1()
{
// 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);
// Use the Inflate method to expand the rectangle by the specified Size in all
// directions. The new size is 240,110. Note: Width of the resulting rectangle
// is increased by twice the Width of the specified Size structure because
// both the left and right sides of the rectangle are inflated. Likewise, the
// Height of the resulting rectangle is increased by twice the Height of the
// specified Size structure.
myRectangle.Inflate(new Size(20,30));
return myRectangle.Size;
}
備註
所得矩形的 會Width增加到指定Width結構的兩倍Size,因為矩形的左右兩側都被充氣了。 同樣地,所得矩形的 會Height增加到指定Height結構的兩倍Size。
另請參閱
適用於
Inflate(Double, Double)
利用指定的寬度與高度,向所有方向擴展或縮小矩形。
public:
void Inflate(double width, double height);
public void Inflate(double width, double height);
member this.Inflate : double * double -> unit
Public Sub Inflate (width As Double, height As Double)
參數
- width
- Double
將矩形左右兩側擴大或縮小的幅度。
- height
- Double
就是將矩形上下兩側擴張或收縮的幅度。
例外狀況
此方法在矩形上稱為 Empty 。
範例
以下範例說明如何使用該 Inflate(Double, Double) 方法改變矩形大小。
private Size inflateExample2()
{
// 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);
// Use the Inflate method to expand or shrink the rectangle by the specified
// width and height amounts. The new size is 160,150 (width shrunk by 40 and
// height increased by 100). Note: Width of the resulting rectangle is increased
// or shrunk by twice the specified width, because both the left and right sides
// of the rectangle are inflated or shrunk. Likewise, the height of the resulting
// rectangle is increased or shrunk by twice the specified height.
myRectangle.Inflate(-20,50);
return myRectangle.Size;
}
備註
所得矩形的偏 Width 移量會增加或減少兩倍的寬度偏移,因為偏移量同時施加在矩形的左右兩側。 同樣地,所得矩形的 會 Height 增加或減少兩倍的高度。
如果指定的寬度或高度使矩形縮小超過其當前 Width 面積,或 Height 使矩形面積為負,矩形即成為矩 Empty 形。
另請參閱
適用於
Inflate(Rect, Size)
回傳將指定矩形 Size向所有方向展開所產生的矩形。
public:
static System::Windows::Rect Inflate(System::Windows::Rect rect, System::Windows::Size size);
public static System.Windows.Rect Inflate(System.Windows.Rect rect, System.Windows.Size size);
static member Inflate : System.Windows.Rect * System.Windows.Size -> System.Windows.Rect
Public Shared Function Inflate (rect As Rect, size As Size) As Rect
參數
傳回
結果就是長方形。
例外狀況
rect 是一個 Empty 矩形。
範例
以下範例說明如何使用該 Inflate(Rect, Size) 方法改變矩形大小。
private Size inflateExample3()
{
// 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);
// Use the static Inflate method to return an expanded version of myRectangle1.
// The size of myRectangle2 is 240,110. Note: Width of the resulting rectangle is increased
// by twice the Width of the specified Size structure, because both the left and right
// sides of the rectangle are inflated. Likewise, the Height of the resulting
// rectangle is increased by twice the Height of the specified Size structure.
Rect myRectangle2 = Rect.Inflate(myRectangle, new Size(20, 30));
return myRectangle2.Size;
}
備註
所得矩形的 會Width增加到指定Width結構的兩倍Size,因為矩形的左右兩側都被充氣了。 同樣地,所得矩形的 會Height增加到指定Height結構的兩倍Size。
另請參閱
適用於
Inflate(Rect, Double, Double)
透過將指定的矩形在各方向以指定的寬度和高度膨脹或縮小,產生一個矩形。
public:
static System::Windows::Rect Inflate(System::Windows::Rect rect, double width, double height);
public static System.Windows.Rect Inflate(System.Windows.Rect rect, double width, double height);
static member Inflate : System.Windows.Rect * double * double -> System.Windows.Rect
Public Shared Function Inflate (rect As Rect, width As Double, height As Double) As Rect
參數
- width
- Double
將矩形左右兩側擴大或縮小的幅度。
- height
- Double
就是將矩形上下兩側擴張或收縮的幅度。
傳回
結果就是長方形。
例外狀況
rect 是一個 Empty 矩形。
範例
以下範例說明如何使用該 Inflate(Rect, Double, Double) 方法改變矩形大小。
private Size inflateExample4()
{
// 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);
// Use the static Inflate method to return a version of myRectangle with a shrunk
// width and expanded height. The size of myRectangle2 is 160,150. Note: Width of the resulting
// rectangle is increased or shrunk by twice the specified width, because both the
// left and right sides of the rectangle are inflated or shrunk. Likewise, the height
// of the resulting rectangle is increased or shrunk by twice the specified height.
Rect myRectangle2 = Rect.Inflate(myRectangle, -20, 50);
return myRectangle2.Size;
}
備註
所得矩形的偏 Width 移量會增加或減少兩倍的寬度偏移,因為偏移量同時施加在矩形的左右兩側。 同樣地,所得矩形的 會 Height 增加或減少兩倍的高度。
若指定的寬度或高度修飾符使矩形縮小超過其當前 Width 面積,或 Height 使矩形區域為負,則此方法返回 Rect.Empty。