Pen.ResetTransform 方法

定义

将此 Pen 的几何变换矩阵重置为单位矩阵。

public:
 void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建一个 Pen

  • 将笔的转换矩阵设置为在 x 轴方向上缩放 2 次。

  • 向屏幕绘制线条。

  • 将转换矩阵重置为标识。

  • 在屏幕上绘制第二行。

public:
   void ResetTransform_Example( PaintEventArgs^ e )
   {
      
      // Create a Pen object.
      Pen^ myPen = gcnew Pen( Color::Black,3.0f );
      
      // Scale the transformation matrix of myPen.
      myPen->ScaleTransform( 2, 1 );
      
      // Draw a line with myPen.
      e->Graphics->DrawLine( myPen, 10, 0, 10, 200 );
      
      // Reset the transformation matrix of myPen to identity.
      myPen->ResetTransform();
      
      // Draw a second line with myPen.
      e->Graphics->DrawLine( myPen, 100, 0, 100, 200 );
   }
public void ResetTransform_Example(PaintEventArgs e)
{
             
    // Create a Pen object.
    Pen myPen = new Pen(Color.Black, 3);
             
    // Scale the transformation matrix of myPen.
    myPen.ScaleTransform(2, 1);
             
    // Draw a line with myPen.
    e.Graphics.DrawLine(myPen, 10, 0, 10, 200);
             
    // Reset the transformation matrix of myPen to identity.
    myPen.ResetTransform();
             
    // Draw a second line with myPen.
    e.Graphics.DrawLine(myPen, 100, 0, 100, 200);
}
Public Sub ResetTransform_Example(ByVal e As PaintEventArgs)

    ' Create a Pen object.
    Dim myPen As New Pen(Color.Black, 3)

    ' Scale the transformation matrix of myPen.
    myPen.ScaleTransform(2, 1)

    ' Draw a line with myPen.
    e.Graphics.DrawLine(myPen, 10, 0, 10, 200)

    ' Reset the transformation matrix of myPen to identity.
    myPen.ResetTransform()

    ' Draw a second line with myPen.
    e.Graphics.DrawLine(myPen, 100, 0, 100, 200)
End Sub

适用于