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,需要后端处理 ...
随机推荐
- Oracle 修改SYS、system用户密码
by:授客 QQ:1033553122 概念 SYS用户是Oracle中权限最高的用户,而SYSTEM是一个用于数据库管理的用户.在数据库安装完之后,应立即修改SYS,SYSTEM这两个用户的密码 ...
- SSH远程神器—Termius
简介 Termius是一款非常好用而且漂亮的SSH客户端,能快速远程控制服务器,可以定制自己喜欢的主题.Termius不仅涵盖了PC端的Windows.Linux.Mac,还支持手机端的Android ...
- 使用 gitee 托管你的 go 模块
前言 实话实说, github 作为这个球上顶级的代码托管平台, 公司/企业/开发者的认可和参与度是非常高的. 但是因为某些原因 特色墙, 国内使用 github 的体验不是非常好 速度慢 不靠谱同学 ...
- 轻松的工作(deepseek)
组长:"这里有一百多个地震波形文件,把每一个地震建立一个文件夹,并把地震波形放到对应日期的地震中." 我想:一个一个整好麻烦想摸会鱼 让我们来deepseek吧~ 首先,生成文件夹 ...
- Hyperledger Fabric - 区块链应用
Fabric Gateway SDK 实现Fabric的编程模型,提供了一系列简单的API给应用程序与Fabric区块链网络进行交互 应用程序将各自的网络交互委托给其网关,每个网关都了解网络信道拓扑, ...
- Go操作MySQL总结
1.下载驱动包 打开GoLand->Terminal,输入:go get github.com/go-sql-driver/mysql 2.编写代码 package mainimport ( & ...
- 🎀MySQL-关键字执行顺序
简介 在MySQL中,SQL查询语句的执行遵循一定的逻辑顺序,即使这些关键字在SQL语句中的物理排列可能有所不同. 语句顺序 (8) SELECT (9) DISTINCT<select_lis ...
- python开发箱号批量查询关联SN号码的程序
# 需要导入的包 import tkinter as tk from tkinter import ttk, messagebox, filedialog import pyodbc import p ...
- 记一次 .NET某旅行社酒店管理系统 卡死分析
一:背景 1. 讲故事 年初有位朋友找到我,说他们的管理系统不响应了,让我帮忙看下到底咋回事? 手上也有dump,那就来分析吧. 二:为什么没有响应 1. 线程池队列有积压吗? 朋友的系统是一个web ...
- 游戏开发之Cocos3着色器/shader快速入门
本文为学习笔记,不排除有谬误,但确保都是亲测.另外,傻狗百度收不收录的无所谓,我来博客园就是为了记记笔记. 对于新人,首先明确一点:shader需要通过材质的方式作用于模型上 所以有个很关键的步骤,c ...