TextureBrush 類別

定義

TextureBrush 類別的每一個屬性都是 Brush 物件,這個物件會使用影像來填滿形狀的內部。Each property of the TextureBrush class is a Brush object that uses an image to fill the interior of a shape. 此類別無法被繼承。This class cannot be inherited.

public ref class TextureBrush sealed : System::Drawing::Brush
public sealed class TextureBrush : System.Drawing.Brush
type TextureBrush = class
    inherit Brush
Public NotInheritable Class TextureBrush
Inherits Brush
繼承

範例

下列程式碼範例示範如何使用 FromFile 方法來取得新的點陣圖。The following code example demonstrates how to obtain a new bitmap using the FromFile method. 它也會示範 TextureBrushIt also demonstrates a TextureBrush.

這個範例是設計來與 Windows Forms 搭配使用。This example is designed to be used with Windows Forms. 建立一個表單,其中包含名為 Button2 的按鈕。Create a form containing a button named Button2. 將程式碼貼入表單,並將 Button2_Click 方法與按鈕的 Click 事件產生關聯。Paste the code into the form and associate the Button2_Click method with the button's Click event.

private:
   void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      try
      {
         Bitmap^ image1 = dynamic_cast<Bitmap^>(Image::FromFile( "C:\\Documents and Settings\\"
         "All Users\\Documents\\My Music\\music.bmp", true ));
         TextureBrush^ texture = gcnew TextureBrush( image1 );
         texture->WrapMode = System::Drawing::Drawing2D::WrapMode::Tile;
         Graphics^ formGraphics = this->CreateGraphics();
         formGraphics->FillEllipse( texture, RectangleF(90.0F,110.0F,100,100) );
         delete formGraphics;
      }
      catch ( System::IO::FileNotFoundException^ ) 
      {
         MessageBox::Show( "There was an error opening the bitmap."
         "Please check the path." );
      }
   }
private void Button2_Click(System.Object sender, System.EventArgs e)
{
    try
    {
        Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" +
            @"All Users\Documents\My Music\music.bmp", true);

        TextureBrush texture = new TextureBrush(image1);
        texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
        Graphics formGraphics = this.CreateGraphics();
        formGraphics.FillEllipse(texture, 
            new RectangleF(90.0F, 110.0F, 100, 100));
        formGraphics.Dispose();

    }
    catch(System.IO.FileNotFoundException)
    {
        MessageBox.Show("There was an error opening the bitmap." +
            "Please check the path.");
    }

}
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click
    Try
        Dim image1 As Bitmap = _
            CType(Image.FromFile("C:\Documents and Settings\" _
            & "All Users\Documents\My Music\music.bmp", True), Bitmap)

        Dim texture As New TextureBrush(image1)
        texture.WrapMode = Drawing2D.WrapMode.Tile
        Dim formGraphics As Graphics = Me.CreateGraphics()
        formGraphics.FillEllipse(texture, _
            New RectangleF(90.0F, 110.0F, 100, 100))
        formGraphics.Dispose()

    Catch ex As System.IO.FileNotFoundException
        MessageBox.Show("There was an error opening the bitmap." _
            & "Please check the path.")
    End Try

End Sub

建構函式

TextureBrush(Image)

初始化使用指定影像的 TextureBrush 物件。Initializes a new TextureBrush object that uses the specified image.

TextureBrush(Image, Rectangle)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和週框。Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, Rectangle, ImageAttributes)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、週框和影像屬性。Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, RectangleF)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和週框。Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, RectangleF, ImageAttributes)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、週框和影像屬性。Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, WrapMode)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和環繞模式。Initializes a new TextureBrush object that uses the specified image and wrap mode.

TextureBrush(Image, WrapMode, Rectangle)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、環繞模式和週框。Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

TextureBrush(Image, WrapMode, RectangleF)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、環繞模式和週框。Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

屬性

Image

取得與這個 Image 物件關聯的 TextureBrush 物件。Gets the Image object associated with this TextureBrush object.

Transform

取得或設定 Matrix 物件的複本,這個複本會為與這個 TextureBrush 物件相關聯的影像定義局部幾何轉換。Gets or sets a copy of the Matrix object that defines a local geometric transformation for the image associated with this TextureBrush object.

WrapMode

取得或設定 WrapMode 列舉型別 (Enumeration),表示這個 TextureBrush 物件的環繞模式。Gets or sets a WrapMode enumeration that indicates the wrap mode for this TextureBrush object.

方法

Clone()

建立這個 TextureBrush 物件的完全相同複本。Creates an exact copy of this TextureBrush object.

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
Dispose()

釋放這個 Brush 物件使用的所有資源。Releases all resources used by this Brush object.

(繼承來源 Brush)
Dispose(Boolean)

釋放 Brush 所使用的 unmanaged 資源並選擇性地釋放 managed 的資源。Releases the unmanaged resources used by the Brush and optionally releases the managed resources.

(繼承來源 Brush)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(繼承來源 MarshalByRefObject)
MultiplyTransform(Matrix)

藉由將指定的 Matrix 物件附加在前面,根據指定的 TextureBrush 物件來乘以代表這個 Matrix 物件之局部幾何轉換的 Matrix 物件。Multiplies the Matrix object that represents the local geometric transformation of this TextureBrush object by the specified Matrix object by prepending the specified Matrix object.

MultiplyTransform(Matrix, MatrixOrder)

依照指定的順序,根據指定的 Matrix 物件來乘以代表這個 TextureBrush 物件之局部幾何轉換的 Matrix 物件。Multiplies the Matrix object that represents the local geometric transformation of this TextureBrush object by the specified Matrix object in the specified order.

ResetTransform()

將此 Transform 物件的 TextureBrush 屬性重設為單位矩陣。Resets the Transform property of this TextureBrush object to identity.

RotateTransform(Single)

根據指定的角度來旋轉此 TextureBrush 物件的局部幾何轉換。Rotates the local geometric transformation of this TextureBrush object by the specified amount. 這個方法會將旋轉附加到轉換之前。This method prepends the rotation to the transformation.

RotateTransform(Single, MatrixOrder)

依照指定的順序,根據指定的量來旋轉此 TextureBrush 物件的局部幾何轉換。Rotates the local geometric transformation of this TextureBrush object by the specified amount in the specified order.

ScaleTransform(Single, Single)

以指定的數量來縮放這個 TextureBrush 物件的局部幾何轉換。Scales the local geometric transformation of this TextureBrush object by the specified amounts. 這個方法會將縮放矩陣附加到轉換之前。This method prepends the scaling matrix to the transformation.

ScaleTransform(Single, Single, MatrixOrder)

依照指定的順序,根據指定的量來縮放此 TextureBrush 物件的局部幾何轉換。Scales the local geometric transformation of this TextureBrush object by the specified amounts in the specified order.

SetNativeBrush(IntPtr)

在衍生類別中,設定 GDI+GDI+ 筆刷物件的參考。In a derived class, sets a reference to a GDI+GDI+ brush object.

(繼承來源 Brush)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
TranslateTransform(Single, Single)

根據指定的維度來轉譯此 TextureBrush 物件的局部幾何轉換。Translates the local geometric transformation of this TextureBrush object by the specified dimensions. 這個方法會將轉譯附加到轉換之前。This method prepends the translation to the transformation.

TranslateTransform(Single, Single, MatrixOrder)

依照指定的順序,根據指定的維度來轉換此 TextureBrush物件的局部幾何轉換。Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

適用於