A1 ………… ESRI_01.zip
A2 ………… 实现:新建shapefile文件
A3 ………… 实现:只显示筛选的要素(IFeatureLayerDefinition)
A4 ………… 实现:高亮显示筛选的要素(IFeatureSelection)
A5 ………… 实现:类似 ArcMap 中 Identify 工具的效果(IIdentify、IArray、IIdentifyObj)
A6 ………… 实现:在 MapControl 上绘制几何图形
---------------------------------------------------------------------------------------------------------
Visual Studio 2008 + ArcGIS Engine 9.3
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 返回目录 ╠══════════════════════════════════════════════════╣
╚════════╝
① 点击下载: >->-> ESRI_01.zip <-<-< 标注:实现了基本 GIS 功能,部分截图如下!
全局:
鹰眼:
面符号:
线符号:
点符号:
右键菜单:
图层属性表:
---------------------------------------------------------------------------------------------------------
Visual Studio 2010 + ArcGIS Engine 10.0
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 返回目录 ╠══════════════════════════════════════════════════╣
╚════════╝
② 点击下载: >->-> NewPoints.zip <-<-< 标注:实现新建shapefile文件,部分截图如下!
属性截图如下:
实现步骤:
代码如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.Carto; using System.IO; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.DataSourcesFile; using ESRI.ArcGIS.Geometry; namespace NewPoints { public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> /// 保存文件的完整路径 /// </summary> string saveFullPath = string.Empty; private void button1_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = Directory.GetCurrentDirectory(); sfd.Filter = "Shp文件(*.shp)|*.shp"; if (sfd.ShowDialog() == DialogResult.OK) { saveFullPath = sfd.FileName; } textBox1.Text = saveFullPath; } private void button2_Click(object sender, EventArgs e) { IFeatureLayer pFeatureLayer = CreateShpFromPoint(saveFullPath); pFeatureLayer.Name = "Point"; axMapControl1.Map.AddLayer(pFeatureLayer); } private IFeatureLayer CreateShpFromPoint(string outfileNamePath) { string folder = System.IO.Path.GetDirectoryName(outfileNamePath); string file = System.IO.Path.GetFileName(outfileNamePath); IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace pFWS = pWSF.OpenFromFile(folder, 0) as IFeatureWorkspace; if (File.Exists(outfileNamePath)) { IFeatureClass featureClass = pFWS.OpenFeatureClass(file); IDataset pDataset = featureClass as IDataset; pDataset.Delete(); } IFields pFields = new FieldsClass(); IFieldsEdit pFieldsEdit = pFields as IFieldsEdit; IField pField = new FieldClass(); IFieldEdit pFieldEdit = pField as IFieldEdit; pFieldEdit.Name_2 = "Shape"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; IGeometryDef pGeometryDef = new GeometryDefClass(); IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit; pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; pFieldEdit.GeometryDef_2 = pGeometryDef; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = pField as IFieldEdit; pFieldEdit.Name_2 = "X"; pFieldEdit.Length_2 = 20; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = pField as IFieldEdit; pFieldEdit.Name_2 = "Y"; pFieldEdit.Length_2 = 20; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; pFieldsEdit.AddField(pField); IFeatureClass pFeatureClass = pFWS.CreateFeatureClass(file, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", ""); for (int i = 0; i < 100;i+=10 ) { for (int j = 0; j < 100;j+=10 ) { IPoint pPoint = new PointClass(); pPoint.PutCoords(i, j); IFeature pFeature = pFeatureClass.CreateFeature(); pFeature.Shape = pPoint as IPoint; pFeature.set_Value(pFeature.Fields.FindField("X"), i.ToString()); pFeature.set_Value(pFeature.Fields.FindField("Y"), j.ToString()); pFeature.Store(); } } IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.FeatureClass = pFeatureClass; return pFeatureLayer; } } }