diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll
index 1583a092..405ed30a 100644
Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ
diff --git a/SunnyUI/Static/UGDI.cs b/SunnyUI/Static/UGDI.cs
index f440ee8e..582b4ed8 100644
--- a/SunnyUI/Static/UGDI.cs
+++ b/SunnyUI/Static/UGDI.cs
@@ -29,6 +29,20 @@ namespace Sunny.UI
{
public static class GDI
{
+ public static PointF AzRange(this PointF center, float range, float az, float xOffset = 0, float yOffset = 0)
+ {
+ float x = (float)(range * 1.0f * Math.Sin(az * Math.PI / 180));
+ float y = (float)(range * 1.0f * Math.Cos(az * Math.PI / 180));
+ return new PointF(center.X + xOffset + x, center.Y + yOffset - y);
+ }
+
+ public static PointF AzRange(this Point center, float range, float az, float xOffset = 0, float yOffset = 0)
+ {
+ float x = (float)(range * 1.0f * Math.Sin(az * Math.PI / 180));
+ float y = (float)(range * 1.0f * Math.Cos(az * Math.PI / 180));
+ return new PointF(center.X + xOffset + x, center.Y + yOffset - y);
+ }
+
///
/// 点是否在区域内
///
diff --git a/SunnyUI/Static/UGraphics.cs b/SunnyUI/Static/UGraphics.cs
index d1777d81..9b4cbe88 100644
--- a/SunnyUI/Static/UGraphics.cs
+++ b/SunnyUI/Static/UGraphics.cs
@@ -929,10 +929,8 @@ namespace Sunny.UI
public static void DrawTwoPoints(this Graphics g, Color color, PointF pf1, PointF pf2, Rectangle rect, bool smooth = true, float penWidth = 1)
{
- using (Pen pen = color.Pen(penWidth))
- {
- DrawTwoPoints(g, pen, pf1, pf2, rect, smooth);
- }
+ using Pen pen = color.Pen(penWidth);
+ DrawTwoPoints(g, pen, pf1, pf2, rect, smooth);
}
public static void DrawTwoPoints(this Graphics g, Pen pen, PointF pf1, PointF pf2, Rectangle rect, bool smooth = true)
@@ -1072,5 +1070,34 @@ namespace Sunny.UI
TwoPoints.Clear();
}
+
+ ///
+ /// 以center为中心,绘制箭头,正北0°,顺时针0°到359°
+ ///
+ /// Graphics
+ /// 颜色
+ /// 中心点
+ /// 箭头尺寸
+ /// 箭头方向
+ /// 笔宽
+ public static void DrawArrow(this Graphics g, Color color, PointF center, float arrowSize, float arrowDir, float penWidth = 1)
+ {
+ using Pen pen = color.Pen(penWidth);
+ PointF pfStart = new PointF(Convert.ToSingle(center.X + arrowSize * Math.Sin(arrowDir.Rad()) / 2),
+ Convert.ToSingle(center.Y - arrowSize * Math.Cos(arrowDir.Rad()) / 2));
+ PointF pfEnd = new PointF(Convert.ToSingle(center.X - arrowSize * Math.Sin(arrowDir.Rad()) / 2),
+ Convert.ToSingle(center.Y + arrowSize * Math.Cos(arrowDir.Rad()) / 2));
+
+ double dAngle = arrowDir + 180 + 25;
+ PointF pfArrow1 = new PointF(Convert.ToSingle(pfStart.X + arrowSize * Math.Sin(dAngle.Rad()) / 2),
+ Convert.ToSingle(pfStart.Y - arrowSize * Math.Cos(dAngle.Rad()) / 2));
+
+ dAngle = arrowDir + 180 - 25;
+ PointF pfArrow2 = new PointF(Convert.ToSingle(pfStart.X + arrowSize * Math.Sin(dAngle.Rad()) / 2),
+ Convert.ToSingle(pfStart.Y - arrowSize * Math.Cos(dAngle.Rad()) / 2));
+
+ PointF[] pfPoints = { pfArrow1, pfStart, pfEnd, pfStart, pfArrow2 };
+ g.DrawLines(pen, pfPoints);
+ }
}
}