Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Rotating the Container Nodes (Read 4146 times)
chiru29
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 35
Location: Hyderabad
Joined: Jul 16th, 2010
Rotating the Container Nodes
Aug 17th, 2010 at 9:38am
Print Post  
Hi Stoyan,

Can i rotate the container nodes by 270 degrees so that the caption will display on left of the node.

Or, is there any way to display the caption of container node on to its left not on top?

Please help me with this.

thanks
Chiru
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotating the Container Nodes
Reply #1 - Aug 17th, 2010 at 10:05am
Print Post  
Hi Chiru,

You will have to override the ContainerNode.Draw method. For an example, check this custom container class:
http://mindfusion.eu/_samples/RoundedContainerNode.cs

The following code draws a rotated caption:
Code
Select All
PointF leftMiddle = new PointF(rect.X, rect.Y + rect.Height / 2);

GraphicsState state = graphics.Save();
graphics.TranslateTransform(-leftMiddle.X, -leftMiddle.Y, MatrixOrder.Append);
graphics.RotateTransform(270, MatrixOrder.Append);
graphics.TranslateTransform(leftMiddle.X, leftMiddle.Y, MatrixOrder.Append);

StringFormat centered = new StringFormat();
centered.Alignment = StringAlignment.Center;
centered.LineAlignment = StringAlignment.Near;
graphics.DrawString(Caption,
	Font, Brushes.Black, leftMiddle, centered);

graphics.Restore(state); 



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


I love YaBB 1G - SP1!

Posts: 35
Location: Hyderabad
Joined: Jul 16th, 2010
Re: Rotating the Container Nodes
Reply #2 - Aug 17th, 2010 at 10:24am
Print Post  
Hi Stoyan,

Thanks for your reply.

Can you give a sample code, to create a container by calling its Draw() method?

for example, i have a Diagram called diagram.

thanks,
Chiru
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotating the Container Nodes
Reply #3 - Aug 17th, 2010 at 10:43am
Print Post  
Draw() is called automatically by the Diagram when it renders items in the current view. It's where you should add the above code to render rotated captions.

You can add a custom container to the diagram as shown below:

Code
Select All
RoundedContainerNode node = new RoundedContainerNode();
diagram.Nodes.Add(node); 



The following enables drawing custom nodes using the mouse:
Code
Select All
diagramView.Behavior = Behavior.Custom;
diagramView.CustomNodeType = typeof(RoundedContainerNode); 



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


I love YaBB 1G - SP1!

Posts: 35
Location: Hyderabad
Joined: Jul 16th, 2010
Re: Rotating the Container Nodes
Reply #4 - Aug 17th, 2010 at 1:29pm
Print Post  
Thanks Stoyan.

But, there is a problem with the rotated caption while scrolling the diagramview.

I mean (Alt + Mouse Left ad move the mouse).

In this scenario, the caption labels are loosing their positions.

Can you help on this?

thanks
Chiru
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotating the Container Nodes
Reply #5 - Aug 17th, 2010 at 2:43pm
Print Post  
Replace the transforms with the following (the default matrix order is Prepend when not specified):

graphics.TranslateTransform(leftMiddle.X, leftMiddle.Y);
graphics.RotateTransform(270);
graphics.TranslateTransform(-leftMiddle.X, -leftMiddle.Y);

This code inserts them before the DiagramView's own transforms and should not depend on the scroll position.
  
Back to top
 
IP Logged
 
chiru29
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 35
Location: Hyderabad
Joined: Jul 16th, 2010
Re: Rotating the Container Nodes
Reply #6 - Aug 17th, 2010 at 2:52pm
Print Post  
Thanks Stoyan.

This is very helpful.


thanks,
Chiru
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint