Layout problems

Hello Walter.
My application contains a diagram with complex nodes. The nodes can contain a single or multiple ports in both node's sides (right ports & left ports).
I use in the "LayeredDigraphLayout" for my diagram layout, after I tryed the TreeLayout & ForcedDiagramLayout too.
I want to share you with some layout problems, but I need to see you some screen pictures for that. I can't find how can I upload the images.
Thanks
Leo

Don’t use the Quick Reply editor on this page – use the full editor on a separate page by clicking on the “Post Reply” button above.

That editor includes an “Insert Image” button in the toolbar.

The “Insert Image” button is exist, but it dosen’t let me upload a new image.
It let me to choose from a image list or write a image url only.

Oh, I see – you’re right. When we upgraded the forum software, we seem to have lost that functionality.

We’ll investigate.

OK, it seems to work now:

Here’s a Gantt chart:

And a PERT chart:

Thanks, Walter.
And my problems:
1. There are times that when I click on a port to expand the next node, the click event doesn't occur at all, and all diagram move to center instead. (see under - 2 pictures).
The diagram moved:
2. I start to expands nodes, and when I try to click on the port (any port) of the fourth generation node, the click event doesn't occur at all (The event doesn't get into the event method code).
But, if I zoom out the diagram, and after that I try to expands nodes, the nodes in the 5th & 6th generation were expanded too.
See in the 2 pictures: I circle the 4th generation node in red:
3. Somtimes when I expand some nodes, The diagram scrolling doesn't matched to the nodes positions (see the picture under):
Thank you
Leo

It doesn’t look as if your questions have anything to do with diagram layout.

Do all of the model changes that you make occur within a transaction?
In other words, does all of your modifying code run between calls to StartTransaction and CommitTransaction?
That would account for most if not all of the odd behavior that you report.

Did you use Buttons to implement those expanding/collapsing controls?

Thank you, I will try your solution, and yes, I use with buttons to implement the expand/collapsed.

I added the transaction to all places that add nodes & links in the code.

That's not change the problems.
Leo.

And in the Button.Click event handlers?
And in any other code that modifies the contents of the diagram?

This is my code structure, after that I added the transaction:
_NEDiagramModel.StartTransaction("ExpandNode");
... Some logic code...
//this method call to AddNode method
this._NEDiagramModel.CreateNodeData(nextNodeFID,
nextNodeType,
new NECableBase[] { port.DataPort.Cable }) as NEJunctionNode;
this._NEDiagramModel.AddLink(port.DataPort.Cable,
from: FromRight ? nextNode : currentNode,
to: FromRight ? currentNode : nextNode,
fromPort: FromRight ? nextPort : port,
toPort: FromRight ? port : nextPort,
link: out link);

... Some logic code...
_NEDiagramModel.CommitTransaction("ExpandNode");
Node[] viewNodes = new Node[] { mainWindow.NEDiagram.Nodes.LastOrDefault() };
Link[] viewLinks = new Link[] { mainWindow.NEDiagram.Links.LastOrDefault() };
mainWindow.NEDiagram.Layout.DoLayout(viewNodes, viewLinks);
return true;

You don’t need to call DoLayout – by default the Diagram.LayoutManager will do that for you.

And that call isn’t doing what you intended anyway – you’re just telling it to do a layout of the one new node and the one new link, without any consideration of any of the other nodes or links in the diagram.

I placed all buttons with a border & path controls, and I changed the event trigger from click to mouseLeftButtonDown.

I deleted the DoLayout method from my code.
Now The first problem doesn't occur, but the other problems was still restored.

So are you saying that the user can still click on “buttons” and there’s no appropriate mouse event handler called?

Regarding the scrollbars not being updated: check on the blue node’s Node.Bounds and the diagram’s Diagram.Panel.DiagramBounds and .ViewportBounds. The DiagramBounds should be big enough to cover the blue node’s Bounds.

Calling CommitTransaction should automatically update the DiagramBounds to cover all of the nodes in the diagram (unless Part.InDiagramBounds is false).

  1. Yes, the user can still click on “buttons” and there’s no appropriate mouse event handler called.
2. I will try to check the bounds according your proposal.

I tryed to set the Diagram width to a large fix size (8000), and when the width is large, the event handler work.

So it seems that the click to expand event handler doesn't call, because the diagram size doesn't grow up enough.

The DiagramBounds will affect the scrollbar and ability to scroll/pan, but it won’t affect whether mouse events are handled.

When the user gets no results when trying to click on a “button”, are they able to do other mouse gestures at or near that point in the diagram?

It seems very mysterious why mouse events are not being delivered.
It’s particularly odd when you were using a regular WPF Button control, since the GoXam code isn’t involved at all.

Might there be some large transparent object in front of the “button”?
Such an object would be intercepting any mouse events.