例如有一个Ellipse,名称叫做element,现在有一个点clickPoint,我们就可以用下面的方法判断这个点是否在Ellipse的内部:

GraphicsPath areaPath = new GraphicsPath();

areaPath.AddEllipse(0, 0, (float)element.Width, (float)element.Height);

// 注意把Ellipse的左上角当作(0,0)点。

areaPath.CloseFigure();

if(areaPath.IsVisible(new System.Drawing.PointF((float)clickPoint.X, (float)clickPoint.Y)))

{

// 在里面

}

else

{

// 不在里面

}

对于其他的graph,如Polygon,有相应的AddPolygon方法。

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-30
  • 2022-01-28
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案