you could use graphicspaths with a dictionary(of graphicspath, integer) like this:
edit: the MouseMove code was just there for my testing purposes...Code:Public Class Form1 Dim sections As New Dictionary(Of Drawing2D.GraphicsPath, Integer) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim pts As New List(Of PointF)() 's20 big pts.Add(New PointF(224, 75)) pts.Add(New PointF(232, 131)) pts.Add(New PointF(267, 131)) pts.Add(New PointF(276, 75)) pts.Add(New PointF(224, 75)) Dim gp As New Drawing2D.GraphicsPath gp.AddPolygon(pts.ToArray) sections.Add(gp, 20) End Sub Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown Dim kvp As KeyValuePair(Of Drawing2D.GraphicsPath, Integer) = sections.FirstOrDefault(Function(de) de.Key.IsVisible(e.Location)) MsgBox(kvp.Value) End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove Dim kvp As KeyValuePair(Of Drawing2D.GraphicsPath, Integer) = sections.FirstOrDefault(Function(de) de.Key.IsVisible(e.Location)) Me.Text = (kvp.Value = 20).ToString End Sub End Class




Reply With Quote