TextureBrush.Clone 方法

定义

创建此 TextureBrush 对象的一个精确副本。

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

返回

此方法创建的作为 TextureBrush 对象转换的 Object 对象。

示例

下面的示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 该代码创建一个 TextureBrush 对象和该纹理画笔的精确副本,然后使用该副本填充屏幕上的矩形。

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

适用于