ArcGIS是Esri公司集40余年地理信息系统(GIS)咨询和研发经验,奉献给用户的一套完整的GIS平台产品,具有强大的地图制作、空间数据管理、空间分析、空间信息整合、发布与共享的能力。本人主要就AE搭建框架做简单的介绍

框架是指一个系统的全部或部分可复用设计,通常由一组抽象类和类之间的协助组成,其有几个特点。

1.模块化:应用框架可以从逻辑上划分为若干个不同的功能模块。

2.可重用性:代码的可重用性是衡量代码健壮性的一个标志,无论是函数,类,接口,还是其他更高层次的模型,都是为了提高其重用性。

3.可扩展性:可扩展性是应用框架一个最显著地标志,他意味着框架的能力具有可生长性。

其实arcmap也是一个可以扩展的框架,下面我们通过对arcmap的框架的研究来学习如何搭建自己的框架

首先我们打开arcmap编写一个简单的宏

宏命名为zoomin--实现一个简单的放大功能

 Dim imxdocument As imxdocument
Dim penovlop As IEnvelope
Set imxdocument = ThisDocument
Set penovlop = imxdocument.ActiveView.Extent
penovlop.Expand 0.2, 0.2, True
imxdocument.ActiveView.Extent = penovlop
imxdocument.ActiveView.Refresh

保存宏,在菜单--自定义--自定义模式--工具条  新建工具条

我们在arcmap工具条看到一个新的工具栏,

在菜单--自定义--自定义模式--命令  找到 --宏   将我们刚才写的宏拖到菜单栏,这样我们就实现 了一个简单的功能

如此可见arcmap是一个可拓展的框架

2.通过实现接口或者抽象类的方法实现arcgis功能

如图安装了arcgis后 可以使用arcgis addin 来扩展功能

 namespace ClassLibrary1
{
/// <summary>
/// Command that works in ArcMap/Map/PageLayout
/// </summary>
[Guid("86fbcea5-043b-404a-a00c-5c480b42f51e")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("ClassLibrary1.Command1")]
public sealed class Command1 : BaseCommand
{
// 将.net 注册为com函数
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType); //
// TODO: Add any COM registration code here
//
} [ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType); //
// TODO: Add any COM unregistration code here
//
} #region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Register(regKey);
ControlsCommands.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Unregister(regKey);
ControlsCommands.Unregister(regKey);
} #endregion
#endregion private IHookHelper m_hookHelper = null;
public Command1()
{
// 初始化
// TODO: Define values for the public properties
//
base.m_category = ""; //localizable text
base.m_caption = ""; //localizable text
base.m_message = "This should work in ArcMap/MapControl/PageLayoutControl"; //localizable text
base.m_toolTip = ""; //localizable text
base.m_name = ""; //unique id, non-localizable (e.g. "MyCategory_MyCommand") try
{
//
// TODO: change bitmap name if necessary
//
string bitmapResourceName = GetType().Name + ".bmp";
base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
}
} #region Overridden Class Methods /// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
//重写基类
if (hook == null)
return; try
{
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
if (m_hookHelper.ActiveView == null)
m_hookHelper = null;
}
catch
{
m_hookHelper = null;
} if (m_hookHelper == null)
base.m_enabled = false;
else
base.m_enabled = true; // TODO: Add other initialization code
} /// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
//全图显示
IMapControl2 Pmapcontrol2 = m_hookHelper as IMapControl2;
Pmapcontrol2.Extent = Pmapcontrol2.FullExtent;
Pmapcontrol2.Refresh();
} #endregion
}
}
生成dll文件,将其bin下面的 tlb.格式的文件 加载到 arcmap

二:基于simplegis的水电工程系统

初始化
  #region 私有变量
IDockableMapWindow m_pMapDockWindow = null;
private IFramework m_pFramework = null;
private ITocWindow m_pTocWindow = new TocWindow();
private bool m_bCanceledExit = false;
//private License m_pLicense = null;
#endregion #region 构造函数和窗体事件函数
public MainForm()
{
//ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
//this.m_pLicense = System.ComponentModel.LicenseManager.Validate(typeof(MainForm), this);
m_pMapDockWindow = new MapDockWindow();
this.Controls.Add(m_pMapDockWindow as Control); InitializeComponent();
this.Load += new EventHandler(MainForm_Load);
this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
(m_pMapDockWindow as Control).Dock = DockStyle.Fill; #region 初始化框架
this.m_pFramework = new FrameworkClass();
this.m_pFramework.MdiForm = this;
IBarManager pBarManager = new BarManagerClass();
pBarManager.BarManager = this.barManager1;
IDockManager pDockManager = new DockManagerClass();
pDockManager.DockManager = this.barManager1;
this.m_pFramework.BarManager = pBarManager;
this.m_pFramework.DockManager = pDockManager;
//(this.m_pFramework as ICommandLineManager).CommandLineWindow = this.m_frmCommandLine;
#endregion #region 命令工具栏赋值
//this.m_frmCommandLine.Framework = this.m_pFramework;
//this.m_frmCommandLine.DockManager = this.dockPanel1;
#endregion # region 加载TOC
DockableTocControl ctrToc = new DockableTocControl();
IContentsViewManager pContensViewManager = ctrToc as IContentsViewManager;
IContentsView pContentsView = new DisplayWindow();
pContensViewManager.AddContentsView(pContentsView);
pContentsView = new DataSourceWindow();
pContensViewManager.AddContentsView(pContentsView);
pContentsView = new CatalogWindow();
pContensViewManager.AddContentsView(pContentsView);
pContentsView = new VisibleWindow();
pContensViewManager.AddContentsView(pContentsView);
pContentsView = new SelectionView();
pContensViewManager.AddContentsView(pContentsView); pDockManager.DockWindow(ctrToc as IDockableWindow);
IDockableWindow pDockableWindow = pDockManager.GetDockableWindow((ctrToc as IDockableWindow).ID);
this.m_pTocWindow.Toc = pDockableWindow;
this.m_pTocWindow.DockManager = this.barManager1;
this.m_pFramework.OverviewWindow = pContensViewManager.OverviewWindow;
this.m_pFramework.TocWindow = this.m_pTocWindow;
#endregion #region 加载地图控件
this.m_pFramework.DelayEvents(true);
this.m_pFramework.Hook = this.m_pMapDockWindow.Hook;
this.m_pFramework.ActiveMapControl = this.m_pMapDockWindow.ActiveMapControl; #endregion
#region 加载命令窗体 #endregion #region 符号库
IStyleGallery pStyleGallery = new StyleGalleryClass(); string sStyleFile = Application.StartupPath + @"\SimpleGIS.style";
if (System.IO.File.Exists(sStyleFile))
{
(pStyleGallery as IStyleGalleryStorage).AddFile(sStyleFile);
}
(pStyleGallery as IStyleGalleryStorage).TargetFile = sStyleFile;
//if (System.IO.File.Exists(Application.StartupPath + @"\Civic.ServerStyle"))
//{
// (pStyleGallery as IStyleGalleryStorage).AddFile(Application.StartupPath + @"\Civic.ServerStyle");
//}
this.m_pFramework.StyleGallery = pStyleGallery;
#endregion #region 绑定图层显示控件和鹰眼图
this.m_pTocWindow.ContentsViewManager.SetBuddyControl(this.m_pMapDockWindow.Hook, this.m_pFramework);
IOverviewWindow pOverviewWindow = this.m_pTocWindow.ContentsViewManager.OverviewWindow;
if (pOverviewWindow != null)
{
pOverviewWindow.MainActiveView = this.m_pFramework.Application.ActiveView;
pOverviewWindow.StyleGallery = this.m_pFramework.Application.StyleGallery;
pOverviewWindow.Framework = this.m_pFramework;
}
#endregion #region 创建状态栏
StatusStrip ctrSta = new StatusStrip();
ctrSta.Dock = DockStyle.Bottom;
ToolStripStatusLabel lblToolTip = new ToolStripStatusLabel();
ctrSta.Items.Add(lblToolTip);
ToolStripStatusLabel lblMapPosition = new ToolStripStatusLabel();
lblMapPosition.Spring = true;
lblMapPosition.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
ctrSta.Items.Add(lblMapPosition);
this.Controls.Add(ctrSta);
IStatusBar pStatusBar = new StatusBarClass();
pStatusBar.StatusBarControl = ctrSta;
pStatusBar.BarMessageItem = lblToolTip;
pStatusBar.BarMousePositionItem = lblMapPosition; pBarManager.StatusBar = pStatusBar; #endregion #region 加载插件
string sMainFrameCommands = ConfigurationManager.AppSettings["PluginFile"];
pBarManager.CreateToolBar(Application.StartupPath + "\\" + sMainFrameCommands);
#endregion #region 绑定右键菜单控件
pOverviewWindow = this.m_pFramework.OverviewWindow;
if (pOverviewWindow is IControlContextMenu)
{
pBarManager.RegisterControlWithPopupContext(pOverviewWindow as IControlContextMenu);
IControlContextMenu2 pControlContextMenu = pOverviewWindow as IControlContextMenu2;
pControlContextMenu.Clear();
pControlContextMenu.AddItem("RefreshOverview", false);
pControlContextMenu.AddItem("Overview", false);
pControlContextMenu.AddItem("OverviewWindowProperty", true);
}
if (this.m_pTocWindow.ContentsViewManager != null)
{
for (int i = ; i < this.m_pTocWindow.ContentsViewManager.Count; i++)
{
IContentsView pView = this.m_pTocWindow.ContentsViewManager.ContentsView(i);
if (pView is IControlContextMenu)
{
pBarManager.RegisterControlWithPopupContext(pView as IControlContextMenu);
}
}
}
#endregion
} private void MainForm_Load(object sender, EventArgs e)
{
try
{
this.Text = ConfigurationManager.AppSettings["AppName"];
}
catch (Exception)
{
}
//初始化一个当前工具
ICommand pCommand = this.m_pFramework.FindCommand("SelectElementTool");
if (pCommand is ITool)
{
this.m_pFramework.CurrentTool = pCommand as ITool;
} ////打开配置文件中指定的MXD文档
//string sMxd = ConfigurationManager.AppSettings["Mxd"];
//pCommand = this.m_pFramework.FindCommand("OpenDocumentCommand");
//if (pCommand != null && System.IO.File.Exists(sMxd))
//{
// IMxdFile pMxdFile = pCommand as IMxdFile;
// if (pMxdFile != null)
// {
// pMxdFile.MxdPath = sMxd;
// pMxdFile.Open();
// }
//}
this.m_pFramework.DelayEvents(false);
} private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
ICommand pCommand = this.m_pFramework.FindCommand("ExitApplication");
if (pCommand != null)
{
if (pCommand is IExitApplicationEvents)
{
(pCommand as IExitApplicationEvents).CancelExitApplicationEvent += new OnCancelExitApplicationEventHandler(MainForm_CancelExitApplicationEvent);
}
e.Cancel = this.m_bCanceledExit;
}
} void MainForm_CancelExitApplicationEvent(bool bCanceledExit)
{
this.m_bCanceledExit = bCanceledExit;
}
#endregion
}

功能配置:

系统会自动检测配置功能

基于AE的SimpleGIS框架的搭建的更多相关文章

  1. 基于C/S架构的3D对战网络游戏C++框架 _05搭建系统开发环境与Boost智能指针、内存池初步了解

    本系列博客主要是以对战游戏为背景介绍3D对战网络游戏常用的开发技术以及C++高级编程技巧,有了这些知识,就可以开发出中小型游戏项目或3D工业仿真项目. 笔者将分为以下三个部分向大家介绍(每日更新): ...

  2. 基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建

    基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建 前言 最近做回后台开发,重新抓起以前学过的SSM(Spring+Sp ...

  3. 基于Maven的SSM框架搭建

    Maven + Spring + Spring MVC + Mybatis + MySQL整合SSM框架 1.数据库准备 本文主要想实现SSM框架的搭建,并基于该框架实现简单的登录功能,那么先新建一张 ...

  4. 基于C/S架构的3D对战网络游戏C++框架 _06搭建C/S架构的基本通信框架(尚未写完会重新编辑后再发出)

    本系列博客主要是以对战游戏为背景介绍3D对战网络游戏常用的开发技术以及C++高级编程技巧,有了这些知识,就可以开发出中小型游戏项目或3D工业仿真项目. 笔者将分为以下三个部分向大家介绍(每日更新): ...

  5. 基于MEF的插件框架之总体设计

    基于MEF的插件框架之总体设计 1.MEF框架简介 MEF的全称是Managed Extensibility Framework(MEF),其是.net4.0的组成部分,在3.5上也可以使用.熟悉ja ...

  6. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试

    这一部分的主要目的是 配置spring-service.xml  也就是配置spring  并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...

  7. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)

    用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...

  8. NET Core微服务之路:自己动手实现Rpc服务框架,基于DotEasy.Rpc服务框架的介绍和集成

    本篇内容属于非实用性(拿来即用)介绍,如对框架设计没兴趣的朋友,请略过. 快一个月没有写博文了,最近忙着两件事;    一:阅读刘墉先生的<说话的魅力>,以一种微妙的,你我大家都会经常遇见 ...

  9. 【Struts2】Struts2框架的搭建

    1,Struts2简介 struts1和struts2都是由Apache组织发布的,但是比较有趣的是struts2和struts1并没有“血缘关系”.在Apache发布struts1之后,当时是还是非 ...

随机推荐

  1. 一些iOS笔试题目

    1.什么是arc?(arc是为了解决什么问题诞生的?) 首先解释ARC: automatic reference counting自动引用计数. ARC几个要点: 在对象被创建时 retain cou ...

  2. 你好,C++(10)这次的C++考试你过了没有?C++中表示逻辑判断的布尔数据类型

    3.4  布尔类型 在日常生活中,我们除了需要使用int类型的变量表示216路公交车:需要使用float类型的变量表示西红柿3.5元一斤,有时候还需要表示一种数据,那就是逻辑状态: “这次的C++考试 ...

  3. 简洁的MysqlHelper

    把MySqlXXX的类更改为SqlXXX就可以成为sqlHelper. 另外C#也提供了MysqlHelper和sqlHelper,用起来也挺方便的. public class MySqlHelper ...

  4. C盘不能新建文件的问题解决办法

    C盘不能新建文件的问题解决办法 主要症状: 1.C 盘文件不能修改2.C 盘不能新建文件3.总之就是只能读取不能,写入和修改这样对于平时操作造成了极其的不方便~~~复制文件到C 盘会提示:错误0×80 ...

  5. html5插入视频

  6. Codeforces 138D World of Darkraft

    有一个n*m 的棋盘,每个点上标记了L,R,X 中的一个每次能选择一个没有被攻击过的点(i,j),从这个点开始发射线,射线形状为:1. 若字符是 L,向左下角和右上角发,遇到被攻击过的点就停下来2. ...

  7. 打印机PCL漏洞原理分析

    0x01 漏洞概要 PCL代表打印机控制语言(Printer Control Language),由惠普公司开发,并被广泛使用的一种打印机协议.关于另一种页面描述语言,应该提一提由Adobe设计的Po ...

  8. IIS的安装与配置详细图解教程。

    一.这里讲的是在WINDOWS 2003下的IIS组件的安装,至于WINDOWS XP,请看这里:   开始-控制面板-添加或删除程序-添加/删除windows组件   勾选应用程序服务器   勾选I ...

  9. Intention Locks 意向锁

    Intention Locks 意向锁 InnoDB 支持多颗粒度锁定允许row-level locks和锁整个表共存. 为了使锁在多个颗粒级别实现, 额外类型的锁被称为意向锁是被使用. . Inte ...

  10. CSU 1021 从m个不同元素中取出n (n ≤ m)个元素的所有组合的个数,叫做从m个不同元素中取出n个元素的组合数。组合数的计算公式如下: C(m, n) = m!/((m - n)!n!) 现在请问,如果将组合数C(m, n)写成二进制数,请问转这个二进制数末尾有多少个零。

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82974#problem/B 解题思路:这个题目就是求因子的个数, m!/((m ...