Rect.Inflate 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建一个矩形,该矩形由指定的量展开或收缩矩形。
重载
| 名称 | 说明 |
|---|---|
| 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 生成的矩形将增加或减少指定高度的两倍。
如果指定的宽度或高度缩小矩形的当前宽度或高度大于其当前 WidthHeight 或 - 给矩形一个负区域 - 矩形将成为 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 生成的矩形将增加或减少指定高度的两倍。
如果指定的宽度或高度修饰符缩小矩形的当前 WidthHeight 或 - 给矩形一个负区域 - 此方法返回 Rect.Empty。