Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Rotating text in a attached box (Read 2673 times)
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Rotating text in a attached box
Oct 9th, 2006 at 7:45am
Print Post  
Hi,

I want to rotate a text in a box so that it's written vertical.
At the moment I do this using a box and rotating it but this generates many problems because this box must be moved and resized programaticaly regarding to another box...so height is width, width is height, (x,y) are changed because of rotation. Attaching is also a problem...(the other box is not rotated) so I attach the bottom of the rotated one with the left midle of the second one?(when second gets moved/resized I need also to move/resize the rotated one)
  How can I do this without rotating the first box?

(The 2 boxes must be always horizontal aligned and of the same height)

Tks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotating text in a attached box
Reply #1 - Oct 9th, 2006 at 10:03am
Print Post  
Hi,

You could do that with custom drawing, i.e. set the box.CustomDraw property to Additional and handle the DrawBox event:

Code
Select All
private void fc_DrawBox(object sender, MindFusion.FlowChartX.BoxDrawArgs e)
{
  RectangleF bounds = e.Box.BoundingRect;
  PointF pivot = new PointF(
    bounds.X,
    bounds.Y + bounds.Height);

  GraphicsState gs = e.Graphics.Save();
  e.Graphics.TranslateTransform(pivot.X, pivot.Y);
  e.Graphics.RotateTransform(-90);
  e.Graphics.TranslateTransform(-pivot.X, -pivot.Y);

  fc.DrawStyledText(e.Graphics,
    "test1 test2 test3 test4 test5 test6",
    e.Box.Font,
    new RectangleF(pivot.X, pivot.Y, bounds.Height, bounds.Width),
    new StringFormat());

  e.Graphics.Restore(gs);
  return;
}
 



The DrawStyledText method will also let you use the formatting tags supported by the "styled text" feature of boxes.

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



Posts: 27
Joined: Sep 22nd, 2006
Re: Rotating text in a attached box
Reply #2 - Oct 10th, 2006 at 7:43am
Print Post  
Hi,

The code works but has a problem. Using spaces in the text generates high delays to events because of high time to draw. On a simple box ""test1 test2 test3 test4 test5 test6" it's ok but on a more complex program it's unusable (2-3 secs to move/select a box). It can be tested on a simple program with more spaces...something like "a b c d e f g...etc".
The solution is good for the moment because I only need one compact word. I hope when the program will have 500+ boxes it will still be usable.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotating text in a attached box
Reply #3 - Oct 10th, 2006 at 8:42am
Print Post  
If you do not need formatted text, just call e.Graphics.DrawString instead of fc.DrawStyledText.

The problem with DrawStyledText is that it parses and lays-out the text each time you call it, which is slow. Boxes with enabled EnableStyledText property keep cache of the parsed data and the text layout, and just draw what's cached which is quite faster.

Anyway, if you need to draw rotated styled text, we can make that method return a structure that contains the cached text data and let you use the cache on subsequent calls.

Stoyan
  
Back to top
 
IP Logged
 
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Re: Rotating text in a attached box
Reply #4 - Oct 10th, 2006 at 10:35am
Print Post  
e.Graphics.DrawString works fine. Returning that structure could be usefull in case someone needs
to draw rotated styled text.

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