Export (0) Print
Expand All

Graphics.TranslateTransform Method (Single, Single, MatrixOrder)

Changes the origin of the coordinate system by applying the specified translation to the transformation matrix of this Graphics in the specified order.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

Public Sub TranslateTransform ( _
	dx As Single, _
	dy As Single, _
	order As MatrixOrder _


Type: System.Single

The x-coordinate of the translation.

Type: System.Single

The y-coordinate of the translation.

Type: System.Drawing.Drawing2D.MatrixOrder

Member of the MatrixOrder enumeration that specifies whether the translation is prepended or appended to the transformation matrix.

The translation operation consists of multiplying the transformation matrix by a matrix whose translation part is the dx and dy parameters. This method prepends or appends the transformation matrix of the Graphics by the translation matrix according to the order parameter.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Rotates the world transformation matrix of the Windows Form by 30.0F degrees.

  • Moves the graphics object's origin by calling TranslateTransform, appending the translation to the world transformation matrix.

  • Draws a rotated, translated ellipse with a blue pen.

Private Sub TranslateTransformAngleMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.

    ' Then to translate, appending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append)

    ' Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft