●·● 目录:
A1 …………
A2 ………… A3 ………… A4 ………… A5 ………… A6 …………---------------------------------------------------------------------------------------------------------
Visual Studio 2008 + ArcGIS Engine 9.3
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝① 点击下载: 标注:实现了基本 GIS 功能,部分截图如下!
全局:
鹰眼:
自定义工具对话框:面符号:
线符号:
点符号:
右键菜单:
图层属性表:
---------------------------------------------------------------------------------------------------------
Visual Studio 2010 + ArcGIS Engine 10.0
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝② 点击下载: 标注:实现新建shapefile文件,部分截图如下!
属性截图如下:
实现步骤:
- 新建工作空间工厂 IWorkspaceFactory!(矢量数据)
- 新建要素工作空间 IFeatureWorkspace! <IWorkspaceFactory.OpenFromFile()>
- 若指定的文件名存在了,则将其内部的数据删除! <IDataset.Delete()>
- 为要素集新建字段 IFields!
- 新建要素集 IFeatureClass! <IFeatureWorkspace.CreateFeatureClass()>
- 新建要素 IFeature! <IFeatureClass.CreateFeature()>
代码如下:
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(); } ////// 保存文件的完整路径 /// 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; } }}