Hi,
You will need to set an outline to your custom shape, otherwise the hittesing code is not detecting the node below the mouse cursor. To hide the default outline and fill of the node, you can set the Stroke and Brush properties to a transparent brush, or set the ShapeNode.Transparent property to true:
var customShape = new Shape(new[]
{
new LineTemplate(0, 0, 0, 100),
new LineTemplate(0, 100, 100, 100),
new LineTemplate(100, 100, 100, 0),
new LineTemplate(100, 0, 0, 0)
}, 0, "Smiley");
private void diagram_NodeCreated(object sender, NodeEventArgs e)
{
DiagramNode Nd = e.Node;
if ((Nd as ShapeNode).Shape.Id == "Smiley")
{
SolidColorBrush transparentBrush = new SolidColorBrush(Colors.Transparent);
(Nd as ShapeNode).Stroke = transparentBrush;
(Nd as ShapeNode).Brush = transparentBrush;
// or
// (Nd as ShapeNode).Transparent = true;
}
SolidColorBrush defAnch = new SolidColorBrush(Colors.Red);
Nd.AnchorPattern = new AnchorPattern(new AnchorPoint[]
{
new AnchorPoint(10, 25, true, true, MarkStyle.Rectangle, defAnch),
new AnchorPoint(10, 50, true, true, MarkStyle.Rectangle, defAnch),
new AnchorPoint(10, 75, true, true, MarkStyle.Rectangle, defAnch)
});
}
Regards,
Lyubo