Hi Stoyan,
During some testing we noticed that the X- and Y- coordinates of the child nodes aren't set properly, which is having some weird side-effects to the nesting of our new operator nodes. At first we didn't notice this because visually, nothing seemed to be wrong.
For example:
If my first node would have the following Bounds: 232.5, 172.5, 100, 100 and my second node, which is nested in the first node, would have the following Bounds: 252.5, 232.5, 100, 100 nothing seems to be wrong. Now if i would move the node with the nested node, lets say, to the upper part of the diagram field, my bounds would look something like this: 1st node: 232.5, 67.5, 100, 100 and 2nd: 252.5, 232.5, 100, 100. This would indicate that the nested node is still in its old location, according to its coordinates, but visually it isn't.
We tried fixing the problem by overriding the MindFusion CompleteModify() method, which in turn will call our own method, called UpdateModelBounds() and eventually calling the method in the class NodeControl called UpdateModelBoundsOnMove. The code from the child-class will handle the node specific updates.
Code in Super:
protected override void CompleteModify(Point end, InteractionState ist)
{
UpdateModelBounds();
AlignToNearestPoint(end, ist);
if (NodeToAttachTo != null)
{
AttachNodes(NodeToAttachTo, this);
NodeToAttachTo = null;
}
}
public virtual void UpdateModelBounds()
{
if (this.Tag != null)
{
BRNodeControl.UpdateModelBoundsOnMove((int)this.Tag, Bounds);
if (ConnectedNode != null)
BRNodeControl.UpdateModelBoundsOnMove((int)ConnectedNode.Tag, ConnectedNode.Bounds);
}
}
Code in NodeControl (Controllerclass)
public static void UpdateModelBoundsOnMove(int movedNodeID, Rect newBounds)
{
BRNodeModel movedNodeModel = models.FirstOrDefault(x => (int)x.Tag == movedNodeID);
if (movedNodeModel != null)
{
movedNodeModel.SetBounds(newBounds, false, true);
}
else
throw new Exception("Unable to update the bounds of the model!");
}
Code in child class BRTryCatchNode (the E shape)
public override void UpdateModelBounds()
{
base.UpdateModelBounds();
if (this.tryConnectedNode != null)
BRNodeControl.UpdateModelBoundsOnMove((int)tryConnectedNode.Tag, tryConnectedNode.Bounds);
if (this.catchConnectedNode != null)
BRNodeControl.UpdateModelBoundsOnMove((int)catchConnectedNode.Tag, catchConnectedNode.Bounds);
}
This seems to work for 1 node with 1 nested node, but if i would nest a new node in the 1st nested node, it doesn't get updated.
Could you give some words of advice?
Thanks in advance.
Greets,
Sander