We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Diagram in code. Nodes laying on top of each other.

Guys,
 
I have a bit of code that attempts to create a digram completely in code-behind. It works fine if I do a Show() on the window before adding the nodes. However, if I add the nodes first, then doa  show, all of the nodes are stacked on top of each other. I assume that the layout is being constrained somehow until I submit a Show command. Can you tell me how to build a diagram 100% in code behind?
 
Code below:
 
        public void Process(SasLog log)
        {
           // this.Show();  <---- WORKS FINE.
            int y = 0;
            int x = 0;
            foreach (var fe in log.FlowElements)
            {
                var rect = CreateNode(x, y, fe);
                diagramModel.Nodes.Add(rect);
                x = fe.Level * 150;
                y += 100;
            }
            this.Show();   <-- DOES NOT SHOW DIAGRAM CORRECTLY
        }
        //Creating the Node
        private Node CreateNode(double x, double y, FlowElement fe)
        {
            Node n = new Node();
            //Custom Label property to the Node
            n.LabelTextWrapping = TextWrapping.Wrap;
            n.LabelFontWeight = FontWeights.Light;
            n.LabelVerticalAlignment = VerticalAlignment.Top;
            n.LabelHorizontalAlignment = HorizontalAlignment.Left;
            n.Label = DetermineLabel(fe);
            n.LabelForeground = Brushes.White;
            n.LabelDisplacement = new Point(10, 20);
            n.Width = 150;
            n.Height = 75;
            n.OffsetX = x;
            n.OffsetY = y;
            return n;
        }

3 Replies

RT Ramya Thirugnanam Syncfusion Team July 13, 2012 04:10 AM UTC

Hi Alan,

Thanks for using Syncfusion Products and we regret for the inconvenience caused.

We have analyzed the reported issue and we are unable to reproduce the issue with the given information.

Can you please revert us with a sample based on your application along with the replication procedure to reproduce this issue? This would be helpful for us to serve you better.

Also, please let us know if you would require any assistance on this.
Regards,
Ramya



AC Alan Churchill July 13, 2012 06:36 PM UTC

See attached project. 2 methods. One labeled as Works and 1 labeled as DoesNotWork.


SyncTest_1c7180a5.zip


RT Ramya Thirugnanam Syncfusion Team July 18, 2012 01:06 PM UTC

Hi Alan,

We have analyzed your query, we are able to reproduce the reported problem.it is by design; the DirectedTreeLayout does not arranges the Nodes which are in disconnected (not connected) state. This is the cause of your problem(node placed on each other).

Details about Directed-Tree layout:

The Directed-Tree layout arranges the nodes in a tree-like structure. This layout can be applied to any diagram that comprises a directed tree graph with unique root and child nodes. This makes creating diagrams easier because the node position is determined automatically, based on the connections. However, it is necessary to specify a layout root for the tree layout. The Directed-Tree layout will position the nodes based on the layout root.

We assumed that your requirement is to arrange the Nodes in vertical manner, then please use TableLayout to achieve your requirement,

If this response does not satisfy your requirement, please provide us more details about your requirement. This would help us to serve you better.

Please let us know if you have any concerns.
Regards,
Ramya


Loader.
Live Chat Icon For mobile
Up arrow icon