Dock nodes

I there,

Is there a way to dock a node on the left or on the right ?
I would like to do something like this :


|MainWindow1|-|X|
| | |
| | _________ |
| | | | |
| O ------> O Node2 | |
| | |
| |
| Node1 | _________ |
| | | | |
| O ------> O Node3 | |
| | |
| |
|
_____ |__________________________|

I tried to set the Location of Node1 to (0,0) but it does not show exactly there, it is offset by something like 10 pixels on the x and y axis. I guess this is because of the automatic scrolling feature. I could start trying to disable all automatic scrolling features, but before i do that and code something GoDiagram might already supports natively, is there a simple way to dock a node while keeping the automatic node positioning for the rest of the graph ?

Also, we would like to keep the ability to pan nodes around while Node1 remains docked to the left.

Thanks for your help.

Moved to GoXam forum.

The ability for users to scroll/pan/zoom makes it hard to guarantee that a node be at a particular position on the screen.

I would guess that if your “Node1” is positioned at (0,0) that there would be some space between the node and the edge of the viewport due to the Diagram.Padding, which defaults to a Thickness of 10 on each side. (That property actually gets transferred to the DiagramPanel.Padding property in the ControlTemplate) Most people want a little margin around their “stuff”, so that the user cannot scroll a node to butt up against a side of the view. However you can allow that by setting Padding=“0” when you initialize the Diagram.

I’m not sure what you mean by the ability to pan nodes around while “Node1” remains positioned against the left side of the view. Users could surely drag “Node2” around, for example. However, if they drag it leftwards to the left of “Node1”, then “Node1” would no longer have the same position in the viewport.

Hi,

Thanks for the quick reply !

“I’m not sure what you mean by the ability to pan nodes around while “Node1” remains positioned against the left side of the view. Users could surely drag “Node2” around, for example. However, if they drag it leftwards to the left of “Node1”, then “Node1” would no longer have the same position in the viewport.”


This is exactly what i want to avoid, Node1 should never move or be re-scaled, no matter where the user move other nodes. Ideally, Node2 and Node3 should collide with Node1, and could not be moved on the left of Node1.

So far the closest i got to that goal was by :

  • Setting go:Part.Movable="False" attached property on Node1.
  • Setting Panel.FixedBounds = new Rect(0, 0, 1024, 768);
The FixedBounds option seems to remove (ignore ?) the padding which is good, and remove the horizontal scrollbar and autoscrolling, which is also good for our scenario. But this brings tree new problems :
  • Scaling with Ctrl+MouseWheel affects all nodes which defeats the illusion of a "docked" Node1. Only Node2 and Node3 should be scalable.
  • By forcing the position of Node1 to (0, 0) we might move it on top of a node which was already there because of the initial TreeLayout calculation.
  • By forcing the height of Node1, the first node connected to it, Node2, has a tendency to be positionned "below" Node1, as in, if Node1 has a height of 600px, Node2 is positionned at 700px on the Y axis. I could move it "up" a bit, but i would need to do the same for all other nodes and kind of override the default positionning calculated by the TreeLayout algorithm. I can provide a sample app if required.
Any idea how to address those tree issues ? Thanks for your help :-)

If you want to allow users to drag around nodes, but never with Location.X less than some value, you could set the attached property go:Node.MinLocation. Or more generally you could override DraggingTool.ComputeMove to do whatever you want.

Scaling/zooming necessarily applies to everything in the Diagram. Otherwise the whole notion of coordinates would be seriously confused. However you could allow normal scaling and then readjust the size and location of your root node in a Diagram.Panel.ViewportBoundsChanged event handler, which you normally declare in a Diagram.TemplateApplied event handler.

Or you could just disallow zooming by the user – set Diagram.AllowZoom to false.

Instead of arbitrarily setting the location of the root “Node1” to (0,0) you could set it to whatever location you like and have TreeLayout not move that root node, by setting TreeLayout.Arrangement=“FixedRoots”.

I hope I have understood what you are trying to do.