레이블에서 텍스트를 회전하고 왼쪽, 오른쪽 또는 가운데에 정렬 할 수 있어야합니다. 지금까지 파생 된 레이블의 onPaint 메서드에서이 코드로 회전 할 수 있습니다.C에서 회전 된 텍스트 정렬
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();
그리고 잘 작동합니다. 270도 회전 된 텍스트를 볼 수 있습니다.
그러나 stringFormat에서 정렬을 설정하려고하면 미쳐 가고, 무슨 일이 일어나는지 알 수 없습니다.
텍스트를 270도 회전하여 위로 정렬 할 수 있습니까?
당신이 설정하는 어떤 정렬? – Aliostad
처음에는 근처에 있었지만 그래픽을 변형 시키면 멀리와 중심으로 바뀌려고합니다. –
전체 "세계"가 변형되어 거의 비슷하지 않습니다. 당신이 원하는 위치에 그것을 설정할 수 있습니까? – Aliostad