Rect.Transform 方法

定義

利用指定的矩陣轉換矩形。

多載

名稱 Description
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) 該方法來轉換結構RectMatrix

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)方法,將 a 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;
}

適用於