CustomLineCap 類別

定義

封裝自訂的使用者定義線條端點。Encapsulates a custom user-defined line cap.

public ref class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
type CustomLineCap = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
Public Class CustomLineCap
Inherits MarshalByRefObject
Implements ICloneable, IDisposable
繼承
CustomLineCap
衍生
實作

範例

下列範例將示範如何使用 CustomLineCap 類別。The following example demonstrates how to use the CustomLineCap class. 若要執行此範例,請將程式碼貼到 Windows Form 中。To run this example paste, the code into a Windows Form. 處理窗Paint體的事件,並DrawCaps從表單的Paint事件處理方法呼叫,傳遞ePaintEventArgsHandle the form's Paint event and call DrawCaps from the form's Paint event-handling method, passing e as PaintEventArgs.


protected void DrawCaps(PaintEventArgs e)
{
    GraphicsPath hPath = new GraphicsPath();

    // Create the outline for our custom end cap.
    hPath.AddLine(new Point(0, 0), new Point(0, 5));
    hPath.AddLine(new Point(0, 5), new Point(5, 1));
    hPath.AddLine(new Point(5, 1), new Point(3, 1));

    // Construct the hook-shaped end cap.
    CustomLineCap HookCap = new CustomLineCap(null, hPath);

    // Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round);

    // Create a pen and set end custom start and end
    // caps to the hook cap.
    Pen customCapPen = new Pen(Color.Black, 5);
    customCapPen.CustomStartCap = HookCap;
    customCapPen.CustomEndCap = HookCap;

    // Create a second pen using the start and end caps from
    // the hook cap.
    Pen capPen = new Pen(Color.Red, 10);
    LineCap startCap;
    LineCap endCap;
    HookCap.GetStrokeCaps(out startCap, out endCap);
    capPen.StartCap = startCap;
    capPen.EndCap = endCap;

    // Create a line to draw.
    Point[] points = { new Point(100, 100), new Point(200, 50), 
        new Point(250, 300) };

    // Draw the lines.
    e.Graphics.DrawLines(capPen, points);
    e.Graphics.DrawLines(customCapPen, points);

}
Protected Sub DrawCaps(ByVal e As PaintEventArgs)
    Dim hPath As New GraphicsPath()

    ' Create the outline for our custom end cap.
    hPath.AddLine(New Point(0, 0), New Point(0, 5))
    hPath.AddLine(New Point(0, 5), New Point(5, 1))
    hPath.AddLine(New Point(5, 1), New Point(3, 1))

    ' Construct the hook-shaped end cap.
    Dim HookCap As New CustomLineCap(Nothing, hPath)

    ' Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round)

    ' Create a pen and set end custom start and end
    ' caps to the hook cap.
    Dim customCapPen As New Pen(Color.Black, 5)
    customCapPen.CustomStartCap = HookCap
    customCapPen.CustomEndCap = HookCap

    ' Create a second pen using the start and end caps from
    ' the hook cap.
    Dim capPen As New Pen(Color.Red, 10)
    Dim startCap As LineCap
    Dim endCap As LineCap
    HookCap.GetStrokeCaps(startCap, endCap)
    capPen.StartCap = startCap
    capPen.EndCap = endCap

    ' Create a line to draw.
    Dim points As Point() = {New Point(100, 100), New Point(200, 50), _
        New Point(250, 300)}

    ' Draw the lines.
    e.Graphics.DrawLines(capPen, points)
    e.Graphics.DrawLines(customCapPen, points)

End Sub

備註

行尾大寫會用於以 gdi + Pen物件繪製的線條或曲線的開頭和結尾。Line caps are used at the beginnings and ends of lines or curves drawn by GDI+ Pen objects. GDI + 支援數個預先定義的端點樣式,也可讓使用者定義自己的端點樣式。GDI+ supports several predefined cap styles, and also allows users to define their own cap styles. 這個類別是用來建立自訂的端點樣式。This class is used to create custom cap styles.

建構函式

CustomLineCap(GraphicsPath, GraphicsPath)

使用指定的外框和填滿,初始化 CustomLineCap 類別的新執行個體。Initializes a new instance of the CustomLineCap class with the specified outline and fill.

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

使用指定的外框和填滿,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline and fill.

CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

使用指定的外框、填滿和內凹,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline, fill, and inset.

屬性

BaseCap

取得或設定這個 LineCap 所根據的 CustomLineCap 列舉型別。Gets or sets the LineCap enumeration on which this CustomLineCap is based.

BaseInset

取得或設定端點和線條之間的距離。Gets or sets the distance between the cap and the line.

StrokeJoin

取得或設定判斷組成這個 LineJoin 物件的線條如何聯結 (Join) 的 CustomLineCap 列舉型別。Gets or sets the LineJoin enumeration that determines how lines that compose this CustomLineCap object are joined.

WidthScale

取得或設定縮放與 CustomLineCap 物件寬度相關的這個 Pen 類別物件的數量。Gets or sets the amount by which to scale this CustomLineCap Class object with respect to the width of the Pen object.

方法

Clone()

建立這個 CustomLineCap 的完全相同複本。Creates an exact copy of this CustomLineCap.

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()

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

Dispose(Boolean)

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

Equals(Object)

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

(繼承來源 Object)
Finalize()

在記憶體回收 (GC) 回收 CustomLineCap 前,允許 CustomLineCap 嘗試釋放資源並執行其他清除作業。Allows an CustomLineCap to attempt to free resources and perform other cleanup operations before the CustomLineCap is reclaimed by garbage collection.

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)
GetStrokeCaps(LineCap, LineCap)

取得用來起始和結束組成這個自訂端點線條的端點。Gets the caps used to start and end lines that make up this custom cap.

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 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

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

(繼承來源 MarshalByRefObject)
SetStrokeCaps(LineCap, LineCap)

設定用來起始和結束組成這個自訂端點線條的端點。Sets the caps used to start and end lines that make up this custom cap.

ToString()

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

(繼承來源 Object)

適用於