目前我正在制定一项要求,其中我想要旋转TeeChart的注释工具(.Net版本),该工具具有多行文字。我成功更新了代码以旋转单行注释工具。其代码片段可在下面找到。
string[] s = tmp.Split(Texts.LineSeparator);
int tmpCenterX, tmpCenterY;
Point tmpP = new Point(0, 0);
Rectangle r = shape.ShapeBounds;
if (Angle != 0)
{
Graphics3D.RectCenter(r, out tmpCenterX, out tmpCenterY);
double tmp1 = Angle * Utils.PiStep;
int tmpNumRow = 1;
int tmpRowHeight = tmpHeight;
double S = Math.Sin(tmp1);
double C = Math.Cos(tmp1);
int tmpY = tmpNumRow * tmpRowHeight - (r.Bottom - tmpCenterY);
tmpP.X = Utils.Round(tmpCenterX - Utils.Round(tmpY * S));
tmpP.Y = Utils.Round(tmpCenterY - Utils.Round(tmpY * C));
tmpP.X = tmpCenterX;
tmpP.Y = r.Top + tmpNumRow * tmpRowHeight;
if (shape.Visible)
{
shape.DrawRectRotated(g, r, Utils.Round(Angle % 360), 0);
}
}
for (int t = 1; t <= tmpN; t++)
{
if (TextAlign == StringAlignment.Center && tmpN > 1)
{
float auxW = g.Chart.Graphics3D.TextWidth(s[t - 1]);
x = Utils.Round((shape.ShapeBounds.Left + shape.ShapeBounds.Right) / 2) - Utils.Round(auxW / 2);
}
if (Angle != 0)
{
Point rotatedPoint = RotatedPoint(r, (int)Angle);
g.RotateLabel(rotatedPoint.X , rotatedPoint.Y + tmpHeight * (t - 1), 0, s[t - 1], (float)Angle);
}
else
{
CalcTextXY(ref x, ref y);
DrawString(g, x, y, t, tmpHeight, s);
}
}
但对于多行文字,此代码无效。请查看以下屏幕截图,看看我收到的错误。 Error in Multiline Rotated Text
对此有任何帮助都会有很大帮助。提前感谢你。