Pen.SetLineCap(LineCap, LineCap, DashCap) 方法

定义

设置用于确定线帽样式的值,线帽用于结束通过此 Pen 绘制的直线。

public:
 void SetLineCap(System::Drawing::Drawing2D::LineCap startCap, System::Drawing::Drawing2D::LineCap endCap, System::Drawing::Drawing2D::DashCap dashCap);
public void SetLineCap (System.Drawing.Drawing2D.LineCap startCap, System.Drawing.Drawing2D.LineCap endCap, System.Drawing.Drawing2D.DashCap dashCap);
member this.SetLineCap : System.Drawing.Drawing2D.LineCap * System.Drawing.Drawing2D.LineCap * System.Drawing.Drawing2D.DashCap -> unit
Public Sub SetLineCap (startCap As LineCap, endCap As LineCap, dashCap As DashCap)

参数

startCap
LineCap

一个 LineCap,表示要在通过此 Pen 绘制的直线起点使用的线帽样式。

endCap
LineCap

一个 LineCap,表示要在通过此 Pen 绘制的直线终点使用的线帽样式。

dashCap
DashCap

一个 LineCap,表示要在通过此 Pen 绘制的虚线起点或终点使用的线帽样式。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 代码创建 , Pen 并将其设置为在行开头绘制箭头定位点帽:

public:
   void SetLineCap_Example( PaintEventArgs^ e )
   {
      
      // Create a Pen object with a dash pattern.
      Pen^ capPen = gcnew Pen( Color::Black,5.0f );
      capPen->DashStyle = DashStyle::Dash;
      
      // Set the start and end caps for capPen.
      capPen->SetLineCap( LineCap::ArrowAnchor, LineCap::Flat, DashCap::Flat );
      
      // Draw a line with capPen.
      e->Graphics->DrawLine( capPen, 10, 10, 200, 10 );
   }
public void SetLineCap_Example(PaintEventArgs e)
{
             
    // Create a Pen object with a dash pattern.
    Pen capPen = new Pen(Color.Black, 5);
    capPen.DashStyle = DashStyle.Dash;
             
    // Set the start and end caps for capPen.
    capPen.SetLineCap(LineCap.ArrowAnchor, LineCap.Flat, DashCap.Flat);
             
    // Draw a line with capPen.
    e.Graphics.DrawLine(capPen, 10, 10, 200, 10);
}
Public Sub SetLineCap_Example(ByVal e As PaintEventArgs)

    ' Create a Pen object with a dash pattern.
    Dim capPen As New Pen(Color.Black, 5)
    capPen.DashStyle = DashStyle.Dash

    ' Set the start and end caps for capPen.
    capPen.SetLineCap(LineCap.ArrowAnchor, LineCap.Flat, DashCap.Flat)

    ' Draw a line with capPen.
    e.Graphics.DrawLine(capPen, 10, 10, 200, 10)
End Sub

适用于