Intersection in Polyline tool
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
Syncfusion.zip
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
Syncfusion.zip
SIGN IN To post a reply.
2 Replies
J.
J.Nagarajan
Syncfusion Team
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.
Regards,
Nagaraj
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.
Regards,
Nagaraj
MF
Meera Fathima
Syncfusion Team
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)
{
base.ProcessMouseUp(evtArgs);
}
// if MouseButtons.Right --> create polyline derived node
else if (evtArgs.Button == MouseButtons.Right)
{
// Check whether intersection
if (!IsIntersects(this.Points))
{
base.ProcessMouseUp(evtArgs);
}
else
{
this.Controller.UpdateInfo.UpdateRefreshRect(this.WorkRect);
}
}
}
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,
Meera.
Syncfusion, Inc.
http://www.syncfusion.com/
SIGN IN To post a reply.
- 2 Replies
- 3 Participants
-
EC Elia Chkayra
- Aug 27, 2007 09:26 AM UTC
- Aug 30, 2007 08:39 AM UTC