diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 5a667ced..9fb5fbd9 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index f559f886..b1fcd217 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 66fd6db9..4330fe0a 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index 44882dd4..02246950 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Charts/UILineChart.cs b/SunnyUI/Charts/UILineChart.cs index 0cf55f11..19a26a5c 100644 --- a/SunnyUI/Charts/UILineChart.cs +++ b/SunnyUI/Charts/UILineChart.cs @@ -275,30 +275,10 @@ namespace Sunny.UI SizeF sfName = g.MeasureString(Option.YAxis.Name, SubFont); float xx = DrawOrigin.X - Option.YAxis.AxisTick.Length - widthMax - sfName.Width; float yy = Option.Grid.Top + (DrawSize.Height - sfName.Height) / 2.0f; - DrawStringRotateAtCenter(g, Option.YAxis.Name, SubFont, ChartStyle.ForeColor, new PointF(xx + sfName.Width / 2.0f, yy + sfName.Height / 2.0f), 270); + g.DrawStringRotateAtCenter(Option.YAxis.Name, SubFont, ChartStyle.ForeColor, new PointF(xx + sfName.Width / 2.0f, yy + sfName.Height / 2.0f), 270); } } - public void DrawStringRotateAtCenter(Graphics graphics, string text, Font font, Color color, PointF centerPoint, int angle) - { - SizeF sf = graphics.MeasureString(text, font); - float x1 = centerPoint.X - sf.Width / 2.0f; - float y1 = centerPoint.Y - sf.Height / 2.0f; - - // 把画板的原点(默认是左上角)定位移到文字中心 - graphics.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2); - // 旋转画板 - graphics.RotateTransform(angle); - // 回退画板x,y轴移动过的距离 - graphics.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2)); - graphics.DrawString(text, font, new SolidBrush(Color.Black), x1, y1); - - //恢复 - graphics.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2); - graphics.RotateTransform(-angle); - graphics.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2)); - } - protected virtual void DrawSeries(Graphics g, Color color, UILineSeries series) { if (series.Points.Count == 0) diff --git a/SunnyUI/Static/UGDI.cs b/SunnyUI/Static/UGDI.cs index ab3d1f25..50e35aec 100644 --- a/SunnyUI/Static/UGDI.cs +++ b/SunnyUI/Static/UGDI.cs @@ -959,6 +959,35 @@ namespace Sunny.UI g.DrawString(s, font, brush, rotatePt, newFormat, angle); } + /// + /// 以文字中心点为原点,旋转文字 + /// + /// Graphics + /// 文字 + /// 字体 + /// 颜色 + /// 文字中心点 + /// 角度 + public static void DrawStringRotateAtCenter(this Graphics graphics, string text, Font font, Color color, PointF centerPoint, int angle) + { + SizeF sf = graphics.MeasureString(text, font); + float x1 = centerPoint.X - sf.Width / 2.0f; + float y1 = centerPoint.Y - sf.Height / 2.0f; + + // 把画板的原点(默认是左上角)定位移到文字中心 + graphics.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2); + // 旋转画板 + graphics.RotateTransform(angle); + // 回退画板x,y轴移动过的距离 + graphics.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2)); + graphics.DrawString(text, font, new SolidBrush(Color.Black), x1, y1); + + //恢复 + graphics.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2); + graphics.RotateTransform(-angle); + graphics.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2)); + } + /// /// 绘制根据点旋转文本,一般旋转点给定位文本包围盒中心点 ///