Strokes.Transform 方法 (Matrix)

将线性变换应用于 Strokes 集合,并且不影响笔宽度。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub Transform ( _
    inkTransform As Matrix _
)
用法
Dim instance As Strokes
Dim inkTransform As Matrix

instance.Transform(inkTransform)
public void Transform(
    Matrix inkTransform
)
public:
void Transform(
    Matrix^ inkTransform
)
public void Transform(
    Matrix inkTransform
)
public function Transform(
    inkTransform : Matrix
)

参数

备注

变换应用于点,但不应用于笔宽度。若要设置一个值将变换应用于笔宽度,请使用此方法的 Transform(Matrix, Boolean) 重载。

线性变换可表示缩放、旋转、转换以及变换组合。

示例

在此示例中,附加到 InkOverlay 对象的 Strokes 集合旋转 180 度。旋转围绕 Strokes 集合边界框的中心进行。

' Access to the Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes

    Dim inkTransform As Matrix = New Matrix()
    Dim bounds As Rectangle = allStrokes.GetBoundingBox()
    Dim center As PointF = _
        New PointF(0.5F * (bounds.Left + bounds.Right), _
                   0.5F * (bounds.Top + bounds.Bottom))
    ' Translate to center of bounding box
    inkTransform.Translate(center.X, center.Y)
    ' Rotate by 180 degrees
    inkTransform.Rotate(180.0F)
    ' Translate back
    inkTransform.Translate(-center.X, -center.Y)
    ' Transform strokes
    allStrokes.Transform(inkTransform)
End Using
// Access to the Strokes property returns a copy of the Strokes object.
// This copy must be implicitly (via using statement) or explicitly
// disposed of in order to avoid a memory leak.
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
    Matrix inkTransform = new Matrix();
    Rectangle bounds = allStrokes.GetBoundingBox();
    PointF center = new PointF(0.5f * (bounds.Left + bounds.Right),
                               0.5f * (bounds.Top + bounds.Bottom));
    // Translate to center of bounding box
    inkTransform.Translate(center.X, center.Y);
    // Rotate by 180 degrees
    inkTransform.Rotate(180f);
    // Translate back
    inkTransform.Translate(-center.X, -center.Y);
    // Transform strokes
    allStrokes.Transform(inkTransform);
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Strokes 类

Strokes 成员

Transform 重载

Microsoft.Ink 命名空间

Strokes.Scale

Strokes.Move

Strokes.Rotate

Stroke.Transform