Pen.DashCap 속성

정의

Pen을 사용하여 그리는 파선을 구성하는 대시의 끝에 사용되는 캡 스타일을 가져오거나 설정합니다.

public:
 property System::Drawing::Drawing2D::DashCap DashCap { System::Drawing::Drawing2D::DashCap get(); void set(System::Drawing::Drawing2D::DashCap value); };
public System.Drawing.Drawing2D.DashCap DashCap { get; set; }
member this.DashCap : System.Drawing.Drawing2D.DashCap with get, set
Public Property DashCap As DashCap

속성 값

DashCap을 사용하여 그리는 파선을 구성하는 대시의 시작과 끝에 사용되는 캡 스타일을 나타내는 Pen 값 중 하나입니다.

예외

지정된 값이 DashCap의 멤버가 아닌 경우

DashCap 클래스에서 반환된 것과 같은 변경 불가능한 PenPens 속성을 설정한 경우

예제

다음 코드 예제에서는 만들기를 보여 줍니다는 및 Pen 설정 DashCap의 효과 , DashPattern, 및 SmoothingMode 속성입니다.

이 예제는 Windows Forms 사용하도록 설계되었습니다. 폼에 코드를 붙여넣고 양식의 Paint 이벤트를 처리할 때 메서드를 호출 ShowPensAndSmoothingMode 하여 로 PaintEventArgs전달 e 합니다.

private:
   void ShowPensAndSmoothingMode( PaintEventArgs^ e )
   {
      // Set the SmoothingMode property to smooth the line.
      e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias;

      // Create a new Pen object.
      Pen^ greenPen = gcnew Pen( Color::Green );

      // Set the width to 6.
      greenPen->Width = 6.0F;

      // Set the DashCap to round.
      greenPen->DashCap = System::Drawing::Drawing2D::DashCap::Round;

      // Create a custom dash pattern.
      array<Single>^temp0 = {4.0F,2.0F,1.0F,3.0F};
      greenPen->DashPattern = temp0;

      // Draw a line.
      e->Graphics->DrawLine( greenPen, 20.0F, 20.0F, 100.0F, 240.0F );

      // Change the SmoothingMode to none.
      e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::None;

      // Draw another line.
      e->Graphics->DrawLine( greenPen, 100.0F, 240.0F, 160.0F, 20.0F );

      // Dispose of the custom pen.
      delete greenPen;
   }
private void ShowPensAndSmoothingMode(PaintEventArgs e)
{

    // Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

    // Create a new Pen object.
    Pen greenPen = new Pen(Color.Green);

    // Set the width to 6.
    greenPen.Width = 6.0F;

    // Set the DashCap to round.
    greenPen.DashCap = System.Drawing.Drawing2D.DashCap.Round;

    // Create a custom dash pattern.
    greenPen.DashPattern = new float[]{4.0F, 2.0F, 1.0F, 3.0F};

    // Draw a line.
    e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F);

    // Change the SmoothingMode to none.
    e.Graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.None;

    // Draw another line.
    e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F);

    // Dispose of the custom pen.
    greenPen.Dispose();
}
Private Sub ShowPensAndSmoothingMode(ByVal e As PaintEventArgs)

    ' Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

    ' Create a new Pen object.
    Dim greenPen As New Pen(Color.Green)

    ' Set the width to 6.
    greenPen.Width = 6.0F

    ' Set the DashCap to round.
    greenPen.DashCap = Drawing2D.DashCap.Round

    ' Create a custom dash pattern.
    greenPen.DashPattern = New Single() {4.0F, 2.0F, 1.0F, 3.0F}

    ' Draw a line.
    e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F)

    ' Change the SmoothingMode to none.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None

    ' Draw another line.
    e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F)

    ' Dispose of the custom pen.
    greenPen.Dispose()
End Sub

설명

에 해당 Alignment 속성이 로 Triangle 설정된 경우 Pen 이 속성을 로 설정Inset하지 마세요.

적용 대상