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 Forms 使用,而且需要 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

適用於