We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Intersection in Polyline tool

Thread ID:





67644 Aug 27,2007 09:26 AM UTC Aug 30,2007 08:39 AM UTC WinForms 2
Tags: Diagram
Elia Chkayra
Asked On August 27, 2007 09:26 AM UTC

hello again,

I am using the polyline tools to draw shapes, i have also created a right click event wich allows me to connect the first and the last polyline point.
My problem is that : i want to give an error message if the user draws intersected lines.
If any line on the shape intersects with another line on the same shape and also if the line that connects the first point with the last point, intersects with any other line in the shape that the user drawed( when the right click event occurs), i want to raise an error message and delete the created node.
i will attach a zip file wich will show exactly what i want


J.Nagarajan [Syncfusion]
Replied On August 29, 2007 04:17 AM UTC

Hi Elia,

Sorry for the delay in getting back to you. We are currently working on this issue. We will update you with in a couple of days.

Thanks for your patience.


Meera Fathima [Syncfusion]
Replied On August 30, 2007 08:39 AM UTC

Hi Elia,

You can restrict the polyline node from being drawn if any line on the shape intersects with another line on the same shape by customizing the Polyline Tool class and

overriding the ProcessMouseUp() method with the desired code implementation.

The node will get created within the ProcessMouseUp() method and so you need to check whether any of line segments of the polyline node intersects with each other

before adding the node. You can get the each line segment of the polyline by using the PolyLineBase.Points collection.

Below is the sample code snippets that shows the above details.

public override Tool ProcessMouseUp(MouseEventArgs evtArgs)
Tool toolToReturn = this;
this.CurrentPoint = new Point(evtArgs.X, evtArgs.Y);
this.CanRender = false;
if (this.InAction)
// if MouseButtons.Left --> add current point to shape Points
if (evtArgs.Button == MouseButtons.Left)
// if MouseButtons.Right --> create polyline derived node
else if (evtArgs.Button == MouseButtons.Right)
// Check whether intersection
if (!IsIntersects(this.Points))
return toolToReturn;

// Check for intersection.
private bool IsIntersects(PointF[] points)
bool success = false;
if (points.Length > 0)
for (int i = 0; i < points.Length - 1; i++)
Line line1 = new Line(points[i], points[i + 1]);
for (int j = 1; j < points.Length - 1; j++)
Line line2 = new Line(points[j], points[j + 1]);
// Add code here to find whether two lines are intersected.
// If intersects set success = true , false otherwise.

return success;

Best Regards,

Syncfusion, Inc.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon