通过光标位置找到所在的要素,进行高亮显示。
IPoint pPoint = new PointClass();
pPoint.PutCoords(e.mapX, e.mapY);
ITopologicalOperator pTopo = pPoint as ITopologicalOperator;
double m_Radius = e.mapX / 100000000000;
IGeometry pGeometry = pTopo.Buffer(m_Radius);
//if (pGeometry == null)
// continue;
axMapControl1.Map.SelectByShape(pGeometry, null, true);//第三个参数为是否只选中一个
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //选中要素高亮显示
ISpatialFilter pFilter = new SpatialFilterClass();
pFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
pFilter.Geometry = pGeometry;
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
for (int i = 0; i < axMapControl1.LayerCount; i++)
{
ILayer ptempLayer = axMapControl1.get_Layer(i);
if (ptempLayer.Name == "样本矢量")
pFeatureLayer = ptempLayer as IFeatureLayer;
}
IFeatureSelection pSelection = pFeatureLayer as IFeatureSelection;
pSelection.SelectFeatures((IQueryFilter)pFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
ISimpleFillSymbol pSym = new SimpleFillSymbolClass();
IRgbColor pRGBColor = new RgbColorClass();
pRGBColor.NullColor = true;
pSym.Color = pRGBColor as IColor;
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 0;
pRgbColor.Green = 0;
pRgbColor.Blue = 255;
pRgbColor.Transparency = 5;
pLineSymbol.Color = pRgbColor as IColor;
pLineSymbol.Width = 2;
//pLineFillSymbol.LineSymbol = pLineSymbol;
pSym.Outline = pLineSymbol;
pSelection.SetSelectionSymbol = true;
pSelection.SelectionSymbol = (ISymbol)pSym;