文档详情

C# ArcEngine 添加打开Shp矢量数据.doc

发布:2020-02-22约1.19千字共2页下载文档
文本预览下载声明
using System; using System.Collections.Generic; usingSystem.ComponentModel; using System.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; usingESRI.ArcGIS.Carto; usingESRI.ArcGIS.DataSourcesFile; usingESRI.ArcGIS.Geodatabase; private void 打开矢量数据ToolStripMenuItem_Click(object sender, EventArgs e) { ? ? OpenFileDialog ?file ?= ?new ?OpenFileDialog(); ? ? file.Filter ?= ?Shp文件|*.shp; ? ? if ( file.ShowDialog() == DialogResult.OK ) ? ? ? ? { ? ? ? ? ? ? string ?path ?= ?file.FileName; ? ? ? ? ? ? string ?folder ?= ?System.IO.Path.GetDirectoryName(path); ? ? ? ? ? ? string ?filename ?= ?System.IO.Path.GetFileName(path); ? ? ? ? ? ? IWorkspaceFactory ?wsf ?= ?new ?ShapefileWorkspaceFactory(); ? ? ? ? ? ? IWorkspace ?ws ?= ?wsf.OpenFromFile(folder,0); ? ? ? ? ? ? IFeatureWorkspace ?fws ?= ?ws ?as ?IFeatureWorkspace; ? ? ? ? ? ? IFeatureClass ?fc ?= ?fws.OpenFeatureClass(filename); ? ? ? ? ? ? IFeatureLayer ?fl ?= ?new ?FeatureLayer(); ? ? ? ? ? ? fl.FeatureClass ?= ?fc; ? ? ? ? ? ? fl.Name ?= ?fc.AliasName; ? ? ? ? ? ? axMapControl1.AddLayer(fl); ? ? ? ? ? ??axMapControl1.ActiveView.Refresh(); ? ? ? ? } ? ? else ? ? ? ? return; }
显示全部
相似文档