Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Resize Node After Inserting Text (Read 4176 times)
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Resize Node After Inserting Text
Mar 28th, 2008 at 8:26pm
Print Post  
Hello,

I am using the following code to resize my node after I enter in about 30 lines of text - 134 chars each line (each line ends with a CRLF)

Code
Select All
 Dim node2 As ShapeNode = VectorDiagram.Factory.CreateShapeNode(New PointF(VectorDiagram.Bounds.Width / 2, VectorDiagram.Bounds.Bottom + 2), New SizeF(45, 15), Shape.FromId("Rectangle"))
node2.TextFormat.Alignment = StringAlignment.Near
Dim r = New RectangleF(node2.Bounds.Left, node2.Bounds.Top, 20, 20)
node2.PolygonalTextLayout = True
node2.Bounds = r
node2.Text = "    Name:   "  & vvCrLf _
				    & vbCrLf & sVeryBigString
Font = New Font(FontFamily.GenericMonospace, 10)
node2.Font = Font
node2.ResizeToFitText(FitSize.KeepRatio)
 



When the node displays on my screen, the text 'almost' fits, but I still need to drag the node width wise a little wider to get each line to fit on one line without word wrapping.

Can someone tell me how to get each text line to fit on one line when I use the resize option?

Thanks!
Barry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resize Node After Inserting Text
Reply #1 - Mar 29th, 2008 at 9:47am
Print Post  
Hi,

To fit the text without wrapping, enable the NoWrap flag in  node.TextFormat.FormatFlags.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Resize Node After Inserting Text
Reply #2 - Mar 31st, 2008 at 3:23am
Print Post  
Hello,

When I add the line:

node2.TextFormat.FormatFlags = StringFormatFlags.NoWrap

Before using the ResizeToFit function, I end up with a rectangle with the height perfect, but the width of the rectangle is now half the size showing only 35 characters.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resize Node After Inserting Text
Reply #3 - Mar 31st, 2008 at 8:32am
Print Post  
Hi,

Please save that node in a file and email it to support@mindfusion.eu.

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Resize Node After Inserting Text
Reply #4 - Mar 31st, 2008 at 12:59pm
Print Post  
Thanks Stoyan,

Do you have an example I can use to just save a node to a filename?


Thanks!
Barry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resize Node After Inserting Text
Reply #5 - Mar 31st, 2008 at 1:23pm
Print Post  
Hi Barry,

Call Diagram.SaveToFile() after creating the node and setting its text.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resize Node After Inserting Text
Reply #6 - Apr 2nd, 2008 at 10:21am
Print Post  
Hi,

It turns out ResizeToFitText doesn't honor the NoWrap flag when using the KeepRatio mode, so for now add this code:

n.TextFormat.FormatFlags = n.TextFormat.FormatFlags | StringFormatFlags.NoWrap;
n.ResizeToFitText(FitSize.KeepWidth);
n.TextFormat.FormatFlags = n.TextFormat.FormatFlags & ~StringFormatFlags.NoWrap;
n.ResizeToFitText(FitSize.KeepHeight);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Resize Node After Inserting Text
Reply #7 - Apr 4th, 2008 at 3:57am
Print Post  
Thanks,

Would you be able to translate that to a vb.net rookie such as myself?


Barry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resize Node After Inserting Text
Reply #8 - Apr 4th, 2008 at 2:20pm
Print Post  
Hi,

Just replace the following symbols and remove the ";" from the line ends:

| -> or
& -> and
~ -> not

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Resize Node After Inserting Text
Reply #9 - Apr 4th, 2008 at 3:05pm
Print Post  
Excellent, that worked perfectly!


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