ArcGISEngine二次开发(1):系统基本功能

来源:互联网 发布:软件专利范文 编辑:程序博客网 时间:2024/06/05 01:54

ArcGISEngine二次开发(1):

系统基本功能

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.SystemUI;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS


在调试之前,需要在Program.csApplication.SetCompatibleTextRenderingDefault(false);与Application.Run(new Form1());
之间加上该代码ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);


软件界面


//添加shapefile文件ICommand pCmd = new ControlsAddDataCommand();pCmd.OnCreate(axMapControl1.Object);//Axcontrols对应封装的.net组件,controls对应于com组件,在使用时须要添加ESRI.Arcgis.Axcontrols名空间和ESRI.Arcgis.Controls名空间。两者包含了所有AE组件。pCmd.OnClick();

//显示整个地图操作//为何末尾两句代码与添加数据代码不一样,其原因是:命令是无状态的,而工具是有状态的,一个主控件(MapControl、PagelayoutControl、GlobeControl、SceneControl)都有CurrentTool属性,也就是说整个系统当前的工具只有一个。电脑一般情况下只有一个鼠标和一个键盘,要响应鼠标和键盘的事件,只能是一个工具。如果想切换工具时,直接给这些控件的CurrentTool属性赋值就可以了。ICommand wholemap = new ControlsMapFullExtentCommandClass(); wholemap.OnCreate(axMapControl1.Object);wholemap.OnClick();ITool ptool = wholemap as ITool;axMapControl1.CurrentTool = ptool;

//地图抓手功能ICommand pan = new ControlsMapPanToolClass();pan.OnCreate(axMapControl1.Object);pan.OnClick();ITool ptool = pan as ITool;axMapControl1.CurrentTool = ptool;

//属性查询功能ICommand identify = new ControlsMapIdentifyToolClass();identify.OnCreate(axMapControl1.Object);identify.OnClick();ITool ptool = identify as ITool;axMapControl1.CurrentTool = ptool;

//zoomin放大功能ICommand zoomin = new ControlsMapZoomInFixedCommandClass();zoomin.OnCreate(axMapControl1.Object);zoomin.OnClick();ITool ptool = zoomin as ITool;axMapControl1.CurrentTool = ptool;

//缩小zoomout功能ICommand zoomout = new ControlsMapZoomOutFixedCommandClass();zoomout.OnCreate(axMapControl1.Object);zoomout.OnClick();ITool ptool = zoomout as ITool;axMapControl1.CurrentTool = ptool;