Breyta

Deila með


Rect.Inflate Method

Definition

Creates a rectangle that results from expanding or shrinking a rectangle by the specified amount.

Overloads

Inflate(Size)

Expands the rectangle by using the specified Size, in all directions.

Inflate(Double, Double)

Expands or shrinks the rectangle by using the specified width and height amounts, in all directions.

Inflate(Rect, Size)

Returns the rectangle that results from expanding the specified rectangle by the specified Size, in all directions.

Inflate(Rect, Double, Double)

Creates a rectangle that results from expanding or shrinking the specified rectangle by the specified width and height amounts, in all directions.

Inflate(Size)

Expands the rectangle by using the specified Size, in all directions.

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)

Parameters

size
Size

Specifies the amount to expand the rectangle. The Size structure's Width property specifies the amount to increase the rectangle's Left and Right properties. The Size structure's Height property specifies the amount to increase the rectangle's Top and Bottom properties.

Exceptions

This method is called on the Empty rectangle.

Examples

The following example shows how to use the Inflate(Size) method to increase the size of a rectangle.

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;
}

Remarks

The 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.

See also

Applies to

Inflate(Double, Double)

Expands or shrinks the rectangle by using the specified width and height amounts, in all directions.

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)

Parameters

width
Double

The amount by which to expand or shrink the left and right sides of the rectangle.

height
Double

The amount by which to expand or shrink the top and bottom sides of the rectangle.

Exceptions

This method is called on the Empty rectangle.

Examples

The following example shows how to use the Inflate(Double, Double) method to change the size of a rectangle.

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;
}

Remarks

The Width of the resulting rectangle is increased or decreased by twice the specified width offset, because it is applied to both the left and right sides of the rectangle. Likewise, the Height of the resulting rectangle is increased or decreased by twice the specified height.

If the specified width or height shrink the rectangle by more than its current Width or Height - giving the rectangle a negative area - the rectangle becomes the Empty rectangle.

See also

Applies to

Inflate(Rect, Size)

Returns the rectangle that results from expanding the specified rectangle by the specified Size, in all directions.

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

Parameters

rect
Rect

The Rect structure to modify.

size
Size

Specifies the amount to expand the rectangle. The Size structure's Width property specifies the amount to increase the rectangle's Left and Right properties. The Size structure's Height property specifies the amount to increase the rectangle's Top and Bottom properties.

Returns

The resulting rectangle.

Exceptions

rect is an Empty rectangle.

Examples

The following example shows how to use the Inflate(Rect, Size) method to change the size of a rectangle.

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;
}

Remarks

The 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.

See also

Applies to

Inflate(Rect, Double, Double)

Creates a rectangle that results from expanding or shrinking the specified rectangle by the specified width and height amounts, in all directions.

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

Parameters

rect
Rect

The Rect structure to modify.

width
Double

The amount by which to expand or shrink the left and right sides of the rectangle.

height
Double

The amount by which to expand or shrink the top and bottom sides of the rectangle.

Returns

The resulting rectangle.

Exceptions

rect is an Empty rectangle.

Examples

The following example shows how to use the Inflate(Rect, Double, Double) method to change the size of a rectangle.

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;
}

Remarks

The Width of the resulting rectangle is increased or decreased by twice the specified width offset, because it is applied to both the left and right sides of the rectangle. Likewise, the Height of the resulting rectangle is increased or decreased by twice the specified height.

If the specified width or height modifiers shrink the rectangle by more than its current Width or Height - giving the rectangle a negative area - this method returns Rect.Empty.

See also

Applies to