Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Auto resizing diagrams (Read 1462 times)
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Auto resizing diagrams
Jan 2nd, 2020 at 12:16pm
Print Post  
Hi there!
I have a diagram, where i am mostly displaying control nodes without links between them.
I'd like to spread them out on the diagram as narrow, as possible when adding them. Example picture is attached.
Currently I'm positioning the location of each of those nodes on my own, but it only works when adding constantly. If I delete some items, I cant figure out the proper loaction.
Currently I'm Using the AutoResize set to down and right.
But I do not want to expand my diagram to the right. I just want to expand it down.
It seems, there is no way to AutoSize only downwards. This would solve my problem.
Currently, when I rearrange the controlnodes, they all are placed in the first colum and only extending to the right.
Any suggestions?
  

example_spreading.png ( 213 KB | 125 Downloads )
example_spreading.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: Auto resizing diagrams
Reply #1 - Jan 2nd, 2020 at 1:51pm
Print Post  
Hi and happy 2020!

The Erdgeist looks dangerous Wink Try calling this method after populating the diagram and when deleting nodes -

Code
Select All
void ArrangeColumns(int maxColumns)
{
    float totalHeight = diagram.Nodes.Aggregate(
        0f, (h, n) => h + n.Bounds.Height);
    float meanHeight = totalHeight / maxColumns;
    float y = 0;
    float x = 0;
    float colWidth = 0;
    foreach (var node in diagram.Nodes)
    {
        node.Move(x, y);
        y += node.Bounds.Height;
        colWidth = Math.Max(colWidth, node.Bounds.Width);
        if (y > meanHeight)
        {
            x += colWidth;
            y = 0;
            colWidth = 0;
        }
    }
    diagram.ResizeToFitItems(5);
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Auto resizing diagrams
Reply #2 - Jan 2nd, 2020 at 4:56pm
Print Post  
Yes, that earth elemental a fierce one!
Thanks for your reply, that works well.

May I suggest Mindfusion for the company with the fastest and most competent Support ever? Two thumbs up!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint