Bearbeiten

Freigeben über


TextureBrush.Clone Method

Definition

Creates an exact copy of this TextureBrush object.

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

Returns

The TextureBrush object this method creates, cast as an Object object.

Examples

The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code creates a TextureBrush object and an exact copy of that texture brush, and then uses the copy to fill a rectangle on the screen.

public:
   void Clone_Example( PaintEventArgs^ e )
   {
      // Create a TextureBrush object.
      TextureBrush^ tBrush = gcnew TextureBrush( gcnew Bitmap( "texture.jpg" ) );

      // Create an exact copy of tBrush.
      TextureBrush^ cloneBrush = dynamic_cast<TextureBrush^>(tBrush->Clone());

      // Fill a rectangle with cloneBrush.
      e->Graphics->FillRectangle( cloneBrush, 0, 0, 100, 100 );
   }
public void Clone_Example(PaintEventArgs e)
{
             
    // Create a TextureBrush object.
    TextureBrush tBrush = new TextureBrush(new Bitmap("texture.jpg"));
             
    // Create an exact copy of tBrush.
    TextureBrush cloneBrush = (TextureBrush)tBrush.Clone();
             
    // Fill a rectangle with cloneBrush.
    e.Graphics.FillRectangle(cloneBrush, 0, 0, 100, 100);
}
Public Sub Clone_Example(ByVal e As PaintEventArgs)

    ' Create a TextureBrush object.
    Dim tBrush As New TextureBrush(New Bitmap("texture.jpg"))

    ' Create an exact copy of tBrush.
    Dim cloneBrush As TextureBrush = CType(tBrush.Clone(), _
    TextureBrush)

    ' Fill a rectangle with cloneBrush.
    e.Graphics.FillRectangle(cloneBrush, 0, 0, 100, 100)
End Sub

Applies to