0
我使用束帶方法來繪製矩形內的文字,..我想旋轉文本180度,所以我使用該代碼拉繩旋轉長文本180
Rectangle displayRectangleh =
new Rectangle(new Point((int)posh.X, (int)posh.Y), new Size(rectwdh, recth));
StringFormat format1h = new StringFormat(StringFormatFlags.DirectionVertical);
format1h.LineAlignment = StringAlignment.Center;
format1h.Alignment = StringAlignment.Center;
b = new SolidBrush(Color.Black);
e.ChartGraphics.Graphics.TranslateTransform((float)rectwdh/2 + posh.X, recth/2 + posh.Y);
e.ChartGraphics.Graphics.RotateTransform(180);
e.ChartGraphics.Graphics.TranslateTransform(-((float)rectwdh/2 + posh.X), -(recth/2 + posh.Y));
Font boldFonth = new Font(FontFamily.GenericSansSerif, 16, FontStyle.Bold, GraphicsUnit.Pixel, 1, true);
e.ChartGraphics.Graphics.DrawRectangle(new Pen(Color.Black, 2), displayRectangleh);
e.ChartGraphics.Graphics.DrawString("This is rotated long text test ", boldFonth, b, (RectangleF)displayRectangleh, format1h);
e.ChartGraphics.Graphics.ResetTransform();
其中posh.X和posh.Y(recatangle位置),rectwdh(矩形寬度)和recth(矩形高度)
它可以完美的短文本,但對於長文本的新生產線將高於我的老線請看下圖:
我甚至試圖添加新的行字符\ n但結果相同。 我的問題:如何旋轉矩形內的文字180並最終得到正確的對齊?
感謝,並獲得成功,併爲我工作 – user1477332