Nevron Forum

Text Orientation problem

https://www.nevron.com/Forum/Topic4151.aspx

By Alex Alex 13 - Wednesday, September 8, 2010

I want to draw a vertical text on the Chart. Here is the code of the INPaintCallback implementation:

public void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
{

string label = "test";
var yStyle = new NTextStyle(new Font("Arial", 12), Color.Red);
yStyle.Orientation = 90;
eventArgs.Graphics.PaintText(label, yStyle, new NPointF(100,100));
}


But text rendered horizontal. How can I rotate it?
By Nevron Support - Wednesday, September 8, 2010

Hi Alexander,

You'll have to change the graphics transform - for example:

public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
{
 string label = "test";
 var yStyle = new NTextStyle(new Font("Arial", 12), Color.Red);
 yStyle.Orientation = 90;


 GraphicsState state = eventArgs.Graphics.DeviceGraphics.Save();
 NPointF location = new NPointF(100, 100);

 eventArgs.Graphics.TranslateTransform(location.X, location.Y);
 eventArgs.Graphics.RotateTransform(90);
 eventArgs.Graphics.PaintText(label, yStyle, new NPointF(0, 0));
 eventArgs.Graphics.DeviceGraphics.Restore(state);
}

By Alex Alex 13 - Wednesday, September 8, 2010

It works Thank you!