Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CompositeNode resize to fit text (Read 2672 times)
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
CompositeNode resize to fit text
May 8th, 2013 at 11:56am
Print Post  
Hey,

I am using CompositeNodes in a treeLayout and i'm wanting them to automatically resize based on the text that the user has entered for that node. My CompositeNode (I inherit the class) includes 2 textComponents and an ImageComponent; the user can enter a String into a dialog to change the text of the nodes. The problem is that the nodes remain unchanged in size so they have to be manually resized.

I noticed on ShapeNodes there is a method called "ResizeToFitText" which doesn't appear on CompositeNodes (Which is fair enough, as they might not contain textComponents). I was wondering if there's a way of doing this?

I have tried using the Graphics.MeasureString method to create a SizeF object based on the actual string size, but this is making the boxes way too big so i'm presuming that there's a difference in the scale or something??

Any help will be very appreciated!

Rich Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode resize to fit text
Reply #1 - May 8th, 2013 at 1:16pm
Print Post  
Hi,

If you are using panels for laying out components, calling the root panel's GetDesiredSize method should give you the size that fits all components in the node. For an example, see OperationNode.cs in the Scripting sample project. It also shows how to resize nodes automatically while the user types in a text field.

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


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: CompositeNode resize to fit text
Reply #2 - May 13th, 2013 at 9:06am
Print Post  
Thanks Stoyo,

Works a treat Smiley

Rich
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint