Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Want consistent font size irrespective of zoom (Read 4700 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Want consistent font size irrespective of zoom
Jan 5th, 2011 at 7:44am
Print Post  
Hi,

If diagram's zoom factor is >=100, we want that node's text should not get increase with the diagram zoom factor i.e. node should be zoomed but not its text.

Also, if node's text is trimmed at 100 zoom factor than we want if we increase the zoom factor, text size should appear the same and it should display some more text which was previously trimmed.

Let know how can we achieve this?

We are sending a sample in which we are performing zoom by mouse wheel but text font is increasing with the diagram zoom factor and also, at higher zoom factor we are not able to see trimmed text.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want consistent font size irrespective of zoom
Reply #1 - Jan 5th, 2011 at 11:07am
Print Post  
This should do the trick:

Code
Select All
private void diagram_ZoomFactorChanged(object sender, EventArgs e)
{
	foreach (DiagramItem item in diagram.Items)
		item.FontSize *= lastZoom / diagram.ZoomFactor;
	lastZoom = diagram.ZoomFactor;
}

private double lastZoom = 100; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want consistent font size irrespective of zoom
Reply #2 - Jan 7th, 2011 at 10:45am
Print Post  
Hi Stoyan,

Thanks for the reply.

It has resolved our issue except a small one.

We have set TextAllignment to Right. When text is larger enough that it is coming in two line than text is right alligned for both the line, we want text alligment as right for first line line only and for second line text should be left alligned.

Please let know your suggestion.

Regards,
Bala
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want consistent font size irrespective of zoom
Reply #3 - Jan 7th, 2011 at 1:52pm
Print Post  
Hi,

Indeed TextAlignment affects all lines. If you need one line to be right-aligned and the second line left-aligned, you won't be able to use the built-in text rendering but will have to custom-draw the text.

Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want consistent font size irrespective of zoom
Reply #4 - Jan 7th, 2011 at 2:19pm
Print Post  
How we can do that in our custom shaped node?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want consistent font size irrespective of zoom
Reply #5 - Jan 8th, 2011 at 8:59am
Print Post  
Here you can find a simple text renderer that outputs the first line right-aligned and the rest of them left-aligned:
http://mindfusion.eu/_samples/Draw2AlignedText.cs

You can use the Draw2AlignedText method like this to show the text on the left of a node:

Code
Select All
private void diagram_DrawNode(object sender, DrawNodeEventArgs e)
{
	var node = e.Node;
	var localRect = new Rect(-150, 0, 150, e.Node.Bounds.Height);
	Draw2AlignedText(e.Graphics, node.Text, localRect, node);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want consistent font size irrespective of zoom
Reply #6 - Jan 10th, 2011 at 7:04am
Print Post  
Hi Stoyan,

I am calling node.Repaint(false); from ZoomFactorChange event handler but Diagram_DrawNode() is not getting called. Can you please let know how to fire DrawNode event explicitly?

Regards,
Bala
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want consistent font size irrespective of zoom
Reply #7 - Jan 10th, 2011 at 7:12am
Print Post  
Hi,

Have you set the node.CustomDraw property?

Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Want consistent font size irrespective of zoom
Reply #8 - Jan 10th, 2011 at 8:47am
Print Post  
No, I have not set node.CustomDraw property.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Want consistent font size irrespective of zoom
Reply #9 - Jan 10th, 2011 at 11:00am
Print Post  
DrawNode is raised only if CustomDraw is different from None. For example set it to Additional to get the standard drawing of ShapeNodes done before raising the event. In that case also set TextBrush = Transparent to stop the default text rendering.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint