CustomLineCap 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化一個新實例 CustomLineCap ,並以指定的輪廓與填充值。
多載
| 名稱 | Description |
|---|---|
| CustomLineCap(GraphicsPath, GraphicsPath) |
初始化一個新實例 CustomLineCap ,並以指定的輪廓與填充值。 |
| CustomLineCap(GraphicsPath, GraphicsPath, LineCap) |
從指定的既有CustomLineCap枚舉初始化該類別的新實例LineCap,並以指定的輪廓與填充方式。 |
| CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single) |
從指定的既有CustomLineCap列舉初始化類別的新實例LineCap,並包含指定的輪廓、填充與內嵌。 |
CustomLineCap(GraphicsPath, GraphicsPath)
初始化一個新實例 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 事件,並 DrawCaps 從表單 Paint 的事件處理方法呼叫,傳遞 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 無論操作指定為何填充模式,都使用「繞線」的填充模式。
fillPath與strokePath參數不能同時使用。 必須傳遞一個參數為空值。 若兩個參數皆未傳遞空值, fillPath 則會被忽略。 若 strokePath 是 null, fillPath 則應截取負 y 軸。
適用於
CustomLineCap(GraphicsPath, GraphicsPath, LineCap)
從指定的既有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 無論操作指定為何填充模式,都使用「繞線」的填充模式。
fillPath與strokePath參數不能同時使用。 必須傳遞一個參數為空值。 若兩個參數皆未傳遞空值, fillPath 則會被忽略。 若 strokePath 是 null, fillPath 則應截取負 y 軸。
適用於
CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)
從指定的既有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 無論操作指定為何填充模式,都使用「繞線」的填充模式。
fillPath與strokePath參數不能同時使用。 必須傳遞一個參數為空值。 若兩個參數皆未傳遞空值, fillPath 則會被忽略。 若 strokePath 是 null, fillPath 則應截取負 y 軸。