Graphics Path - which member is mouse pointer inside, if any

  • Thread starter Thread starter Devon_Nullman
  • Start date Start date
D

Devon_Nullman

Guest
This code:

Option Strict On
Imports System.Drawing
Public Class Form1
Private GPath As New Drawing2D.GraphicsPath
Private ThickPen As New System.Drawing.Pen(Color.Black, 3)

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawPath(ThickPen, GPath)
End Sub

Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
TextBox1.Text = GPath.IsVisible(e.X, e.Y).ToString
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
GPath.AddEllipse(10, 10, 50, 50)
GPath.AddEllipse(110, 10, 50, 50)
GPath.AddEllipse(210, 10, 50, 50)

GPath.AddEllipse(10, 110, 50, 50)
GPath.AddEllipse(110, 110, 50, 50)
GPath.AddEllipse(210, 110, 50, 50)

GPath.AddEllipse(10, 210, 50, 50)
GPath.AddEllipse(110, 210, 50, 50)
GPath.AddEllipse(210, 210, 50, 50)
End Sub
End Class

Produces this:
1447131.jpg
As I move the mouse, the TextBox tells me if the pointer is inside any of the 9 circles. What I want to do is to determine which of the circles the pointer is inside of, assuming that it is inside one. Is this possible ?

Continue reading...
 
Back
Top