---------------------------------------------------------------------------------------------------------
●·● 目录:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A1个 ╠══════════════════════════════════════════════════╣
╚════════╝
第一部分:获取选择要素的属性值:
通过 IEnumFeature 即可存储 pMap.FeatureSelection,但这个时候只能获取属性的字段的前两列,也是最没用的两列,要想获取其他的字段属性,则要引入 IEnumFeatureSetup,将属性 AllFields 设置为 true 才可!
IMap pMap = axMapControl1.Map;
ISelection pSelection = pMap.FeatureSelection; //获取选择集
IEnumFeatureSetup pEnumFeatureSetup = pSelection as IEnumFeatureSetup; //将其转为setup
pEnumFeatureSetup.AllFields = true; //设置所有字段显示
IEnumFeature pEnumFeature = pEnumFeatureSetup as IEnumFeature; //将其转为 pEnumFeature
pEnumFeature.Reset(); //从头开始,不是必要的!
IFeature pFeature = pEnumFeature.Next(); //下一个要素
string str = "";
while (pFeature != null)
{
str += pFeature.get_Value(pFeature.Fields.FindField("Name")).ToString() + "\n";
pFeature = pEnumFeature.Next();
}
MessageBox.Show(str);
参考:http://huangdingjun.blog.163.com/blog/static/3110639201108112823953/
---------------------------------------------------------------------------------------------------------
●·● Geodatabase 命名空间
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G1个 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IEnumFeatureSetup 接口:
Provides access to members that define behavior of IEnumFeature.
Product Availability
Members
Description | ||
---|---|---|
![]() | AllFields | Indicates if returned features will contain all fields. |
![]() | Recycling | Indicates if returned features recycle. |
CoClasses that implement IEnumFeatureSetup
CoClasses and Classes | Description |
---|---|
MapSelection (esriCarto) | Maintains the map's feature selection. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G2个 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IEnumFeature 接口:
Provides access to members that hand out enumerated features and reset the enumeration.
Product Availability
Members
Description | ||
---|---|---|
![]() | Next | Retrieves the next Feature in the enumeration sequence. |
![]() | Reset | Resets the enumeration sequence to the beginning. |
CoClasses that implement IEnumFeature
CoClasses and Classes | Description |
---|---|
EditSelection (esriEditor) | Enumerates the editable selected features. |
MapSelection (esriCarto) | Maintains the map's feature selection. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A2个 ╠══════════════════════════════════════════════════╣
╚════════╝
第二部分:闪烁显示选择要素:
第一步是建立筛选条件,这个时候要用到 IQueryFilter 接口,通过其 WhereClause 属性可以建立 SQL 语句进行筛选,然后循环!
第二步是建立闪烁,建立闪烁通过 axMapControl 的 FlashShape 方法即可实现,如下所示:
IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = "Area > 20";
IFeatureCursor pFeatureCursor = pFeatureLayer.Search(pQueryFilter, false); //建立查询
IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null) //循环查询要素
{
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol(); //建立闪烁样式
IRgbColor pColor = new RgbColor();
pColor.Red = 255;
pSimpleFillSymbol.Color = pColor;
IPolygon pPolygon = pFeature.Shape as IPolygon; //闪烁几何体
axMapControl1.FlashShape(pPolygon, 3, 20, pSimpleFillSymbol); //闪烁几何体
object symbol = pSimpleFillSymbol as object; //后面要用到ref,这里要转为 object 类型!
axMapControl1.DrawShape(pPolygon, ref symbol); //在绘制此要素几何!
pFeature = pFeatureCursor.NextFeature(); //循环下一个要素
}
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A3个 ╠══════════════════════════════════════════════════╣
╚════════╝
第三部分:取消选择的要素:
此方法在 IMap 接口中实现的,即 ClearSelection 方法!
IMap pMap = axMapControl1.Map;
pMap.ClearSelection();
axMapControl1.ActiveView.Refresh();