关键点:
对IArray、IFeature.ShapeCopy、HookHelperClass以及IHookActions.DoActionOnMultiple的正确使用。
代码如下:
002 |
using System.Collections.Generic; |
003 |
using System.ComponentModel; |
004 |
using System.Drawing; |
008 |
using System.Windows.Forms; |
009 |
using ESRI.ArcGIS.Geodatabase; |
010 |
using ESRI.ArcGIS.Carto; |
011 |
using ESRI.ArcGIS.Display; |
012 |
using ESRI.ArcGIS.Geometry; |
013 |
using ESRI.ArcGIS.Controls; |
014 |
using ESRI.ArcGIS.esriSystem; |
021 |
public partial class FlashMutiGeometry : UserControl |
023 |
public FlashMutiGeometry() |
025 |
InitializeComponent(); |
031 |
/// <param name="pathMap"></param> |
032 |
public void LoadMap( string pathMap) |
034 |
axMapControl1.LoadMxFile(pathMap); |
040 |
/// <param name="where">查询条件</param> |
041 |
public void FilterLayer( string where) |
043 |
IFeatureLayer flyr = (IFeatureLayer)axMapControl1.get_Layer(0); |
044 |
IFeatureClass fcls = flyr.FeatureClass; |
046 |
IQueryFilter queryFilter = new QueryFilterClass(); |
047 |
queryFilter.WhereClause = where; |
050 |
ZoomToSelectedFeature(flyr, queryFilter); |
053 |
IFeatureCursor featureCursor = fcls.Search(queryFilter, true ); |
054 |
FlashPolygons(featureCursor); |
060 |
/// <param name="pFeatureLyr"></param> |
061 |
/// <param name="pQueryFilter"></param> |
062 |
private void ZoomToSelectedFeature(IFeatureLayer pFeatureLyr, IQueryFilter pQueryFilter) |
067 |
IRgbColor pLineColor = new RgbColor(); |
068 |
pLineColor.Red = 255; |
069 |
ILineSymbol ilSymbl = new SimpleLineSymbolClass(); |
070 |
ilSymbl.Color = pLineColor; |
074 |
ISimpleFillSymbol ipSimpleFillSymbol = new SimpleFillSymbol(); |
075 |
ipSimpleFillSymbol.Outline = ilSymbl; |
076 |
RgbColor pFillColor = new RgbColor(); |
077 |
pFillColor.Green = 60; |
078 |
ipSimpleFillSymbol.Color = pFillColor; |
079 |
ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; |
082 |
IFeatureSelection pFtSelection = pFeatureLyr as IFeatureSelection; |
083 |
pFtSelection.SetSelectionSymbol = true ; |
084 |
pFtSelection.SelectionSymbol = (ISymbol)ipSimpleFillSymbol; |
085 |
pFtSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false ); |
089 |
ISelectionSet pSelectionSet = pFtSelection.SelectionSet; |
091 |
IEnumGeometry pEnumGeom = new EnumFeatureGeometry(); |
092 |
IEnumGeometryBind pEnumGeomBind = pEnumGeom as IEnumGeometryBind; |
093 |
pEnumGeomBind.BindGeometrySource( null , pSelectionSet); |
094 |
IGeometryFactory pGeomFactory = new GeometryEnvironmentClass(); |
095 |
IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom); |
097 |
axMapControl1.ActiveView.Extent = pGeom.Envelope; |
098 |
axMapControl1.ActiveView.Refresh(); |
104 |
/// <param name="featureCursor"></param> |
105 |
private void FlashPolygons(IFeatureCursor featureCursor) |
107 |
IArray geoArray = new ArrayClass(); |
108 |
IFeature feature = null ; |
109 |
while ((feature = featureCursor.NextFeature()) != null ) |
112 |
geoArray.Add(feature.ShapeCopy); |
116 |
HookHelperClass m_pHookHelper = new HookHelperClass(); |
117 |
m_pHookHelper.Hook = axMapControl1.Object; |
118 |
IHookActions hookActions = (IHookActions)m_pHookHelper; |
120 |
hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan); |
123 |
Application.DoEvents(); |
124 |
m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow(); |
126 |
hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); |
截图如下:

来自http://www.cnblogs.com/flyingfish/archive/2010/02/11/1667533.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理