/// <summary> /// 点选选中要素的顶点 /// </summary> /// <param name="mouseLocation"></param> /// <param name="bounds"></param> /// <param name="centerPos"></param> /// <param name="scale"></param> internal override void SelectVertex(Point mouseLocation, Rectangle bounds, PointF centerPos, double scale) { MyPoint xyCenter = ETCProjection.LngLat2XY(new MyPoint(centerPos.X, centerPos.Y)); double xmin = xyCenter.X - scale * bounds.Width / 2; double xmax = xyCenter.X + scale * bounds.Width / 2; double ymin = xyCenter.Y - scale * bounds.Height / 2; double ymax = xyCenter.Y + scale * bounds.Height / 2; for (int i = 0; i < polygons.Count; i++) { if (polygons[i].Selected == true) //polylines[i]被选中 { for (int j = 0; j < polygons[i].PointCount; j++) { MyPoint xyProjection = ETCProjection.LngLat2XY(polygons[i].Points[j]); double xScreen = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin); double yScreen = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin); MyPoint screen = new MyPoint(xScreen, bounds.Height - yScreen); //polygons[i].Points[j]在屏幕坐标系的位置 polygons[i].Points[j].Selected = GeometryTools.IsPointInCircle(new MyPoint(mouseLocation.X, mouseLocation.Y), screen, margin); //判断polylines[i].Points[j]是否被选中并修改Selected属性的值 } } } }
/// <summary> /// 点选 /// </summary> /// <returns>被选中要素FID的List</returns> internal override List <int> SelectByPoint(Point mouseLocation, Rectangle bounds, PointF centerPos, double scale) { List <int> selectedID = new List <int>(); MyPoint xyCenter = ETCProjection.LngLat2XY(new MyPoint(centerPos.X, centerPos.Y)); double xmin = xyCenter.X - scale * bounds.Width / 2; double xmax = xyCenter.X + scale * bounds.Width / 2; double ymin = xyCenter.Y - scale * bounds.Height / 2; double ymax = xyCenter.Y + scale * bounds.Height / 2; for (int i = 0; i < myPoints.Count; i++) { MyPoint xyProjection = ETCProjection.LngLat2XY(myPoints[i]); double xScreen = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin); double yScreen = bounds.Height - bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin); MyPoint screen = new MyPoint(xScreen, yScreen); myPoints[i].Selected = GeometryTools.IsPointInCircle(new MyPoint(mouseLocation.X, mouseLocation.Y), screen, margin); if (myPoints[i].Selected == true) { selectedID.Add(i); } } return(selectedID); }