AE学习笔记

在安装完AE和VS后,启动VS,新建项目,在控件工具栏看到列出的AE控件,主要会使用的是MapControl(数据视图)、PageLayoutControl(布局视图),TOOCControl(需设置与MapControl、PageLayoutControl和SceneControl的伙伴关系(buddy)),ToolbarControl(通过右键属性->Iems添加命令按钮)以及LisenceControl(每个窗体都必须加载,可以控制功能权限)。

AE学习笔记_第1张图片AE学习笔记_第2张图片

也可以自己添加控件,需要添加引用及命名空间Controls,SystemUI

(1)实现打开地图,添加一button控件

//实现加载地图文档

OpenFileDialog openFileDialog=new OpenFileDialog();

openFileDialog.Title = "打开地图文档";

 openFileDialog.Filter = "map document(*.mxd)|*.mxd";
 openFileDialog.ShowDialog();
  string filepath = openFileDialog.FileName;
  if (axMapControl1.CheckMxFile(filepath))
   {
       axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerHourglass;
        axMapControl1.LoadMxFile(filepath, 0, Type.Missing);
         axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerDefault;
     }
     else
     {
           MessageBox.Show(filepath + "不是有效地地图文档");
      }

(2)实现漫游

ICommand pCommand = new ControlsMapPanToolClass();
pCommand.OnCreate(axMapControl1.Object);
 axMapControl1.CurrentTool = pCommand as ITool;

(3)全局视图

ICommand pCommand = new ControlsMapFullExtentCommandClass();
 pCommand.OnCreate(axMapControl1.Object);
  pCommand.OnClick();

(4)放大

ICommand pCommand = new ControlsMapZoomInToolClass();
pCommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pCommand as ITool;

(5)缩小

ICommand pCommand = new ControlsMapZoomOutToolClass();
 pCommand.OnCreate(axMapControl1.Object);
 axMapControl1.CurrentTool = pCommand as ITool;

(6)属性查询

ICommand pCommand = new ControlsMapIdentifyToolClass();
pCommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pCommand as ITool;

AE学习笔记_第3张图片
今天用到ICommand和QI


你可能感兴趣的:(c#)