Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Draw actions (Read 2715 times)
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Custom Draw actions
Aug 21st, 2009 at 8:34am
Print Post  
Hi there.
I want to customize the drawing of a table node cell. I have overwrite the draw method of the table node and draw the string as I want. But when I look at the diagram the text is not visible. Does any one know what to do?

Cry HELP
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Draw actions
Reply #1 - Aug 21st, 2009 at 9:53am
Print Post  
Hi,

You could set CellCustomDraw = Additional, set the tables' TextColor = Transparent to stop the standard text rendering, and draw the cell text in the DrawCell event handler:

Code
Select All
private void diagram_DrawCell(object sender, DrawCellEventArgs e)
{
	IGraphics g = e.Graphics;
	TableNode.Cell cell = e.Cell;
	RectangleF r = e.Bounds;
	PointF pivot = new PointF(r.X + r.Width / 2, r.Y + r.Height / 2);

	// draw rotated text
	Matrix savedTransform = g.Transform;

	g.TranslateTransform(pivot.X, pivot.Y);
	g.RotateTransform(20);
	g.TranslateTransform(-pivot.X, -pivot.Y);

	StringFormat format = new StringFormat();
	format.Alignment = StringAlignment.Center;
	format.LineAlignment = StringAlignment.Center;

	g.DrawString(cell.Text,
		cell.Font ?? e.Table.Font, Brushes.Black, r, format);

	g.Transform = savedTransform;
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint