/// <summary> /// Select graphics by an extent /// </summary> /// <param name="aExtent">extent</param> /// <param name="selectedGraphics">ref selected graphics</param> /// <returns>if selected</returns> public bool SelectGraphics(Extent aExtent, ref GraphicCollection selectedGraphics) { selectedGraphics.GraphicList.Clear(); int i, j; PointD aPoint = new PointD(); aPoint.X = (aExtent.minX + aExtent.maxX) / 2; aPoint.Y = (aExtent.minY + aExtent.maxY) / 2; foreach (Graphic aGraphic in _graphicList) { switch (aGraphic.Shape.ShapeType) { case ShapeTypes.Point: for (i = 0; i < Count; i++) { PointShape aPS = (PointShape)_graphicList[i].Shape; if (MIMath.PointInExtent(aPS.Point, aExtent)) { selectedGraphics.Add(aGraphic); } } break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: for (i = 0; i < Count; i++) { PolylineShape aPLS = (PolylineShape)_graphicList[i].Shape; if (MIMath.IsExtentCross(aExtent, aPLS.Extent)) { for (j = 0; j < aPLS.Points.Count; j++) { aPoint = aPLS.Points[j]; if (MIMath.PointInExtent(aPoint, aExtent)) { selectedGraphics.Add(aGraphic); break; } } } } break; case ShapeTypes.Polygon: case ShapeTypes.Rectangle: for (i = Count - 1; i >= 0; i--) { PolygonShape aPGS = (PolygonShape)_graphicList[i].Shape; if (!(aPGS.PartNum > 1)) { if (MIMath.PointInPolygon(aPGS.Points, aPoint)) { selectedGraphics.Add(aGraphic); } } else { for (int p = 0; p < aPGS.PartNum; p++) { ArrayList pList = new ArrayList(); if (p == aPGS.PartNum - 1) { for (int pp = aPGS.parts[p]; pp < aPGS.PointNum; pp++) { pList.Add(aPGS.Points[pp]); } } else { for (int pp = aPGS.parts[p]; pp < aPGS.parts[p + 1]; pp++) { pList.Add(aPGS.Points[pp]); } } if (MIMath.PointInPolygon(pList, aPoint)) { selectedGraphics.Add(aGraphic); break; } } } } break; } } if (selectedGraphics.Count > 0) { return(true); } else { return(false); } }