LinearGradientBrush.Clone メソッド

定義

この LinearGradientBrush の同一コピーを作成します。

public:
 override System::Object ^ Clone();
public override object Clone ();
override this.Clone : unit -> obj
Public Overrides Function Clone () As Object

戻り値

このメソッドが作成し、オブジェクトとしてキャストされる LinearGradientBrush

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • 新しい LinearGradientBrush を作成します。

  • このブラシを使用して、画面に楕円を描画します。

  • (clonedLGBrush) を複製しますLinearGradientBrush

  • 複製したブラシを使用して、最初の楕円のすぐ下の画面に楕円を描画します。

private:
   void CloneExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      int x = 20,y = 20,h = 100,w = 200;
      Rectangle myRect = Rectangle(x,y,w,h);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Aquamarine,45.0f,true );

      // Draw an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, x, y, w, h );

      // Clone the LinearGradientBrush.
      LinearGradientBrush^ clonedLGBrush = dynamic_cast<LinearGradientBrush^>(myLGBrush->Clone());

      // Justify the left edge of the gradient with the
      // left edge of the ellipse.
      clonedLGBrush->TranslateTransform(  -100.0f, 0.0f );

      // Draw a second ellipse to the screen using the cloned HBrush.
      y = 150;
      e->Graphics->FillEllipse( clonedLGBrush, x, y, w, h );
   }
private void CloneExample(PaintEventArgs e)
{
             
    // Create a LinearGradientBrush.
    int x=20, y=20, h=100, w=200;
    Rectangle myRect = new Rectangle(x, y, w, h);
    LinearGradientBrush myLGBrush = new LinearGradientBrush(
        myRect, Color.Blue, Color.Aquamarine, 45.0f, true);

    // Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, x, y, w, h);
             
    // Clone the LinearGradientBrush.
    LinearGradientBrush clonedLGBrush =
        (LinearGradientBrush)myLGBrush.Clone();
             
    // Justify the left edge of the gradient with the
    // left edge of the ellipse.
    clonedLGBrush.TranslateTransform(-100.0f, 0.0f);
             
    // Draw a second ellipse to the screen using the cloned HBrush.
    y=150;
    e.Graphics.FillEllipse(clonedLGBrush, x, y, w, h);
}
Public Sub CloneExample(ByVal e As PaintEventArgs)

    ' Create a LinearGradientBrush.
    Dim x As Integer = 20
    Dim y As Integer = 20
    Dim h As Integer = 100
    Dim w As Integer = 200
    Dim myRect As New Rectangle(x, y, w, h)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Aquamarine, 45.0F, True)

    ' Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, x, y, w, h)

    ' Clone the LinearGradientBrush.
    Dim clonedLGBrush As LinearGradientBrush = _
    CType(myLGBrush.Clone(), LinearGradientBrush)

    ' Justify the left edge of the gradient with the left edge of the
    ' ellipse.
    clonedLGBrush.TranslateTransform(-100.0F, 0.0F)

    ' Draw a second ellipse to the screen using the cloned HBrush.
    y = 150
    e.Graphics.FillEllipse(clonedLGBrush, x, y, w, h)
End Sub

適用対象