CustomLineCap 构造函数

定义

使用指定的轮廓和填充初始化 CustomLineCap 类的新实例。

重载

CustomLineCap(GraphicsPath, GraphicsPath)

使用指定的轮廓和填充初始化 CustomLineCap 类的新实例。

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

通过指定的轮廓和填充从指定的现有 CustomLineCap 枚举初始化 LineCap 类的新实例。

CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

通过指定的轮廓、填充和嵌入从指定的现有 CustomLineCap 枚举初始化 LineCap 类的新实例。

CustomLineCap(GraphicsPath, GraphicsPath)

Source:
CustomLineCap.cs
Source:
CustomLineCap.cs
Source:
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 窗体中。 处理窗体的 Paint 事件,并从窗体的事件Paint处理方法调用 DrawCaps ,并e作为 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

注解

CustomLineCap 无论为操作指定的填充模式如何,都使用“缠绕”填充模式。

fillPathstrokePath 参数不能同时使用。 必须向一个参数传递 null 值。 如果两个参数均未传递 null 值, fillPath 则 将被忽略。 如果 strokePathnullfillPath 则应截获负 y 轴。

适用于

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

Source:
CustomLineCap.cs
Source:
CustomLineCap.cs
Source:
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)

Source:
CustomLineCap.cs
Source:
CustomLineCap.cs
Source:
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 轴。

适用于