Find if Point lies Inside a polygon

Is there a way to find if a point (x,y) lies inside a polygon?


1 Reply

PM Pandi Murugan A Syncfusion Team August 16, 2011 03:37 AM UTC

Hi JVM,

Thanks for using Syncfusion products.

We suggest you to use Node.Contains(PointF pt) method to achieve your requirement. Here is the code snippet for your reference.

[C#]
diagram1.MouseUp += new MouseEventHandler(diagram1_MouseUp);
void diagram1_MouseUp(object sender, MouseEventArgs e)
{
PointF curPt = diagram1.Controller.ConvertToModelCoordinates(e.Location);
Node node = diagram1.Controller.GetNodeAtPoint(curPt);
if (node != null)
{
if(node.ContainsPoint(curPt)){
MessageBox.Show("Point inside!");
}
}
}


Please let me know if you have any concerns.

Regards,
Pandi Murugan A


Loader.
Up arrow icon