基于AE的SimpleGIS框架的搭建
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框架的搭建的更多相关文章
- 基于C/S架构的3D对战网络游戏C++框架_05搭建系统开发环境与Boost智能指针、内存池初步了解
本系列博客主要是以对战游戏为背景介绍3D对战网络游戏常用的开发技术以及C++高级编程技巧,有了这些知识,就可以开发出中小型游戏项目或3D工业仿真项目. 笔者将分为以下三个部分向大家介绍(每日更新): ...
- 基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建
基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建 前言 最近做回后台开发,重新抓起以前学过的SSM(Spring+Sp ...
- 基于Maven的SSM框架搭建
Maven + Spring + Spring MVC + Mybatis + MySQL整合SSM框架 1.数据库准备 本文主要想实现SSM框架的搭建,并基于该框架实现简单的登录功能,那么先新建一张 ...
- 基于C/S架构的3D对战网络游戏C++框架_06搭建C/S架构的基本通信框架(尚未写完会重新编辑后再发出)
本系列博客主要是以对战游戏为背景介绍3D对战网络游戏常用的开发技术以及C++高级编程技巧,有了这些知识,就可以开发出中小型游戏项目或3D工业仿真项目. 笔者将分为以下三个部分向大家介绍(每日更新): ...
- 基于MEF的插件框架之总体设计
基于MEF的插件框架之总体设计 1.MEF框架简介 MEF的全称是Managed Extensibility Framework(MEF),其是.net4.0的组成部分,在3.5上也可以使用.熟悉ja ...
- 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试
这一部分的主要目的是 配置spring-service.xml 也就是配置spring 并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...
- 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)
用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...
- NET Core微服务之路:自己动手实现Rpc服务框架,基于DotEasy.Rpc服务框架的介绍和集成
本篇内容属于非实用性(拿来即用)介绍,如对框架设计没兴趣的朋友,请略过. 快一个月没有写博文了,最近忙着两件事; 一:阅读刘墉先生的<说话的魅力>,以一种微妙的,你我大家都会经常遇见 ...
- 【Struts2】Struts2框架的搭建
1,Struts2简介 struts1和struts2都是由Apache组织发布的,但是比较有趣的是struts2和struts1并没有“血缘关系”.在Apache发布struts1之后,当时是还是非 ...
随机推荐
- cas sso单点登录系列3_cas-server端配置认证方式实践(数据源+自定义java类认证)
转:http://blog.csdn.net/ae6623/article/details/8851801 本篇将讲解cas-server端的认证方式 1.最简单的认证,用户名和密码一致就登录成功 2 ...
- 打包静默安装参数(nsis,msi,InstallShield,InnoSetup)[转]
有时我们在安装程序的时候,希望是静默安装的,不显示下一步下一步,这编访问来教大家如何来操作,现在常用的制作安装程序的软件有, Microsoft Windows Installer , Windo ...
- [Struts2学习笔记] -- 环境配置
在创建好WebProject后,就可以开始进行Struts2的环境配置,可以到Struts2官网下载,本环境使用struts-2.3.24.1版本. 首先导入必要的jar包到WebProject的/W ...
- Uva 120 - Stacks of Flapjacks(构造法)
UVA - 120 Stacks of Flapjacks Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &a ...
- Java笔记-快速失败and安全失败
参考资料:http://blog.csdn.net/chenssy/article/details/38151189 快速失败 fail-fast 安全失败 fail-safe java.util包下 ...
- Web Services 介绍
Web Services 介绍 Web Services 是建立可交互操作的分布式应用程序的新平台 ; Web Services 平台是一套标准,它定义了应用程序如何在 Web 上进行交互操作 , 你 ...
- STM8S学习笔记-时钟控制1
1.图13可见,STM8S单片机主要有四种时钟源可供选择: 1).1-24MHz外部晶体振荡器(HSE). 2).最大24MHz外部时钟(HSE ext). 3).16MHz高速内部RC振荡器(HSI ...
- mobox:推进企业文档管理走向信息化之路
随着“大数据”时代的到来,越来越多的人们对数据库管理信息抱有认可态度,这是近年来信息化发展的必然结果.企业作为推进社会经济发展的主力军,也必然要紧跟大数据时代潮流,利用计算机技术全面普及企业的信息化管 ...
- android 多线程断点续传下载
今天跟大家一起分享下Android开发中比较难的一个环节,可能很多人看到这个标题就会感觉头很大,的确如果没有良好的编码能力和逻辑思维,这块是很难搞明白的,前面2次总结中已经为大家分享过有关技术的一些基 ...
- POJ2253 Frogger(最短路)
题目链接. 题意: 从0号点,到1号点,找一条能通过的路,使得这条路中的最大的边,比其它所有可能的路中的边都小. 分析: 这题就是按着dijkstra写,写着写着觉得像是prim了. 其中d[n]表示 ...