Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Starting in the center (Read 4871 times)
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Starting in the center
Feb 24th, 2009 at 6:48am
Print Post  
Hi,

Is there a way in which the nodes start to appear in the center of the Diagram conrol when I add nodes. And when I add nodes and based on the alyout chosen for rendering, the center point of the diagram control should always be respected to the extent possible.

Currently it starts in the left side corner, which is not so good in appearance. Please help.

Thanks,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting in the center
Reply #1 - Feb 24th, 2009 at 9:17am
Print Post  
Hi,

By center, do you mean the center of the currently visible part of the control, or the center of the scrollable area (Diagram.Bounds)?

Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Starting in the center
Reply #2 - Feb 24th, 2009 at 9:35am
Print Post  
By center, I mean  the center of the Scrollable Area.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting in the center
Reply #3 - Feb 24th, 2009 at 10:02am
Print Post  
You could set node.Bounds as follows to move the node to the center:

Code
Select All
Point center = new Point(
	diagram.Bounds.X + diagram.Bounds.Width / 2,
	diagram.Bounds.Y + diagram.Bounds.Height / 2);
node.Bounds = new Rect(
	center.X - node.Bounds.Width / 2,
	center.Y - node.Bounds.Height / 2,
	node.Bounds.Width,
	node.Bounds.Height);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Starting in the center
Reply #4 - Feb 24th, 2009 at 12:31pm
Print Post  
Hi Stoyo,

Thanks for the snippet, but I think this would move a particular node in the diagram in the center. I don't really want this. My diagram will have many nodes determined by the data relation I have in DB. So I am using the various layout to render the nodes and the (diagrma) links. What I actually need is that the renderation of the diagram (after the layout) should happen from the center of the scrollable screen area and use the entire space symmetrically to the extent possible depending upon the layout type used(maximum in case of circular)

Hope I am able to explain my exact requirement this time  Smiley

Regards,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting in the center
Reply #5 - Feb 24th, 2009 at 1:20pm
Print Post  
Hi Amit,

At this time the arranged graphs are always aligned to the top-left of Diagram.Bounds. What you could do is modify Bounds after the layout completes. Loop over all nodes and accumulate the union of their Bounds into a Rect instance, then add some margin space to all sides of the rect, and assign it to Diagram.Bounds.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Starting in the center
Reply #6 - Feb 27th, 2009 at 6:58am
Print Post  
Thanks Stoya, your suggestion looks workable however I have not tried this out. If you have any sample snippet do send me.

Best Regards & thanks again for all your help,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting in the center
Reply #7 - Feb 27th, 2009 at 9:06am
Print Post  
Hi Amit,

This version adds the ResizeToFitItems(margins) method to the Diagram class:
https://mindfusion.eu/_beta/diaglite_resizetofit.zip

Call it after applying a layout to set Diagram.Bounds as big as required to contain the items, with some space optionally left for margins. If you don't want to change the Bounds size, call that method with 0 as argument to get the size that corresponds to the diagram content, and then add to all sides of Bounds to inflate it to its original size but keep the content in the center.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Starting in the center
Reply #8 - Mar 16th, 2009 at 2:37pm
Print Post  
Hi Stoyan,

This new method (ResizetoFitContents) does somewhat achieves my reoquirement. I can live with this.

Great support.
Thanks,
Amit
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint