结合IHookActions的DoAction方法并搭上esriHookActionsFlash动作,这样做效果很接近arcmap中的效果,速度也比较快。Action方面有6个constant,可以根据需要选择
代码思路:
- 获取要素的objectID,根据ID选出要素
- 通过IHookActions闪烁要素
源代码:
private void LocatePoint(DataGridViewCellEventArgs e) { int rowNO = e.RowIndex; if (rowNO >= 0) { int TowerObjectID = int.Parse(this.dataGridView.Rows[rowNO].Cells[0].Value.ToString()); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = "TowerObjectID=" + TowerObjectID; IFeatureCursor pFeatureCursor = _pFeatureLayerTower.Search(pQueryFilter, false); IFeature pFeature = pFeatureCursor.NextFeature(); if (pFeature != null) { IArray geoArray = new ArrayClass(); geoArray.Add(pFeature.ShapeCopy); //通过IHookActions闪烁要素集合 HookHelperClass m_pHookHelper = new HookHelperClass(); m_pHookHelper.Hook = this.mapContainer.MapControl.Object; IHookActions hookActions = (IHookActions)m_pHookHelper; hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan); //hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsGraphic); //hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsZoom); //hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsCallout); Application.DoEvents(); m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow(); hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); } } }