.Net窗体确定点击区域

时间:2015-08-13 21:58:48

标签: c# vb.net winforms coordinates area

嘿所有我一直试图找到能够在表单上的某个区域周围绘制线条的示例,并确定当用户点击表单时,是否在该绘制区域内或其外部。

我看到很多例子来获得鼠标光标位置,但这并不是我所追求的。我希望能够绘制出该区域并在其后面有一些逻辑来确定它是否在绘制线的X,Y区域内。

如果上面没有这样做,那么图片制作一个标准的HTML页面,上面有一个图像。在该图像中,您已经定义了一个" MAP"您可以绘制矩形,圆形或多边形。每个区域都有自己的坐标,具体取决于用户点击该图像的位置取决于这些地图坐标放置在该图像中的位置。

HTML图片地图示例:

<img src="images/house.jpg" width="400" height="150" border="1" usemap="#home">

<map name="home">
   <area shape="circle" coords="28,126,25" href="ocotillo.html">
   <area shape="rect" coords="0,0,86,35" href="sky.html">
   <area shape="rect" coords="271,85,329,124" href="garage.html">
   <area shape="rect" coords="141,84,176,107" href="entrance.html">
   <area shape="rect" coords="140,114,194,145" href="hitching_post.html">
   <area shape="poly" coords="182,35,225,16,280,27,282,48,190,48" href="mountain.html">
   <area shape="poly" coords="69,62,100,40,119,62,98,126" href="saguaro.html">
   <area shape="poly" coords="212,147,287,131,390,126,353,148" href="driveway">
</map>

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以创建一个区域外的区域(可能是图形路径),然后使用IsVisible区域方法查看鼠标点是否位于该区域内。

https://msdn.microsoft.com/en-us/library/system.drawing.region%28v=vs.110%29.aspx