64. int layerCount = axMapControl1.LayerCount; 65. for (int i = 0; i < layerCount; i++) 66. {
67. pLayer = axMapControl1.get_Layer(i); 68. pFeatureLayer = (IFeatureLayer)pLayer; 69. pFeatureClass = pFeatureLayer.FeatureClass;
70. pFeatureCursor = pFeatureClass.Search((IQueryFilter)pSpatialFilter,
false);
71. pFeature = pFeatureCursor.NextFeature(); 72. while (pFeature != null) 73. {
74. listView1.Items.Add(pLayer.Name); 75. } 76. } 77. } 78. } 79. }
39.关于更改符号的代码 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20.
private void axTOC1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) {
esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; IBasicMap basicMap = null; ILayer layer = null; object unk = null; object data = null;
axTOC1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);
if (e.button == 1) {
if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass) {
//取得图例
ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
//创建符号选择器SymbolSelector实例
FormSymbolControl SymbolSelectorFrm = new FormSymbolControl(pLegendClass, layer);
if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK) {
//局部更新主Map控件
//m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
21. 22. 23. 24. 25. 26. 27. 28. 29. }
39. 关于显示属性的代码 40. ///
41. /// 填充DataTable中的数据 42. /// 43. /// 44. /// 45. ///
46. public static DataTable CreateDataTable(ILayer pLayer, string tableName) 47. {
48. //创建空DataTable
49. DataTable pDataTable = CreateDataTableByLayer(pLayer, tableName); 50. //创建DataTable的行对象 51. DataRow pDataRow = null; 52. //取得图层类型
53. string shapeType = getShapeType(pLayer); 54. //从ILayer查询到ITable
55. ITable pTable = pLayer as ITable;
56. ICursor pCursor = pTable.Search(null, false); 57. //取得ITable中的行信息
58. IRow pRow = pCursor.NextRow(); 59. int n = 0;
60. while (pRow != null) 61. {
62. //新建DataTable的行对象
63. pDataRow = pDataTable.NewRow();
64. for (int i = 0; i < pRow.Fields.FieldCount; i++) 65. {
axMap1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
//设置新的符号
pLegendClass.Symbol = SymbolSelectorFrm.pSymbol; //更新主Map控件和图层控件 this.axMap1.ActiveView.Refresh(); this.axTOC1.Refresh(); } } }
66. //如果字段类型为esriFieldTypeGeometry,则根据图层类型设置字段值 67. if (pRow.Fields.get_Field(i).Type ==
esriFieldType.esriFieldTypeGeometry) 68. {
69. pDataRow = shapeType; 70. }
71. //当图层类型为Anotation时,要素类中会有esriFieldTypeBlob类型的数据, 72. //其存储的是标注内容,如此情况需将对应的字段值设置为Element 73. else if (pRow.Fields.get_Field(i).Type ==
esriFieldType.esriFieldTypeBlob) 74. {
75. pDataRow = \76. } 77. else 78. {
79. pDataRow = pRow.get_Value(i); 80. } 81. }
82. //添加DataRow到DataTable 83. pDataTable.Rows.Add(pDataRow); 84. pDataRow = null; 85. n++;
86. pRow = pCursor.NextRow(); 87. ////为保证效率,一次只装载最多条记录 88. //if (n == 2000) 89. //{
90. // pRow = null; 91. //} 92. //else 93. //{
94. // pRow = pCursor.NextRow(); 95. //} 96. }
97. return pDataTable; }
41.关于IFeature变量添加进List
List
3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13.
{
pFC_TER_LN =
pFeatureWorkspace.OpenFeatureClass(\} catch {
richTextBox1.SelectionStart = richTextBox1.Text.Length;
richTextBox1.SelectedText = \地形图:\e + \中没有TER_LN_l图层!\\n\
richTextBox1.Refresh(); continue; }
for (int i = 0; i < pFC_TER_LN.FeatureCount([color=Red]null[/color]); i++) ///将该图层的每个Feature提取出来以供编辑时依次赋值,并且可以设置FeatureCount方法的参数为一个IQueryFilter类型的变量,就可以实现你所要求的方法了,用Search()方法,应该是不可以的,希望你们试一下。 14. 15. 16. }
{
pFeatrue = pFC_TER_LN.GetFeature(i); listFeature.Add(pFeatrue);
42.关于IDataStatistics接口(esriGeodatabase)
IDataStatistics接口的第一个属性Statistics(只读,返回一个IStatisticsResults类型的变量,可以用该变量去求指定域的数学值)
IDataStatistics接口的第二个属性UniqueValues(只读,返回一个IEnumVariantSimple类型的变量,该变量可以遍历指定域的所有Value)
IDataStatistics接口的第三个属性UniqueValueCount(只读,返回指定域的值的数量) IDataStatistics接口的第四个属性Field(读写,读取或者设置指定域,参数为String类型的域名的名称)
IDataStatistics接口的第五个属性Cursor(只写,在做对域的查询及各种操作之前一定要设置一个游标的参数,可以去设置QueryFilter来过滤) 例子代码:
The following code uses a DataStatistics object to create a list of unique values in the \field and also display the mean of these values (notice that the cursor must be reset to obtain the mean value after accessing the unique values):
1.
Dim pMxDoc As esriArcMapUI.IMxDocument, pFLayer As esriCarto.IFeatureLayer,
pData As esriGeoDatabase.IDataStatistics 2. Dim pCursor As esriGeoDatabase.ICursor, pStatResults As esriSystem.IStatisticsResults 3. 4.
Set pMxDoc = ThisDocument
Set pFLayer = pMxDoc.FocusMap.Layer(0)