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;
}