Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PenSetLineCap
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim redPen As New Pen(Color.Red, 6)
Dim bluePen As New Pen(Color.Blue, 7)
Dim greenPen As New Pen(Color.Green, 7)
redPen.Width = 8
redPen.DashStyle = DashStyle.Dash
redPen.SetLineCap(LineCap.DiamondAnchor, LineCap.ArrowAnchor, DashCap.Flat)
greenPen.DashStyle = DashStyle.DashDotDot
greenPen.StartCap = LineCap.Triangle
greenPen.EndCap = LineCap.Triangle
greenPen.DashCap = DashCap.Triangle
greenPen.DashStyle = DashStyle.Dot
greenPen.DashOffset = 3.4F
bluePen.StartCap = LineCap.Square
bluePen.EndCap = LineCap.SquareAnchor
greenPen.SetLineCap(LineCap.RoundAnchor, LineCap.Square, DashCap.Round)
g.DrawLine(redPen, New Point(20, 50), New Point(150, 50))
g.DrawLine(greenPen, New Point(30, 80), New Point(200, 80))
g.DrawLine(bluePen, New Point(30, 120), New Point(250, 120))
redPen.Dispose()
greenPen.Dispose()
greenPen.Dispose()
g.Dispose()
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
|