title: Rotated text align in C#
body: <p>I need to be able to rotate text in a label and align it to the left, right or center. So far I am able to do rotation with this code in the derived label's onPaint method:</p>
  
  <pre><code> float width = graphics.MeasureString(Text, this.Font).Width;
   float height = graphics.MeasureString(Text, this.Font).Height;
  
   double angle = (_rotationAngle / 180) * Math.PI;
   graphics.TranslateTransform(
       (ClientRectangle.Width + (float)(height * Math.Sin(angle)) - (float)(width * Math.Cos(angle))) / 2,
       (ClientRectangle.Height - (float)(height * Math.Cos(angle)) - (float)(width * Math.Sin(angle))) / 2);
   graphics.RotateTransform(270f);
   graphics.DrawString(Text, this.Font, textBrush, new PointF(0,0), stringFormat);
   graphics.ResetTransform();
  </code></pre>
  
  <p>And it works fine. I can see text rotated 270 degrees.</p>
  
  <p>But when I try to set alignment in stringFormat it goes crazy, and I can't figure out what's going on.</p>
  
  <p>How can I have text rotated by 270 degrees and align it to up?</p>