次の方法で共有


CustomLineCap.SetStrokeCaps メソッド

直線の開始と終了に使用する、このカスタム キャップを構成するキャップを設定します。

Public Sub SetStrokeCaps( _
   ByVal startCap As LineCap, _   ByVal endCap As LineCap _)
[C#]
public void SetStrokeCaps(LineCapstartCap,LineCapendCap);
[C++]
public: void SetStrokeCaps(LineCapstartCap,LineCapendCap);
[JScript]
public function SetStrokeCaps(
   startCap : LineCap,endCap : LineCap);

パラメータ

  • startCap
    このキャップ内で直線の開始点で使用される LineCap 列挙体。
  • endCap
    このキャップ内で直線の終了点に使用される LineCap 列挙体。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • GraphicsPath オブジェクトを使用して、カスタム ライン キャップ capPath を作成します。
  • capPath にストローク キャップ (三角形および円形) を追加し、 custCap を作成します。
  • 新しい直線のライン キャップとして custCap を使用するペンを作成します。

[Visual Basic, C#] ライン キャップは (custCap で作成したとおり) 矢印になり、矢印の両端はストローク キャップが適用されて、一方が三角形、もう一方が円形になります。

 
Public Sub SetStrokeCapsExample(e As PaintEventArgs)
' Create a Path and add two lines to it,
' forming a custom line cap.
Dim points As Point() =  {New Point(- 2, - 2), New Point(0, 0), _
New Point(2, - 2)}
Dim capPath As New GraphicsPath()
capPath.AddLines(points)
' Create a CustomLineCap object.
Dim custCap As New CustomLineCap(Nothing, capPath)
' Set the start and end caps for custCap.
custCap.SetStrokeCaps(LineCap.Triangle, LineCap.Round)
' Create a Pen object, assign custCap as the start and end caps,
' and draw a line to the screen.
Dim strokeCapPen As New Pen(Color.Black, 15)
strokeCapPen.CustomStartCap = custCap
strokeCapPen.CustomEndCap = custCap
e.Graphics.DrawLine(strokeCapPen, New Point(100, 100), _
New Point(300, 100))
End Sub
        
[C#] 
private void SetStrokeCapsExample(PaintEventArgs e)
{
// Create a Path and add two lines to it,
// forming a custom line cap.
Point[] points =
{
new Point(-2, -2),
new Point(0, 0),
new Point(2, -2)
};
GraphicsPath capPath = new GraphicsPath();
capPath.AddLines(points);
// Create a CustomLineCap object.
CustomLineCap custCap = new CustomLineCap(null, capPath);
// Set the start and end caps for custCap.
custCap.SetStrokeCaps(LineCap.Triangle, LineCap.Round);
// Create a Pen object, assign custCap as the start and end caps, and draw a line to the screen.
Pen strokeCapPen = new Pen(Color.Black, 15);
strokeCapPen.CustomStartCap = custCap;
strokeCapPen.CustomEndCap = custCap;
e.Graphics.DrawLine(strokeCapPen, new Point(100, 100), new Point(300, 100));
} // SetStrokeCapsExample
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

CustomLineCap クラス | CustomLineCap メンバ | System.Drawing.Drawing2D 名前空間