Here is the code that I'm using. The problem is, that every way that I tried to add lines between the rectangles, it always connected from each point to the mouse position. That's not what I want. What I would like to do, is to be able to have lines connected as I add rectangles. I'm trying to build a selection builder for an editor I am working on. To try this, just click in the picturebox to see what I mean. I removed the bad code, since everything I tried did not work.
Very important - This is not just a visual display that can be saved as an image. Instead, I'm trying to make sure the polygon and lines are saved to a list or array, so they can be reloaded. So it's either arrays or lists. Eventually I want to be able to display several selections at once. What should I do with this?
Very important - This is not just a visual display that can be saved as an image. Instead, I'm trying to make sure the polygon and lines are saved to a list or array, so they can be reloaded. So it's either arrays or lists. Eventually I want to be able to display several selections at once. What should I do with this?
Code:
Public Class Form1
Private p_point As New List(Of Point)
Private m_pos As New Point
Private i As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Screen_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Screen.MouseClick
Dim p As New Point
p.X = e.X
p.Y = e.Y
p_point.Add(p)
i = True
Screen.Refresh()
End Sub
Private Sub UpdateScreen()
End Sub
Private Sub Screen_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Screen.MouseMove
m_pos.X = e.X
m_pos.Y = e.Y
Screen.Refresh()
End Sub
Private Sub Screen_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Screen.Paint
If i = True Then
For Each _p As Point In p_point
e.Graphics.DrawRectangle(Pens.White, New Rectangle(_p.X, _p.Y, 10, 10))
Next
End If
End Sub
End Class