LinearGradientBrush.TranslateTransform 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
按指定维度转换局部几何转换。 此方法在转换前追加转换。
重载
| TranslateTransform(Single, Single, MatrixOrder) | 按指定顺序按指定维度转换局部几何转换。 | 
| TranslateTransform(Single, Single) | 按指定维度转换局部几何转换。 此方法在转换前追加转换。 | 
TranslateTransform(Single, Single, MatrixOrder)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
按指定顺序按指定维度转换局部几何转换。
public:
 void TranslateTransform(float dx, float dy, System::Drawing::Drawing2D::MatrixOrder order);public void TranslateTransform (float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order);member this.TranslateTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unitPublic Sub TranslateTransform (dx As Single, dy As Single, order As MatrixOrder)参数
- dx
- Single
x 中翻译的值。
- dy
- Single
y 中翻译的值。
- order
- MatrixOrder
应用翻译的顺序(前面或追加)。
示例
下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:
- 创建新的 LinearGradientBrush。 
- 使用此画笔将矩形绘制到屏幕,该矩形具有颜色的线性、从左到右的切换效果。 
- 将 LinearGradientBrush 旋转 90 度并缩放渐变。 
- 将具有旋转和缩放渐变的矩形绘制到屏幕。 
- 转换矩形,使其具有从上到下运行的线性渐变。 
- 将翻译后的矩形绘制到屏幕。 
请注意,有三个矩形显示顶部一个,显示从左到右渐变,中间一个显示旋转和缩放渐变,底部显示最终的转换渐变。
private:
   void TranslateTransformExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );
      // Draw a rectangle to the screen using the LinearGradientBrush.
      e->Graphics->FillRectangle( myLGBrush, myRect );
      // Rotate the LinearGradientBrush.
      myLGBrush->RotateTransform( 90.0f );
      // Scale the gradient for the height of the rectangle.
      myLGBrush->ScaleTransform( 0.5f, 1.0f );
      // Draw to the screen, the rotated and scaled gradient.
      e->Graphics->FillRectangle( myLGBrush, 20, 150, 200, 100 );
      // Rejustify the brush to start at the top edge of the
      // rectangle.
      myLGBrush->TranslateTransform(  -20.0f, 0.0f );
      // Draw a third rectangle to the screen using the translated
      // brush.
      e->Graphics->FillRectangle( myLGBrush, 20, 300, 200, 100 );
   }
private void TranslateTransformExample(PaintEventArgs e)
{
             
    // Create a LinearGradientBrush.
    Rectangle myRect = new Rectangle(20, 20, 200, 100);
    LinearGradientBrush myLGBrush = new LinearGradientBrush(
        myRect, Color.Blue, Color.Red,  0.0f, true);
             
    // Draw a rectangle to the screen using the LinearGradientBrush.
    e.Graphics.FillRectangle(myLGBrush, myRect);
             
    // Rotate the LinearGradientBrush.
    myLGBrush.RotateTransform(90.0f);
             
    // Scale the gradient for the height of the rectangle.
    myLGBrush.ScaleTransform(0.5f, 1.0f);
             
    // Draw to the screen, the rotated and scaled gradient.
    e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100);
             
    // Rejustify the brush to start at the top edge of the
    // rectangle.
    myLGBrush.TranslateTransform(-20.0f, 0.0f);
             
    // Draw a third rectangle to the screen using the translated
    // brush.
    e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100);
}
Public Sub TranslateTransformExample(ByVal e As PaintEventArgs)
    ' Create a LinearGradientBrush.
    Dim myRect As New Rectangle(20, 20, 200, 100)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Red, 0.0F, True)
    ' Draw a rectangle to the screen using the LinearGradientBrush.
    e.Graphics.FillRectangle(myLGBrush, myRect)
    ' Rotate the LinearGradientBrush.
    myLGBrush.RotateTransform(90.0F)
    ' Scale the gradient for the height of the rectangle.
    myLGBrush.ScaleTransform(0.5F, 1.0F)
    ' Draw to the screen, the rotated and scaled gradient.
    e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100)
    ' Rejustify the brush to start at the top edge of the rectangle.
    myLGBrush.TranslateTransform(-20.0F, 0.0F)
    ' Draw a third rectangle to the screen using the translated brush.
    e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100)
End Sub
适用于
TranslateTransform(Single, Single)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
按指定维度转换局部几何转换。 此方法在转换前追加转换。
public:
 void TranslateTransform(float dx, float dy);public void TranslateTransform (float dx, float dy);member this.TranslateTransform : single * single -> unitPublic Sub TranslateTransform (dx As Single, dy As Single)参数
- dx
- Single
x 中翻译的值。
- dy
- Single
y 中翻译的值。
示例
有关示例,请参阅 TranslateTransform。