* UILineChart: 增加了绘制线的DashStyle样式
This commit is contained in:
parent
fa7aaad7b4
commit
047a1f508d
@ -50,6 +50,7 @@
|
|||||||
* 2023-07-14: V3.4.0 增加了坐标轴绘制时显示箭头,并在箭头处显示数量单位的功能
|
* 2023-07-14: V3.4.0 增加了坐标轴绘制时显示箭头,并在箭头处显示数量单位的功能
|
||||||
* 2023-10-04: V3.5.0 增加了Y轴数据由上向下绘制
|
* 2023-10-04: V3.5.0 增加了Y轴数据由上向下绘制
|
||||||
* 2023-10-05: V3.5.0 增加了X轴和Y轴鼠标选择区域并返回选中范围
|
* 2023-10-05: V3.5.0 增加了X轴和Y轴鼠标选择区域并返回选中范围
|
||||||
|
* 2023-10-20: V3.5.1 增加了绘制线的DashStyle样式
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -546,6 +547,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
using (Pen pen = new Pen(color, series.Width))
|
using (Pen pen = new Pen(color, series.Width))
|
||||||
{
|
{
|
||||||
|
pen.DashStyle = series.DashStyle;
|
||||||
|
if (series.DashPattern.IsValid()) pen.DashPattern = series.DashPattern;
|
||||||
g.SetHighQuality();
|
g.SetHighQuality();
|
||||||
|
|
||||||
if (series is UISwitchLineSeries lineSeries)
|
if (series is UISwitchLineSeries lineSeries)
|
||||||
|
@ -28,6 +28,7 @@ using System;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
@ -496,6 +497,10 @@ namespace Sunny.UI
|
|||||||
public float Width { get; set; } = 2;
|
public float Width { get; set; } = 2;
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
|
||||||
|
public DashStyle DashStyle { get; set; } = DashStyle.Solid;
|
||||||
|
|
||||||
|
public float[] DashPattern { get; set; }
|
||||||
|
|
||||||
public UILinePointSymbol Symbol { get; set; } = UILinePointSymbol.None;
|
public UILinePointSymbol Symbol { get; set; } = UILinePointSymbol.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -268,11 +268,11 @@ namespace Sunny.UI
|
|||||||
/// <param name="color">颜色</param>
|
/// <param name="color">颜色</param>
|
||||||
/// <param name="centerPoint">文字中心点</param>
|
/// <param name="centerPoint">文字中心点</param>
|
||||||
/// <param name="angle">角度</param>
|
/// <param name="angle">角度</param>
|
||||||
public static void DrawRotateString(this Graphics g, string text, Font font, Color color, PointF centerPoint, float angle)
|
public static void DrawRotateString(this Graphics g, string text, Font font, Color color, PointF centerPoint, float angle, int offsetX = 0, int offsetY = 0)
|
||||||
{
|
{
|
||||||
if (text.IsNullOrEmpty()) return;
|
if (text.IsNullOrEmpty()) return;
|
||||||
using Brush br = color.Brush();
|
using Brush br = color.Brush();
|
||||||
g.DrawRotateString(text, font, br, centerPoint, angle);
|
g.DrawRotateString(text, font, br, centerPoint, angle, offsetX, offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -284,25 +284,25 @@ namespace Sunny.UI
|
|||||||
/// <param name="brush">笔刷</param>
|
/// <param name="brush">笔刷</param>
|
||||||
/// <param name="centerPoint">文字中心点</param>
|
/// <param name="centerPoint">文字中心点</param>
|
||||||
/// <param name="angle">角度</param>
|
/// <param name="angle">角度</param>
|
||||||
private static void DrawRotateString(this Graphics g, string text, Font font, Brush brush, PointF centerPoint, float angle)
|
private static void DrawRotateString(this Graphics g, string text, Font font, Brush brush, PointF centerPoint, float angle, int offsetX = 0, int offsetY = 0)
|
||||||
{
|
{
|
||||||
if (text.IsNullOrEmpty()) return;
|
if (text.IsNullOrEmpty()) return;
|
||||||
SizeF sf = TextRenderer.MeasureText(text, font);
|
SizeF sf = TextRenderer.MeasureText(text, font);
|
||||||
float x1 = centerPoint.X - sf.Width / 2.0f;
|
float x1 = centerPoint.X - sf.Width / 2.0f + offsetX;
|
||||||
float y1 = centerPoint.Y - sf.Height / 2.0f;
|
float y1 = centerPoint.Y - sf.Height / 2.0f + offsetY;
|
||||||
|
|
||||||
// 把画板的原点(默认是左上角)定位移到文字中心
|
// 把画板的原点(默认是左上角)定位移到文字中心
|
||||||
g.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2);
|
g.TranslateTransform(x1 + sf.Width / 2.0f, y1 + sf.Height / 2.0f);
|
||||||
// 旋转画板
|
// 旋转画板
|
||||||
g.RotateTransform(angle);
|
g.RotateTransform(angle);
|
||||||
// 回退画板x,y轴移动过的距离
|
// 回退画板x,y轴移动过的距离
|
||||||
g.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2));
|
g.TranslateTransform(-(x1 + sf.Width / 2.0f), -(y1 + sf.Height / 2.0f));
|
||||||
g.DrawString(text, font, brush, x1, y1);
|
g.DrawString(text, font, brush, x1, y1);
|
||||||
|
|
||||||
//恢复
|
//恢复
|
||||||
g.TranslateTransform(x1 + sf.Width / 2, y1 + sf.Height / 2);
|
g.TranslateTransform(x1 + sf.Width / 2.0f, y1 + sf.Height / 2.0f);
|
||||||
g.RotateTransform(-angle);
|
g.RotateTransform(-angle);
|
||||||
g.TranslateTransform(-(x1 + sf.Width / 2), -(y1 + sf.Height / 2));
|
g.TranslateTransform(-(x1 + sf.Width / 2.0f), -(y1 + sf.Height / 2.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -106,11 +106,35 @@ namespace Sunny.UI
|
|||||||
/// <param name="xOffset">×óÓÒÆ«ÒÆ</param>
|
/// <param name="xOffset">×óÓÒÆ«ÒÆ</param>
|
||||||
/// <param name="yOffSet">ÉÏÏÂÆ«ÒÆ</param>
|
/// <param name="yOffSet">ÉÏÏÂÆ«ÒÆ</param>
|
||||||
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color,
|
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color,
|
||||||
|
RectangleF rect, int xOffset = 0, int yOffSet = 0, int angle = 0)
|
||||||
|
{
|
||||||
|
SizeF sf = graphics.GetFontImageSize(symbol, symbolSize);
|
||||||
|
|
||||||
|
if (angle == 0)
|
||||||
|
{
|
||||||
|
graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + ((rect.Width - sf.Width) / 2.0f).RoundEx(),
|
||||||
|
rect.Top + ((rect.Height - sf.Height) / 2.0f).RoundEx(), xOffset, yOffSet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphics.DrawFontImage(symbol, symbolSize, color, angle, rect, xOffset, yOffSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color, int angle,
|
||||||
RectangleF rect, int xOffset = 0, int yOffSet = 0)
|
RectangleF rect, int xOffset = 0, int yOffSet = 0)
|
||||||
{
|
{
|
||||||
SizeF sf = graphics.GetFontImageSize(symbol, symbolSize);
|
SizeF sf = graphics.GetFontImageSize(symbol, symbolSize);
|
||||||
graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + ((rect.Width - sf.Width) / 2.0f).RoundEx(),
|
PointF center = rect.Center();
|
||||||
rect.Top + ((rect.Height - sf.Height) / 2.0f).RoundEx(), xOffset, yOffSet);
|
Font font = GetFont(symbol, symbolSize);
|
||||||
|
|
||||||
|
var symbolValue = GetSymbolValue(symbol);
|
||||||
|
string text = char.ConvertFromUtf32(symbolValue);
|
||||||
|
graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
|
||||||
|
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
||||||
|
graphics.DrawRotateString(text, font, color, center, angle, xOffset, yOffSet);
|
||||||
|
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||||
|
graphics.InterpolationMode = InterpolationMode.Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -127,12 +151,8 @@ namespace Sunny.UI
|
|||||||
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color,
|
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color,
|
||||||
float left, float top, int xOffset = 0, int yOffSet = 0)
|
float left, float top, int xOffset = 0, int yOffSet = 0)
|
||||||
{
|
{
|
||||||
//×ÖÌå
|
|
||||||
Font font = GetFont(symbol, symbolSize);
|
Font font = GetFont(symbol, symbolSize);
|
||||||
if (font == null)
|
if (font == null) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var symbolValue = GetSymbolValue(symbol);
|
var symbolValue = GetSymbolValue(symbol);
|
||||||
string text = char.ConvertFromUtf32(symbolValue);
|
string text = char.ConvertFromUtf32(symbolValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user