主要是路径的计算
先得到路径
if (value.Width > 0 && value.Height > 0) {GraphicsPath.AddBezier(new PointF(RectangleF.Left + RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.55f),new PointF(RectangleF.Left + RectangleF.Width * 0.1f - RectangleF.Width * 0.05f, RectangleF.Top + RectangleF.Height * 0.55f),new PointF(RectangleF.Left + RectangleF.Width * 0.25f - RectangleF.Width * 0.4f, RectangleF.Top + RectangleF.Height * 0.2f + RectangleF.Height * 0.1f),new PointF(RectangleF.Left + RectangleF.Width * 0.25f, RectangleF.Top + RectangleF.Height * 0.2f));GraphicsPath.AddBezier(new PointF(RectangleF.Left + RectangleF.Width * 0.25f, RectangleF.Top + RectangleF.Height * 0.2f),new PointF(RectangleF.Left + RectangleF.Width * 0.25f, RectangleF.Top + RectangleF.Height * 0.2f - RectangleF.Height * 0.1f),new PointF(RectangleF.Left + RectangleF.Width * 0.65f - RectangleF.Width * 0.2f, RectangleF.Top + RectangleF.Height * 0.15f - RectangleF.Height * 0.33f),new PointF(RectangleF.Left + RectangleF.Width * 0.65f, RectangleF.Top + RectangleF.Height * 0.15f));GraphicsPath.AddBezier(new PointF(RectangleF.Left + RectangleF.Width * 0.65f, RectangleF.Top + RectangleF.Height * 0.15f),new PointF(RectangleF.Left + RectangleF.Width * 0.65f + RectangleF.Width * 0.2f, RectangleF.Top + RectangleF.Height * 0.15f - RectangleF.Height * 0.1f),new PointF(RectangleF.Right + RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.45f - RectangleF.Height * 0.25f),new PointF(RectangleF.Right - RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.45f));GraphicsPath.AddBezier(new PointF(RectangleF.Right - RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.45f),new PointF(RectangleF.Right - RectangleF.Width * 0.1f + RectangleF.Width * 0.15f, RectangleF.Top + RectangleF.Height * 0.45f + RectangleF.Height * 0.1f),new PointF(RectangleF.Right - RectangleF.Width * 0.2f + RectangleF.Width * 0.2f, RectangleF.Bottom - RectangleF.Height * 0.15f),new PointF(RectangleF.Right - RectangleF.Width * 0.2f, RectangleF.Bottom - RectangleF.Height * 0.15f));GraphicsPath.AddBezier(new PointF(RectangleF.Right - RectangleF.Width * 0.2f, RectangleF.Bottom - RectangleF.Height * 0.15f),new PointF(RectangleF.Right - RectangleF.Width * 0.2f - RectangleF.Width * 0.1f, RectangleF.Bottom + RectangleF.Height * 0.05f),new PointF(RectangleF.Left + RectangleF.Width * 0.3f + RectangleF.Width * 0.1f, RectangleF.Bottom + RectangleF.Height * 0.05f),new PointF(RectangleF.Left + RectangleF.Width * 0.3f, RectangleF.Bottom - RectangleF.Height * 0.15f));GraphicsPath.AddBezier(new PointF(RectangleF.Left + RectangleF.Width * 0.3f, RectangleF.Bottom - RectangleF.Height * 0.15f),new PointF(RectangleF.Left + RectangleF.Width * 0.3f - RectangleF.Width * 0.2f, RectangleF.Bottom - RectangleF.Height * 0.15f + RectangleF.Height * 0.1f),new PointF(RectangleF.Left + RectangleF.Width * 0.1f - RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.55f + RectangleF.Height * 0.1f),new PointF(RectangleF.Left + RectangleF.Width * 0.1f, RectangleF.Top + RectangleF.Height * 0.55f));GraphicsPath.CloseAllFigures(); }
得到GraphicsPath就可以绘制了,下面看下效果
原文地址:https://www.hzhcontrols.cn/blog-174.html