Freigeben über


LinearGradientBrush.ResetTransform-Methode

Setzt die Transform-Eigenschaft auf Identität zurück.

Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Sub ResetTransform
'Usage
Dim instance As LinearGradientBrush

instance.ResetTransform
public void ResetTransform ()
public:
void ResetTransform ()
public void ResetTransform ()
public function ResetTransform ()

Beispiel

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert das OnPaint-Ereignisobjekt PaintEventArgse. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen neuen LinearGradientBrush.

  • Zeichnet mit diesem Pinsel eine Ellipse auf den Bildschirm.

  • Ruft die MultiplyTransform-Methode für die Transformation des LinearGradientBrush-Objekts auf.

  • Zeichnet mit dem transformierten Pinsel eine Ellipse direkt unter die erste Ellipse auf den Bildschirm.

  • Setzt die Transformation zurück.

  • Zeichnet unter die ersten beiden eine dritte Ellipse auf den Bildschirm.

Beachten Sie, dass die untere Ellipse genauso groß gezeichnet wird wie erste und der Farbverlauf durch Aufrufen der ResetTransform-Methode der kleineren Größe angepasst wird.

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
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);
}
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.get_Blue(), Color.get_Red(), 0, true);

    // Draw an ellipse to the screen using the LinearGradientBrush.
    e.get_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.get_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.get_Graphics().FillEllipse(myLGBrush, 20, 250, 200, 100);
} //ResetTransformExample

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

LinearGradientBrush-Klasse
LinearGradientBrush-Member
System.Drawing.Drawing2D-Namespace