I
ibiza
Hi all,
I use VB.NET (C# would do the same) and GDI+ to draw on a form. I'd
like to know if it is possible to set the z-order when we draw
something...Let's consider that simplified case :
' Assume there is an 'items' array that contains information from which
I draw
' Also assume I have a valid Graphics object named g
Dim pts(5) As Point
Dim i as integer
For i = 0 to 4
g.DrawLine(Pens.LightGray, items(i).x1, items(i).y1, items(i).x2,
items(i).y2)
pts(i) = new Point(items(i).ptX, items(i).ptY)
Next
g.FillPolygon(Brushes.LightGreen, pts)
Now, the thing is, I'd like to draw the polygon UNDER the lines, which
is not the case right now, because it is rendered after...the only way
I find to do this right now is to do the same loop from 0 to 4 before
the current one, ONLY to construct the pts array...then after, draw the
polygon (so it's before the lines), and then loop within the current
For we see here, to draw lines...Of course, it's really ugly to make 2
loops just for that!! Is there a way I can draw the polygon under the
lines, while having only one loop, as in the current scenario?? Kind of
a z-order to set? How :S
thanks for all your help in advance!
I use VB.NET (C# would do the same) and GDI+ to draw on a form. I'd
like to know if it is possible to set the z-order when we draw
something...Let's consider that simplified case :
' Assume there is an 'items' array that contains information from which
I draw
' Also assume I have a valid Graphics object named g
Dim pts(5) As Point
Dim i as integer
For i = 0 to 4
g.DrawLine(Pens.LightGray, items(i).x1, items(i).y1, items(i).x2,
items(i).y2)
pts(i) = new Point(items(i).ptX, items(i).ptY)
Next
g.FillPolygon(Brushes.LightGreen, pts)
Now, the thing is, I'd like to draw the polygon UNDER the lines, which
is not the case right now, because it is rendered after...the only way
I find to do this right now is to do the same loop from 0 to 4 before
the current one, ONLY to construct the pts array...then after, draw the
polygon (so it's before the lines), and then loop within the current
For we see here, to draw lines...Of course, it's really ugly to make 2
loops just for that!! Is there a way I can draw the polygon under the
lines, while having only one loop, as in the current scenario?? Kind of
a z-order to set? How :S
thanks for all your help in advance!