同时闪烁多个要素代码(ArcEngine)

/// <summary> 
/// 根据查询条件构造
/// </summary> 
/// <param name="where">查询条件</param> 
public void FilterLayer(string where) 

IFeatureLayer flyr = (IFeatureLayer)axMapControl1.get_Layer(0); 
IFeatureClass fcls = flyr.FeatureClass; 

IQueryFilter queryFilter = new QueryFilterClass(); 
queryFilter.WhereClause = where; 

// 缩放到选择结果集,并高亮显示 
ZoomToSelectedFeature(flyr, queryFilter); 

//闪烁选中得图斑 
IFeatureCursor featureCursor = fcls.Search(queryFilter, true); 
FlashPolygons(featureCursor); 
}

 

/// <summary> 
/// 缩放到选择结果集,并高亮显示 
/// </summary> 
/// <param name="pFeatureLyr"></param> 
/// <param name="pQueryFilter"></param> 
private void ZoomToSelectedFeature(IFeatureLayer pFeatureLyr, IQueryFilter pQueryFilter) 

#region 高亮显示查询到的要素集合 

//符号边线颜色 
IRgbColor pLineColor = new RgbColor(); 
pLineColor.Red = 255; 
ILineSymbol ilSymbl = new SimpleLineSymbolClass(); 
ilSymbl.Color = pLineColor; 
ilSymbl.Width = 5; 

//定义选中要素的符号为红色 
ISimpleFillSymbol ipSimpleFillSymbol = new SimpleFillSymbol(); 
ipSimpleFillSymbol.Outline = ilSymbl; 
RgbColor pFillColor = new RgbColor(); 
pFillColor.Green = 60; 
ipSimpleFillSymbol.Color = pFillColor; 
ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; 

//选取要素集 
IFeatureSelection pFtSelection = pFeatureLyr as IFeatureSelection; 
pFtSelection.SetSelectionSymbol = true; 
pFtSelection.SelectionSymbol = (ISymbol)ipSimpleFillSymbol; 
pFtSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); 

#endregion 

ISelectionSet pSelectionSet = pFtSelection.SelectionSet; 
//居中显示选中要素 
IEnumGeometry pEnumGeom = new EnumFeatureGeometry(); 
IEnumGeometryBind pEnumGeomBind = pEnumGeom as IEnumGeometryBind; 
pEnumGeomBind.BindGeometrySource(null, pSelectionSet); 
IGeometryFactory pGeomFactory = new GeometryEnvironmentClass(); 
IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom); 

axMapControl1.ActiveView.Extent = pGeom.Envelope; 
axMapControl1.ActiveView.Refresh(); 


/// <summary> 
/// 闪烁选中得图斑 
/// </summary> 
/// <param name="featureCursor"></param> 
private void FlashPolygons(IFeatureCursor featureCursor) 

IArray geoArray = new ArrayClass(); 
IFeature feature = null; 
while ((feature = featureCursor.NextFeature()) != null) 

//feature是循环外指针,所以必须用ShapeCopy 
geoArray.Add(feature.ShapeCopy); 


//通过IHookActions闪烁要素集合 
HookHelperClass m_pHookHelper = new HookHelperClass(); 
m_pHookHelper.Hook = axMapControl1.Object; 
IHookActions hookActions = (IHookActions)m_pHookHelper; 

hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan); 
//hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsGraphic); 
//hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsZoom); 
Application.DoEvents(); 
m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow(); 

hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); 

}

 

from: http://www.cnblogs.com/feilong3540717/archive/2011/07/27/2118651.html

你可能感兴趣的:(ArcEngine)