Hi Luciano,
Following is a code sample that implements similar behavior:
...
view.MouseMove += new MouseEventHandler(view_MouseMove);
...
void view_MouseMove(object sender, MouseEventArgs e)
{
// create connector tool already activated - do nothing
if (view.Controller.Tools.GetToolByName(NDWFR.ToolCreateConnector).IsActive)
return;
// determine whether there is a port neard the current mouse position.
// this implementation considers near to be 10 pixels
NPointF mouseInClient = new NPointF(e.X, e.Y);
bool hasPortNearMouse = false;
NRectangleF window = view.Window;
foreach (NPort port in document.Descendants(Nevron.Diagram.Filters.NFilters.TypeNPort, -1))
{
NPointF portInClient = view.SceneToDevice.TransformPoint(port.Location);
if (window.Contains(portInClient) == false)
continue;
if (NGeometry2D.PointsDistance(portInClient, mouseInClient) < 10)
{
hasPortNearMouse = true;
break;
}
}
// enable the create connector tool or the pointer tool
if (hasPortNearMouse)
{
view.Controller.Tools.SingleEnableTool(NDWFR.ToolCreateConnector);
}
else
{
string[] toolNames = new string[] {
NDWFR.ToolCreateGuideline,
NDWFR.ToolHandle,
NDWFR.ToolMove,
NDWFR.ToolSelector,
NDWFR.ToolContextMenu,
NDWFR.ToolKeyboard,
NDWFR.ToolInplaceEdit,
NDWFR.ToolMouseEventDelegator
};
view.Controller.Tools.SingleEnableTools(toolNames);
}
}
Best Regards,
Nevron Support Team