How to HitTest a polygonal region

Platform: WinForms| Category: Hit Testing
Bool HitTest(PointF[] polygonCorners, PointF mousePosition)
{ 
	GraphicsPath path = new GraphicsPath();
	path.AddLines(polygonCorners);
	Region region = new Region(path);

// Hittest the region to verify if the point is in the rect
	if(region.IsVisible(mousePosition))
		return true;
	else
		return false;
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.