【问题标题】:TeeChart - Rotating Multiline Annotation (Text) Tool gives wrong resultTeeChart - 旋转多行注释(文本)工具给出错误结果
【发布时间】:2017-03-31 09:41:57
【问题描述】:

目前我正在处理一项要求,其中我想旋转具有多行文本的 TeeChart 的注释工具(.Net 版本)。我成功更新了代码以旋转单行注释工具。其中的代码sn-p可以在下面找到。

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

对此的任何帮助都会有很大帮助。提前谢谢你。

【问题讨论】:

    标签: c# .net charts teechart


    【解决方案1】:

    RotateLabel 在这里对我来说是正确的:

    private void TChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      String tmp = "Multiline\nText\nAngle 45 Degree";
    
      g.RotateLabel(100, 150, tmp, 45);
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-16
      相关资源
      最近更新 更多