Nevron Forum

Determine if a Line Touch or Cross a Shape

https://www.nevron.com/Forum/Topic4957.aspx

By Volvick Derose 1 - Wednesday, March 2, 2011

Assume that I have line one or rectangle one in the drawing area, I want to know if it is possible to determine when a user draws a line or any shape if the shape touches or crosses line one or rectangle one.

is it possible to determine that?
By Nevron Support - Tuesday, March 8, 2011

Hi,

You can check whether a given line segment intersects the bounds of a shape by using the following piece of code:

 

NShape shape = null;

NLineSegmentF lineSegment = new NLineSegmentF(0, 0, 100, 100);

if (lineSegment.IntersectsWith(shape.Bounds))

{

      // The line segment intersects the shape bounds

}

 

Similarly, you can test for rectangle intersections – just use the corresponding methods of the NRectangleF class.

By Volvick Derose 1 - Thursday, March 17, 2011

I would like that to be hooked to an event. For instance, assume that the user draws a rectangle first in the drawing view, then when the user draws a line in the drawing view, if the line crosses the rectangle, then I fire a message. I did not find any event that I can use to check when a specific shape is drawn on the drawing view. The only thing I can find is NodeBoundsChanging