Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Single long lines of text in boxes? (Read 6747 times)
RobGP
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2005
Single long lines of text in boxes?
Sep 30th, 2005 at 10:45pm
Print Post  
How can I make a single long line of text appear in a diagram box? It seems so simple but difficult. I can't seem to make it stretch to fit and turn off the auto-text-wrap feature at the same time. Can someone please post some code for setting up a simple diagram (completley programatically) with a single box with a large line of text in it which doesnt wrap?

Also, my diagrams are for display purposes only - how do I disable all the manual editing features?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Single long lines of text in boxes?
Reply #1 - Oct 1st, 2005 at 12:49pm
Print Post  
If what you need is to resize the box so all its text is on a single line, try this:

private void btnTextLine_Click(object sender, System.EventArgs e)
{
  Box b = fc.CreateBox(0, 0, 1, 1);
  b.Text = "a single longer line of text in the box";
  b.TextFormat.FormatFlags = StringFormatFlags.NoWrap;

  Graphics g = fc.CreateGraphics();
  g.PageUnit = fc.MeasureUnit;
  SizeF size = g.MeasureString(b.Text, b.Font, 10000, b.TextFormat);
  g.Dispose();

  b.BoundingRect = new RectangleF(b.BoundingRect.Location, size);
}

Set Behavior = bhDoNothing to ignore all mouse actions on the diagram items, which prevents modifying the items.

Stoyan
  
Back to top
 
IP Logged
 
Rob
Guest


Re: Single long lines of text in boxes?
Reply #2 - Oct 1st, 2005 at 2:20pm
Print Post  
Thats what I ended up doing, thanks, felt like a bit of a hack though.

Couple of other things,

I dont have a bhDoNothing in the EBehaviour enumeration, is it new or something?

In the documentation it says to set enabled to false to disable the user interaction - but it takes the scrollbars out too! Any way to avoid this?

Also, setting AutoSizeDoc to true doesn't seem to work properly, as it seems to underestimate the size of the document exponentially as more nodes are added (I created a two-tier tree diagram with 1 node connected to 100 children, only 10 or so are visible).

Is there a way to solve this?

Thanks for the help so far!
  
Back to top
 
IP Logged
 
RobGP
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2005
Re: Single long lines of text in boxes?
Reply #3 - Oct 1st, 2005 at 2:27pm
Print Post  
"(EBehavior)0" worked in place of bhDoNothing, thanks.

Still wondering about the AutoSize though..?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Single long lines of text in boxes?
Reply #4 - Oct 1st, 2005 at 3:25pm
Print Post  
bhDoNothing was added in version 3.2, so if you don't have it, your FlowChart.NET version is older than 3.2. (EBehavior)0 == bhModify, which allows selecting and moving the diagram items, which is somewhat different than DoNothing.

You are right about Enabled, I guess the flowchart should allow scrolling even when not Enabled; will pass that to the developers.

I can't find anything wrong with AutoSize, could you save your diagram in a file and send it to our support address at mindfusion.org ?

Stoyan
  
Back to top
 
IP Logged
 
RobGP
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2005
Re: Single long lines of text in boxes?
Reply #5 - Oct 1st, 2005 at 3:47pm
Print Post  
Ah, I had set all the items to Locked = true, so I guess thats why it appeared to work ok.

Thanks, I'll send it, is there any chance you could check it out personally? You seem to know whats what with this control. I'll try upgrading the library too.

Thanks a lot!
  
Back to top
 
IP Logged
 
RobGP
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2005
Re: Single long lines of text in boxes?
Reply #6 - Oct 1st, 2005 at 4:07pm
Print Post  
Emailed - I found that selecting the arrows by dragging a box over them seems to force the flowchart ot recalculate the document area correctly. Is this something to do with creating the nodes programatically?
  
Back to top
 
IP Logged
 
RobGP
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2005
Re: Single long lines of text in boxes?
Reply #7 - Oct 1st, 2005 at 4:28pm
Print Post  
This works for me for now...

[code]float max_x = System.Single.MinValue;
float max_y = System.Single.MinValue;
foreach(Box bo in flow.Boxes)
{
max_x = Math.Max(max_x, bo.BoundingRect.X + bo.BoundingRect.Width);
max_y = Math.Max(max_y, bo.BoundingRect.Y + bo.BoundingRect.Height);
}
flow.DocExtents = new RectangleF(0, 0, max_x + 20, max_y + 20);[/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Single long lines of text in boxes?
Reply #8 - Oct 1st, 2005 at 4:28pm
Print Post  
One thing that might cause the problem is that AutoSizeDoc works only for users actions, e.g. the user drawing a new item or moving items around. If you need to resize the document after creating the tree programmatically, try setting a larger DocExtents or call the FitDocToObjects method.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Single long lines of text in boxes?
Reply #9 - Oct 1st, 2005 at 4:32pm
Print Post  
Ok it seems we are posting at the same time. So after creating the tree programmatically, call the FitDocToObjects method which does the same as what your code above does. AutoDizeDoc resizes the document only after users actions, because it could slow the things down to recalculate a new bounding rectange, e.g. when you create a lot of items in a loop.

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