Hi Sandro,
The best way to forbid a shape from dropping on a specific area of the grid is to use the NodeBoundsChanging event of the drawing document’s event sink service:
document.EventSinkService.NodeBoundsChanging += new NodeBoundsCancelEventHandler(OnNodeBoundsChanging);
The event is cancelable, so you just have to assign true to the Cancel property of the supplied event args to cancel the shape to move to its new location. Here’s a simple example for the NodeBoundsChanging event handler:
private void OnNodeBoundsChanging(NNodeBoundsCancelEventArgs args)
{
// The following will be an example area that is not allowed for shapes
NRectangleF forbiddenArea = new NRectangleF(100, 100, 300, 300);
// Get the shape which bounds has changed
NShape shape = args.Node as NShape;
if (shape == null)
return;
// Check if the shape is dropped on an allowed location
NRectangleF bounds = args.NewBounds;
if (forbiddenArea.IntersectsWith(bounds))
{
// Cancel the the dragging of the shape
args.Cancel = true;
}
}
Best Regards,
Nevron Support Team