CustomLineCap 建構函式

定義

使用指定的外框和填滿,初始化 CustomLineCap 類別的新執行個體。

多載

CustomLineCap(GraphicsPath, GraphicsPath)

使用指定的外框和填滿,初始化 CustomLineCap 類別的新執行個體。

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

使用指定的外框和填滿,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。

CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

使用指定的外框、填滿和內凹,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。

CustomLineCap(GraphicsPath, GraphicsPath)

來源:
CustomLineCap.cs
來源:
CustomLineCap.cs
來源:
CustomLineCap.cs

使用指定的外框和填滿,初始化 CustomLineCap 類別的新執行個體。

public:
 CustomLineCap(System::Drawing::Drawing2D::GraphicsPath ^ fillPath, System::Drawing::Drawing2D::GraphicsPath ^ strokePath);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath);
new System.Drawing.Drawing2D.CustomLineCap : System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.GraphicsPath -> System.Drawing.Drawing2D.CustomLineCap
Public Sub New (fillPath As GraphicsPath, strokePath As GraphicsPath)

參數

fillPath
GraphicsPath

定義自訂端點填滿的 GraphicsPath 物件。

strokePath
GraphicsPath

定義自訂端點外框的 GraphicsPath 物件。

範例

下列範例示範如何使用 建 CustomLineCap 構函式。 若要執行此範例,請將程式代碼貼到 Windows Form 中。 處理表單Paint的事件,並從表單的事件Paint處理方法呼叫 DrawCaps ,並傳遞ePaintEventArgs


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

備註

CustomLineCap 不論為作業指定的填滿模式為何,都會使用「彎曲」的填滿模式。

fillPathstrokePath 參數不能同時使用。 一個參數必須傳遞 Null 值。 如果兩個參數都未傳遞 Null 值, fillPath 則會忽略。 如果 為 strokePathnullfillPath 則應該攔截負 Y 軸。

適用於

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

來源:
CustomLineCap.cs
來源:
CustomLineCap.cs
來源:
CustomLineCap.cs

使用指定的外框和填滿,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。

public:
 CustomLineCap(System::Drawing::Drawing2D::GraphicsPath ^ fillPath, System::Drawing::Drawing2D::GraphicsPath ^ strokePath, System::Drawing::Drawing2D::LineCap baseCap);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath, System.Drawing.Drawing2D.LineCap baseCap);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap);
new System.Drawing.Drawing2D.CustomLineCap : System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.LineCap -> System.Drawing.Drawing2D.CustomLineCap
Public Sub New (fillPath As GraphicsPath, strokePath As GraphicsPath, baseCap As LineCap)

參數

fillPath
GraphicsPath

定義自訂端點填滿的 GraphicsPath 物件。

strokePath
GraphicsPath

定義自訂端點外框的 GraphicsPath 物件。

baseCap
LineCap

要建立自訂帽緣的來源直線帽緣。

備註

CustomLineCap 不論為作業指定的填滿模式為何,都會使用「彎曲」的填滿模式。

fillPathstrokePath 參數不能同時使用。 一個參數必須傳遞 Null 值。 如果兩個參數都未傳遞 Null 值, fillPath 則會忽略。 如果 為 strokePathnullfillPath 則應該攔截負 Y 軸。

適用於

CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

來源:
CustomLineCap.cs
來源:
CustomLineCap.cs
來源:
CustomLineCap.cs

使用指定的外框、填滿和內凹,從指定的現有 CustomLineCap 列舉型別初始化 LineCap 類別的新執行個體。

public:
 CustomLineCap(System::Drawing::Drawing2D::GraphicsPath ^ fillPath, System::Drawing::Drawing2D::GraphicsPath ^ strokePath, System::Drawing::Drawing2D::LineCap baseCap, float baseInset);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath, System.Drawing.Drawing2D.LineCap baseCap, float baseInset);
public CustomLineCap (System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap, float baseInset);
new System.Drawing.Drawing2D.CustomLineCap : System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.LineCap * single -> System.Drawing.Drawing2D.CustomLineCap
Public Sub New (fillPath As GraphicsPath, strokePath As GraphicsPath, baseCap As LineCap, baseInset As Single)

參數

fillPath
GraphicsPath

定義自訂端點填滿的 GraphicsPath 物件。

strokePath
GraphicsPath

定義自訂端點外框的 GraphicsPath 物件。

baseCap
LineCap

要建立自訂帽緣的來源直線帽緣。

baseInset
Single

端點和線條之間的距離。

備註

CustomLineCap 不論為作業指定的填滿模式為何,都會使用「彎曲」的填滿模式。

fillPathstrokePath 參數不能同時使用。 一個參數必須傳遞 Null 值。 如果兩個參數都未傳遞 Null 值, fillPath 則會忽略。 如果 為 strokePathnullfillPath 則應該攔截負 Y 軸。

適用於