public static void DrawRotatedTextAt(Graphics gr, float angle, string txt, float x, float y, Font the_font, Brush the_brush)
{
// Text rectangle
var fontRect = gr.MeasureString(txt, the_font);
// Save the graphics state.
GraphicsState state = gr.Save();
gr.ResetTransform();
// Rotate.
gr.RotateTransform(angle);
// Translate to desired position. Be sure to append the rotation so it occurs after the rotation.
gr.TranslateTransform(x + fontRect.Width / 2, y + fontRect.Height / 2, MatrixOrder.Append);
// Draw
gr.DrawString(txt, the_font, the_brush, -fontRect.Width / 2, -fontRect.Height / 2);
//gr.DrawRectangle(new Pen(the_brush, 1), -fontRect.Width / 2, -fontRect.Height / 2, fontRect.Width, fontRect.Height);
// Restore the graphics state.
gr.Restore(state);
}