Rect.Transform 方法

定义

使用指定的矩阵转换矩形。

重载

名称 说明
Transform(Matrix)

通过应用指定的矩阵来转换矩形。

Transform(Rect, Matrix)

返回将指定矩阵应用于指定矩形的结果的矩形。

Transform(Matrix)

通过应用指定的矩阵来转换矩形。

public:
 void Transform(System::Windows::Media::Matrix matrix);
public void Transform(System.Windows.Media.Matrix matrix);
member this.Transform : System.Windows.Media.Matrix -> unit
Public Sub Transform (matrix As Matrix)

参数

matrix
Matrix

一个矩阵,指定要应用的转换。

示例

以下示例演示如何使用Transform(Matrix)Rect该方法Matrix转换结构。

private Rect transformExample1()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // Set the Size property of the rectangle with a width of 200
    // and a height of 60.
    myRectangle.Size = new Size(200, 60);

    // Creating a Matrix structure.
    Matrix myMatrix = new Matrix(0, 1, 1, 0, 20, 2);

    // The Transform method transforms this rectangle using the specified matrix.  
    // myRectangle location changed from 0,0 to 20, 2 and the size changed from
    // 200,60 to 60,200.
    myRectangle.Transform(myMatrix);

    return myRectangle;
}

适用于

Transform(Rect, Matrix)

返回将指定矩阵应用于指定矩形的结果的矩形。

public:
 static System::Windows::Rect Transform(System::Windows::Rect rect, System::Windows::Media::Matrix matrix);
public static System.Windows.Rect Transform(System.Windows.Rect rect, System.Windows.Media.Matrix matrix);
static member Transform : System.Windows.Rect * System.Windows.Media.Matrix -> System.Windows.Rect
Public Shared Function Transform (rect As Rect, matrix As Matrix) As Rect

参数

rect
Rect

一个矩形,它是转换的基础。

matrix
Matrix

一个矩阵,指定要应用的转换。

返回

操作产生的矩形。

示例

以下示例演示如何使用 Transform(Rect, Matrix) 该方法创建一个新 Rect 结构,该结构将应用于 Matrix 现有矩形。

private Rect transformExample2()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // Set the Size property of the rectangle with a width of 200
    // and a height of 60.
    myRectangle.Size = new Size(200, 60);

    // Creating a Matrix structure.
    Matrix myMatrix = new Matrix(0, 1, 1, 0, 20, 2);

    // The Transform method Transforms the specified rectangle using the specified matrix 
    // and returns the results.  
    // resultRect is an alterned version of myRectangle with a location of 20,2 rather
    // then 0,0 and a size of 60,200 rather then 200,60.
    Rect resultRect = Rect.Transform(myRectangle,myMatrix);

    return resultRect;
}

适用于