I have a case where I have created several GoDiagram nodes in the GoDiagram control (int top-down node order). It is important to mention that the GoDiagram control is Fully docked in a Form and the Form is maximized (full screen). In this state the layout of the GoDiagram nodes (their color, shape, position…) is saved in the backend. [Image1]
And then the form is resized to some small size (e.g. 200x200) and all
nodes are deleted and afterwards preloaded from the saved layout.
Now the problem occurs. [Image2] As you can see some nodes are located in the upper left corner and are out of visual scope. And if I start to increase the size of the form and when I reach the size in which all nodes are enclosed, then the layout of the nodes goes to the normal state…
Is this a bug or can be fixed with some settings of the GoDiagram?
I don’t use any AutoLayout …
All nodes that are not visible in the resized (small) window are wrong. As I increase the size of the window, links that lead to the upper left corner start to disappear one by one and not visible nodes start to be shown on their corresponding position with all their links.
I suppose it has to do something with the stored locations of the nodes. Maybe the problem is that when the window is small, the locations of the nodes that were stored when the window was maximized, doesn’t exist in this small window, and they are shown as negative in the upper left corner… And when the window is large enough to enclose a node, then this node is shown correctly…
That’s pretty weird. The only explanation is that you are making changes to the view’s GoDocument while the Form/GoView is being resized. What event handlers have you defined for the GoView, or for the Form that have anything to do with either the GoView or its GoView.Document?
Scrolling, zooming, and resizing the view do not (normally) make any changes to the document. Perhaps you are loading-on-demand, so as to create nodes only when they become visible. This normally is accomplished by implementing a GoView.PropertyChanged event handler that looks for the “DocScale” and “DocPosition” properties, as well as an event handler that is invoked when the Control’s size changes.
I don’t think I have defined any event handler that changes the GoView or the Document with resizing…
These are the event handlers that I have defined on the GoView:
Document.DefaultLayer = Document.Layers.CreateNewLayerAfter(Document.LinksLayer);
_layouter = new GoLayoutLayeredDigraph();
_layouter.AggressiveOption = GoLayoutLayeredDigraphAggressive.Less;
_layouter.DirectionOption = GoLayoutDirection.Down;
_layouter.SetsPortSpots = false;
_layouter.Document = Document;
Document.Changed += delegate(object sender, GoChangedEventArgs e)
{
if (e.Hint == GoLayer.RemovedObject)
{
if (e.Object is GoLink)
{
DeleteLinkFromModel(e.Object as GoLink);
}
if (e.Object is BaseShape)
{
DeleteObjectFromModel(e.Object as BaseShape);
}
}
};
BaseShape is an abstract class that inherits GoNode. And these DeleteLinkFromModel and DeleteObjectFromModel just delete objects from the model, without any refreshment of the GoView
As you can see, none of these should change the GoView on resizing…
Also I have implemented zooming options, where on certain button click I increment or decrement the DocScale for a factor… But this is also not related to resizing…
I really think it has to do something with the size of the document when the form is small, that actually some nodes can not be shown because their location don’t exist in this form size…
I’m going to try to resize the document to the size that encloses all nodes (so that the scollbars are shown), without resizing the form and then let you know if this was the problem…
to set the ScrollRectangleToVisible to some rectangle that borders the down-right angle, after loading the nodes… This usually works when manually scrolled to the down-right corner… But in the case when I made this programatically, it didn’t worked
to programatically scroll both (V and H) scrollbars till the down-right corner, and then to reset the scrolls to their initial position… Also didn’t worked… But manually works…
to RescaleToFit when the nodes are loaded and afterwards to reset the scaling by clicking on button which resets the scale … Also without results… The reset drawed the nodes again on the their irregular positions…
I’m simply running out of ideas…
Can you try to create some nodes on locations deep in the scrolled area inside the view (larger then the form) and then to save this positions and try to preload the nodes on these positions in resized form size (smaller then the one in what the location were saved)… Maybe it is a bug…
Or do you have any further suggestion what could be the solution…
I’ve figured out what was the problem… It was the positioning of the ports…
In the constructor of the nodes I was setting some initial location (0, 0) of the ports, and on the paint method of the node I was fixing this location of the ports to be relative to the node that it belongs to…
But the problem was that for these nodes that weren’t in the visual area was not called the paint method, therefore the port locations of these nodes were in (0, 0) and thats why they were drawn like this…