视频图像处理系列索引 || Arcgis/Engine/Server开发索引 || Web Map Gis开发索引 || jquery表格组件 JQGrid索引
WPF MVVM模式开发实现简明教程索引 || ArcGIS Runtime WPF(.net C#)开发简明教程索引

GDI画图,判断鼠标点击点在某一画好的多边形、矩形、图形里

Region.IsVisible方法

简单方便准确

private bool CheckPntInPoly(Point[] points, Point pnt)

        {

            if (points == null || points.Length == 0 || pnt == Point.Empty)

            {

                return false;

            }

 

            System.Drawing.Drawing2D.GraphicsPath myGraphicsPath=newSystem.Drawing.Drawing2D.GraphicsPath();               

            Region myRegion=new Region();                       

            myGraphicsPath.Reset();  

 

            myGraphicsPath.AddPolygon(points); 

            myRegion.MakeEmpty();  

            myRegion.Union(myGraphicsPath);  

            //返回判断点是否在多边形里

            return myRegion.IsVisible(pnt);         

        }

 

 

posted @ 2016-04-26 09:41  jhlong  阅读(2293)  评论(0编辑  收藏  举报
海龙的博客 jhlong@cnblogs 版权所有© 转载请注明链接.有用请推荐一下
代码全部经过本人测试,但不保证复制粘贴就正常运行,更不保证能解决你的问题,请结合前后代码及描述理解后修改和使用