ArcObjects SDK 023 开发框架搭建-MainApp
MainApp定义了启动界面,主界面等。主界面的整体流程如下。
1、验证许可。
//ArcGIS许可验证
RuntimeManager.Bind(ProductCode.Desktop);
var myAoLicenseCheck = new AoLicenseCheck
{
ProductCode = esriLicenseProductCode.esriLicenseProductCodeAdvanced
};
string myMessage = myAoLicenseCheck.Check();
2、初始化AxMapControl以及AxPageLayoutControl(如有需要),然后初始化MapApplication或者继承该类的子类。
//初始化地图控件
AxMapControl myAxMapControl = new AxMapControl();
myAxMapControl.BeginInit();
this.UI_Map_WindowsFormsHost.Child = myAxMapControl;
myAxMapControl.EndInit();
myAxMapControl.BackColor = System.Drawing.Color.White;
myAxMapControl.BorderStyle = esriControlsBorderStyle.esriNoBorder;
myAxMapControl.ShowScrollbars = false;
var myAxPageLayoutControl = new AxPageLayoutControl
{
BackColor = System.Drawing.Color.White
};
myAxPageLayoutControl.BeginInit();
this.UI_PageLayout_WindowsFormsHost.Child = myAxPageLayoutControl;
myAxPageLayoutControl.EndInit();
myAxPageLayoutControl.BackColor = System.Drawing.Color.White;
myAxPageLayoutControl.BorderStyle = esriControlsBorderStyle.esriNoBorder;
this._AxTOCControlExUI = new AxTocControlExUI();
this.UI_AxTOCControlExUI_Border.Child = this._AxTOCControlExUI;
this._AxTOCControlExUI.SetTocBuddy(myAxMapControl.Object); //初始化 Application
this._MapApplication = new MapApplication(myAxMapControl, myAxPageLayoutControl);
this._AxTOCControlExUI.BindApplication(this._MapApplication);
this._MapApplication.MainWindow = this;
3、注册Tab也切换事件
Tab也切换时,要根据切换情况激活MapControl或者PageLayoutControl。
/// <summary>
/// 当主视图的Tab页切换后 触发执行的函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DXTabControl_SelectionChanged(object sender, TabControlSelectionChangedEventArgs e)
{
if (this._MapApplication == null)
{
return;
}
DXTabControl myTabControl = sender as DXTabControl;
if (myTabControl.SelectedIndex == 0)
{
this._MapApplication.ActivePattern = MapActivePattern.Map;
this._AxTOCControlExUI.SetTocBuddy(this._MapApplication.MapControl);
this._MapApplication.CrruteTool = this._MapApplication.MapPanTool;
}
else if (myTabControl.SelectedIndex == 1)
{
this._MapApplication.ActivePattern = MapActivePattern.PageLayout;
this._AxTOCControlExUI.SetTocBuddy(this._MapApplication.PageLayoutControl);
this._MapApplication.CrruteTool = this._MapApplication.PagePanTool;
}
else if (myTabControl.SelectedIndex == 2)
{
this._MapApplication.ActivePattern = MapActivePattern.None;
}
}
4、在菜单和工具栏等位置堆Coomand和Tool,如下图所示。
//初始化菜单
BarSubItem myBarSubItem = null;
myBarSubItem = new BarSubItem() { Name = "File" };
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.NewMapDocCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarItemLinkSeparator());
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.OpenMxdCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.AddDataCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarItemLinkSeparator());
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.SaveMxdCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.SaveAsMxdCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.ViewExportPicCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarItemLinkSeparator());
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.ExitAppCommand(this._MapApplication)));
this.UI_MainMenu_Bar.Items.Add(myBarSubItem); myBarSubItem = new BarSubItem() { Name = "Deploy" };
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new DeployUI.Fishnets.FishnetCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new DeployUI.Drainages.DraExtSCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new DeployUI.Slopes.SlopeCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarItemLinkSeparator());
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new DeployUI.PointDeploys.PointDeployCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new DeployUI.PointEncodes.PointEncodeCommand(this._MapApplication)));
myBarSubItem.Items.Add(new BarItemLinkSeparator());
myBarSubItem.Items.Add(new BarButtonItemCommandUI(new SaudiDeployUI.SaudiDeployCommand(this._MapApplication)));
this.UI_MainMenu_Bar.Items.Add(myBarSubItem); //初始化工具栏
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.MapZoomInTool(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.MapZoomOutTool(this._MapApplication)));
FrameworkUI.MapTools.MapPanTool myMapPanTool = new FrameworkUI.MapTools.MapPanTool(this._MapApplication);
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(myMapPanTool));
this._MapApplication.MapPanTool = myMapPanTool;
this._MapApplication.CrruteTool = myMapPanTool;
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapFullExtentCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomInFixedCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomOutFixedCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomBackCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomForwardCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new AxMapScaleBarEditItem(this._MapApplication));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.PageTools.PageZoomInTool(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.PageTools.PageZoomOutTool(this._MapApplication)));
FrameworkUI.PageTools.PagePanTool myPagePanTool = new FrameworkUI.PageTools.PagePanTool(this._MapApplication);
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(myPagePanTool));
this._MapApplication.PagePanTool = myPagePanTool;
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoomWholePageCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoom100PercentCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoomInFixedCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoomOutFixedCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoomBackCommand(this._MapApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.PageTools.PageZoomForwardCommand(this._MapApplication))); //地图右键菜单
this._AxTOCControlExUI.MapContextMenu = new ContextMenuStripTocContextMenu();
this._AxTOCControlExUI.MapContextMenu.AddCommand(new FrameworkUI.Maps.MapSetSpatialReferenceCommand(this._MapApplication));
this._AxTOCControlExUI.MapContextMenu.AddCommand(new FrameworkUI.Maps.MapClearLayerCommand(this._MapApplication)); //图层右键菜单
this._AxTOCControlExUI.LayerContextMenu = new ContextMenuStripTocContextMenu();
this._AxTOCControlExUI.LayerContextMenu.AddCommand(new FrameworkUI.Layers.LayerZoomToCommand(this._MapApplication));
this._AxTOCControlExUI.LayerContextMenu.AddCommand(new FrameworkUI.Layers.TableCommand(this._MapApplication));
this._AxTOCControlExUI.LayerContextMenu.AddCommand(new FrameworkUI.Layers.LayerPropertyCommand(this._MapApplication));
this._AxTOCControlExUI.LayerContextMenu.AddCommand(new FrameworkUI.Layers.LayerRemoveCommand(this._MapApplication)); //添加显示坐标的状态栏
this.UI_StatusBar.ItemLinks.Add(new AxCoordinateBarEditItem(this._MapApplication));
ArcObjects SDK 023 开发框架搭建-MainApp的更多相关文章
- ArcObjects SDK开发 001 ArcObjects SDK 简介
1.什么是ArcObjects SDK 在网上搜索什么是ArcObjects,会搜到如下的定义. 这个定义比较准确,也比较容易理解. 2.什么是ArcEngine 在网上搜索ArcEngine,一般会 ...
- ArcObjects SDK(AE)10.1在vs2012安装的方法
ArcObjects SDK(以下简称AO)10.1只支持vs2010,如果装了vs2012,再安装AO会提示一串鸡肠(英文),意思是AO10.1只支持vs2010 想在2012下安装,可以通过修改注 ...
- Win7_Ultimate + VS2010 + openGL_MFC单文档应用开发框架搭建步骤
Win7_Ultimate + VS2010 + openGL单文档应用开发框架搭建步骤 上一个配置是基于OpenGL的开发工具配置的,下面就是基于Vs2010的MFC单文档应用开发. 通过网上查找资 ...
- Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍
Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍 spring集成 mybatis Spring4.x零配置框架搭建 两年前一直在做后 ...
- ONVIF学习-ONVIF开发框架搭建(C++)
第一步.下载gsoap 从gsoap官网(http://www.genivia.com/products.html#notice)下载最新版gsoap(博主用的是gsoap_2.8.45).gsoap ...
- C# 快速开发框架搭建—开发工具介绍
C# 快速开发框架搭建—开发工具介绍 一.VS2013,SQL SERVER R22008 以上两种工具如有不会者自行百度学习下. 二.动软代码生成器 对于经典的三层架构框架来说,使用动软代码生成器会 ...
- WPF管理系统开发框架搭建指南,2020从入门到放弃
WPF技术是一个很不错的技术,但一直没有上手过正式的项目,趁在做这个医疗项目时,遂搭建一个WPF开发框架,目的是为了统一WPF开发并提高开发效率:我对WPF技术算是零基础,现学现卖,用这些不成体系的文 ...
- ArcObjects SDK开发 007 自定义App-Command-Tool框架
1.为什么再设计一套App-Command-Tool框架 为什么我们要自己再设计一套App-Command框架,而不直接使用AO API中的AxControl-ICommand这套已经非常好的框架呢? ...
- ArcObjects SDK开发 006 ICommand和ITool接口
1.ICommand接口 ICommand接口是插件协议之一,继承该接口的类都可以成为命令.即点击一下执行,不主动与宿主发生鼠标和键盘交互.该接口包含的重要成员如下表所示. 序号 名称 类型 描述 1 ...
- ArcObjects SDK开发 004 如何学习好ArcObjects SDK开发
1.基于Arcobjects SDK可以做什么 基于Arcobjects SDK开发,大部分情况下就是做桌面GIS应用程序.AO写的代码是不能直接在Web服务上运行的,但如果你前端是JS,需要后端处理 ...
随机推荐
- dxTabbedMDIManager1关闭窗体
procedure TfrmJianKongXinXi.FormClose(Sender: TObject; var Action: TCloseAction);begin Action:=caFre ...
- Redis 高可用方案
本文分享自天翼云开发者社区<Redis 高可用方案>,作者:芋泥麻薯 一.常见使用方式 Redis的几种常见使用方式包括: Redis单副本: • Redis多副本(主从): • Redi ...
- 在 CentOS 系统下搭建 ZeroTier Moon
在 CentOS 系统下搭建 ZeroTier Moon 服务器时,生成的配置文件位置是在 /var/lib/zerotier-one/ 目录下.该目录包含了 ZeroTier One 的运行时数据, ...
- 【Python】PDF文档导出指定章节为TXT
PDF文档导出指定章节为TXT 需求 要导出3000多个pdf文档的特定章节内容为txt格式(pdf文字可复制). 解决 导出PDF 查了一下Python操作PDF文档的方法,主要是通过3个库,PyP ...
- Oracle - ORA-19809: 超出了恢复文件数的限制
场景重现 使用rman执行以下命令进行数据库备份的时候出现异常: RMAN> backup database; 出现如下错误: # 主要异常信息如下: # ... RMAN-00571: === ...
- 《机器人SLAM导航核心技术与实战》第1季:第0章_SLAM发展综述
<机器人SLAM导航核心技术与实战>第1季:第0章_SLAM发展综述 视频讲解 [第1季]0.第0章_SLAM发展综述-视频讲解 [第1季]0.1.第0章_SLAM发展综述-梳理定位导航技 ...
- 探秘 MySQL 索引底层原理,解锁数据库优化的关键密码(下)
上两篇文章<探秘MySQL索引底层原理,解锁数据库优化的关键密码(上)>和<探秘 MySQL 索引底层原理,解锁数据库优化的关键密码(中)>主要讲了MySQL索引的底层原理,且 ...
- SRE网站可靠性工程师
SRE网站可靠性工程师 SRE需要做什么? 一般: 故障模式,尤其是SPOF(单点故障).消除SPOFs是你作为SRE最大的挑战和乐趣. 基础设施组件,从应用程序到硬件(服务器.交换机.路由器.互联网 ...
- Java提交到MySQL数据库出现中文乱码
1)使用文本或者链接地址写到代码中(不推荐)时,实例如下: jdbc:mysql://localhost:3306/tms?useUnicode=true&characterEncoding= ...
- 🎀chrome-截图录屏插件-Awesome Screenshot
简介 Awesome Screenshot 截图录屏是一款浏览器扩展程序,它可以帮助用户进行网页截图.编辑图片以及录制屏幕视频 版本 4.4.22 功能 截图:可以截取整个网页(即使是需要滚动才能看到 ...