Bonjour,
I try to replace my own routines to draw dash lines with g.LineDash
But g.LineDash is always affected by g.PenSize
A workaround is to divide the dash values by g.PenSize
But with g.DrawLine, dashes don’t start correctly.
And continuous lines drawn with DrawLine are not correctly axed.
The 2 last problems don’t exist with DrawPath.
Example :
Code :
g.LineCap = Graphics.LineCapTypes.■■■■
g.PenSize = 0.5
g.DrawLine(0, 20, me.Width, 20)
g.PenSize = 10
g.DrawLine(20, 20, me.Width/2 - 10, 20) //<= Line is not axed on y = 20
Var mPath As New GraphicsPath
mPath.MoveToPoint(me.Width/2 + 10, 20)
mPath.AddLineToPoint(me.Width - 20, 20)
g.DrawPath(mPath) //<= Line is axed on y = 20
Var dashValue As Double = 20.0
g.PenSize = 1
g.LineDash = Array(dashValue, dashValue) //<= dashValue is affected by PenSize
g.DrawLine(0, 50, me.Width, 50)
g.PenSize = 5
g.DrawLine(0, 60, me.Width, 60)
g.PenSize = 2
g.DrawLine(0, 75, me.Width, 75)
g.PenSize = 1
g.LineDash = Array(dashValue, dashValue) //<= dashValue corrected but not aligned with DrawLine
g.DrawLine(0, 100, me.Width, 100)
g.PenSize = 5
g.LineDash = Array(dashValue / g.PenSize, dashValue / g.PenSize)
g.DrawLine(0, 110, me.Width, 110)
g.PenSize = 2
g.LineDash = Array(dashValue / g.PenSize, dashValue / g.PenSize)
g.DrawLine(0, 125, me.Width, 125)
g.PenSize = 1
g.LineDash = Array(dashValue, dashValue) //<= dashValue corrected AND aligned with DrawPath
Var mPath2 As New GraphicsPath
mPath2.MoveToPoint(0, 150)
mPath2.AddLineToPoint(me.Width, 150)
g.DrawPath(mPath2)
g.PenSize = 5
g.LineDash = Array(dashValue / g.PenSize, dashValue / g.PenSize)
Var mPath3 As New GraphicsPath
mPath3.MoveToPoint(0, 160)
mPath3.AddLineToPoint(me.Width, 160)
g.DrawPath(mPath3)
g.PenSize = 2
g.LineDash = Array(dashValue / g.PenSize, dashValue / g.PenSize)
Var mPath4 As New GraphicsPath
mPath4.MoveToPoint(0, 170)
mPath4.AddLineToPoint(me.Width, 170)
g.DrawPath(mPath4)