LinearGradientBrush.ResetTransform Méthode

Définition

Rétablit l'identité de la propriété Transform.Resets the Transform property to identity.

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

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms, et il requiert PaintEventArgs e un OnPaint objet d’événement.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. Le code effectue les actions suivantes :The code performs the following actions:

  • Crée un LinearGradientBrush.Creates a new LinearGradientBrush.

  • Dessine une ellipse à l’écran à l’aide de ce pinceau.Draws an ellipse to the screen using this brush.

  • Appelle la MultiplyTransform méthode pour transformer le LinearGradientBrush .Calls the MultiplyTransform method to transform the LinearGradientBrush.

  • Dessine une ellipse à l’écran, directement sous la première ellipse, à l’aide du pinceau transformé.Draws an ellipse to the screen directly below the first ellipse, using the transformed brush.

  • Réinitialise la transformation.Resets the transform.

  • Dessine une troisième ellipse à l’écran sous les deux premières.Draws a third ellipse to the screen below the first two.

Notez que l’ellipse la plus basse est dessinée de la même taille que la première, et que, en raison de l’appel à la ResetTransform méthode, le dégradé a été réduit pour correspondre.Notice that the lowest ellipse is drawn the same size as the first, and that, due to the call to the ResetTransform method, the gradient has been reduced to match.

private:
   void ResetTransformExample( 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 an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, myRect );

      // Transform the LinearGradientBrush.
      array<Point>^ transformArray = {Point(20,150),Point(400,150),Point(20,200)};
      Matrix^ myMatrix = gcnew Matrix( myRect,transformArray );
      myLGBrush->MultiplyTransform( myMatrix, MatrixOrder::Prepend );

      // Draw a second ellipse to the screen
      // using the transformed brush.
      e->Graphics->FillEllipse( myLGBrush, 20, 150, 380, 50 );

      // Reset the brush transform.
      myLGBrush->ResetTransform();

      // Draw a third ellipse to the screen using the reset brush.
      e->Graphics->FillEllipse( myLGBrush, 20, 250, 200, 100 );
   }
private void ResetTransformExample(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 an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect);
             
    // Transform the LinearGradientBrush.
    Point[] transformArray = { new Point(20, 150),
         new Point(400,150), new Point(20, 200) };
       
    Matrix myMatrix = new Matrix(myRect, transformArray);
    myLGBrush.MultiplyTransform( myMatrix, MatrixOrder.Prepend);
             
    // Draw a second ellipse to the screen
    // using the transformed brush.
    e.Graphics.FillEllipse(myLGBrush, 20, 150, 380, 50);
             
    // Reset the brush transform.
    myLGBrush.ResetTransform();
             
    // Draw a third ellipse to the screen using the reset brush.
    e.Graphics.FillEllipse(myLGBrush, 20, 250, 200, 100);
}
Public Sub ResetTransformExample(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 an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect)

    ' Transform the LinearGradientBrush.
    Dim transformArray As Point() = {New Point(20, 150), _
    New Point(400, 150), New Point(20, 200)}
    Dim myMatrix As New Matrix(myRect, transformArray)
    myLGBrush.MultiplyTransform(myMatrix, MatrixOrder.Prepend)

    ' Draw a second ellipse to the screen using the transformed brush.
    e.Graphics.FillEllipse(myLGBrush, 20, 150, 380, 50)

    ' Reset the brush transform.
    myLGBrush.ResetTransform()

    ' Draw a third ellipse to the screen using the reset brush.
    e.Graphics.FillEllipse(myLGBrush, 20, 250, 200, 100)
End Sub

S’applique à