共用方式為


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

適用於