C # determines whether or not the point in a rectangular frame

Please add QQ group group exchange 830 426 796

Together with System.Drawing.Drawing2D.GraphicsPath and the Region class, then Region.IsVisible (point) function can be determined whether the points within the polygon area.

System.Drawing.Drawing2D.GraphicsPath myGraphicsPath=new System.Drawing.Drawing2D.GraphicsPath(); 
Region myRegion=new Region(); 
myGraphicsPath.Reset(); 

// add the points of the polygon constructed 
Point P1 = new new Point (X1, Y1);
Point p2=new Point(x2,y2);
Point p3=new Point(x3,y3);
Point p4=new Point(x4,y4);

myGraphicsPath.AddPolygon (LoadPoint (P1, P2, P2, P4)); 
myRegion.MakeEmpty(); 
myRegion.Union(myGraphicsPath); 
// return point in the polygon is determined whether there 
BOOL myPoint = myRegion.IsVisible (MousePoint);

 

Guess you like

Origin www.cnblogs.com/yc1224/p/11671769.html