A typical way to make a multi-line drawing is to store each line as Drawing2D.GraphicsPath, adding it to a List(Of GraphicsPath) to represent the whole drawing. You can use GraphicsPath.IsOutlineVisible for hit testing on a path with a margin of error. For example to check if a given point is within 2 pixels either side of the path, you could write:
Code:
Dim hit As Boolean
Dim p As Point = PictureBox1.PointToClient(MousePosition)
Using pn As New Pen(Brushes.Black, 5)
hit = myPath.IsOutlineVisible(r.Location, pn)
End Using Since you want to edit individual segments, you could define each segment as a separate GraphicsPath. Then each drawn line could become a List of such segments. I would think about defining separate classes for objects like Drawing, DrawnLine, LineSegment, ArcSegment etc. The data you are currently storing such as length, radius etc. would become properties of the appropriate classes.
Don't worry too much about the amount of data stored: it has to be stored somewhere if you are going to edit it. A collection of paths with 10,000 PointFs isn't all that much to draw on a modern PC. If rendering starts getting too slow you could render everything but the line you are currently drawing or editing to a bitmap, which you then treat as a background image.
Vic
Bookmarks