ArcEngine中同时闪烁多个要素的用户控件代码 转
原创
©著作权归作者所有:来自51CTO博客作者gisoracleplus的原创作品,请联系作者获取转载授权,否则将追究法律责任
ArcEngine中同时闪烁多个要素的用户控件代码
关键点:
对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
posted on
2010-11-01 18:22
gisoracle
阅读(633)
评论(0)
编辑
收藏
举报