dotnet graphics : how to draw a line with a DashPattern beginning with a space ?

Pen.DashPattern is "an array of real numbers that specifies the lengths of alternating dashes and spaces in dashed lines" (quoted fom MSDN). The first value in this array always corresponds to a dash. It's ok if the line begins with a dash but i need to draw lines beginning with a space (perhaps a bit strange but it can occur in some Autocad linestyles).

To do that, i added a 'virtual' dash at the beginning of the dashPattern, with a a very small value : for example DashPattern = {.00001, 10,5,10} : .00001 is an invisible dash, followed by a 10 pixels space, then a 5 pixels dash, and so on.
It works if the line is drawed with a one pixel width : the first dash is invisible; but if width > 1 pixel, the first dash is clearly visible.
I know that the effective dash length is = (value from DashPattern) x pen.Width , so i expected that for a 2 pixels width, (00001 x 2) would still give an invisible dot, but clearly on screen this dot has 2 pixels width.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use pen.DashOffset equal to first value of DashPattern.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JP_GobletAuthor Commented:
simple but effective solution ; writing dashOffset = dashPattern[0] didn't work at first time, the first dash was still visible. But after some thinking i guess that the very small value i used for the 1st dash (such as 0.000001F) was non-sense, since the values in DashPattern and DashOffset are floats and not doubles ; i don't know the precision of floats, but i presume that 0.000001F was rounded to 0 pixel (which was interpreted  somehow in GDI code as 1 pixel ?).

Anyway with your solution i don't need to use small values, since the the first dash will be 'eaten' by the dashOffset of same value; i tried for example dashOffset = dashPattern[0]  = 1, no problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.