在WPF中使用ArcGIS Engine
原文 http://blog.csdn.net/zzahkj/article/details/9102621
1.首先,新建一个WPF项目,添加引用ESRI.ArcGIS.AxControls、ESRI.ArcGIS.System、 ESRI.ArcGIS.Version、ESRI.ArcGIS.Controls、ESRI.ArcGIS.SystemUI,然后拖入 WindowsFormsHost控件到窗体中或者通过在Grid中添加XAML代码实现,如下:
- <Grid>
- <WindowsFormsHost Height="54" HorizontalAlignment="Left" Name="windowsFormsHost1" VerticalAlignment="Top" Width="576" />
- <WindowsFormsHost Height="232" HorizontalAlignment="Left" Margin="0,60,0,0" Name="windowsFormsHost2" VerticalAlignment="Top" Width="133" />
- <WindowsFormsHost Height="232" HorizontalAlignment="Left" Margin="139,60,0,0" Name="windowsFormsHost3" VerticalAlignment="Top" Width="437" />
- </Grid>
2.为窗体添加一个WindowsLoad事件,名为Window_Loaded,可通过在Window属性里的事件Load里填写Window_Loaded
或者在代码中直接添加Loaded="Window_Loaded"
3.添加AE控件并建立其与WindowsFormsHost控件的联系,
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using ESRI.ArcGIS.Controls;
- using ESRI.ArcGIS.SystemUI;
- using System.Windows.Forms;
- namespace WpfArcGISEngine
- {
- /// <summary>
- /// MainWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MainWindow : Window
- {
- AxMapControl mapControl = null;
- AxTOCControl tocControl = null;
- AxToolbarControl toolbarControl = null;
- public MainWindow()
- {
- InitializeComponent();
- CreateEngineControls();
- }
- //建立AE控件与WindowsFormsHost控件的联系
- private void CreateEngineControls()
- {
- mapControl = new AxMapControl();
- windowsFormsHost3.Child = mapControl;
- tocControl = new AxTOCControl();
- windowsFormsHost2.Child = tocControl;
- toolbarControl = new AxToolbarControl();
- windowsFormsHost1.Child = toolbarControl;
- }
- //在Window_Loaded实现TOC与MapControl控件、ToolBar与MapControl之间的绑定
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- tocControl.SetBuddyControl(mapControl);
- toolbarControl.SetBuddyControl(mapControl);
- ToolbarAddItems();
- }
- //ToolBar中添加工具
- private void ToolbarAddItems()
- {
- toolbarControl.AddItem(new ControlsOpenDocCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
- toolbarControl.AddItem(new ControlsSaveAsDocCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
- toolbarControl.AddItem(new ControlsAddDataCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
- toolbarControl.AddItem("esriControls.ControlsMapNavigationToolbar");
- toolbarControl.AddItem("esriControls.ControlsMapIdentifyTool");
- }
- }
- }
4.最后运行肯定不会成功,因为没有License的初始化,License初始化的方法是在App.xaml.cs中添加如下的代码实现
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Windows;
- using ESRI.ArcGIS.esriSystem;
- namespace WpfArcGISEngine
- {
- /// <summary>
- /// App.xaml 的交互逻辑
- /// </summary>
- public partial class App : Application
- {
- protected override void OnStartup(StartupEventArgs e)
- {
- base.OnStartup(e);
- ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
- InitializeEngineLicense();
- }
- private void InitializeEngineLicense()
- {
- AoInitialize aoi = new AoInitializeClass();
- esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngine;
- if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
- {
- aoi.Initialize(productCode);
- }
- }
- }
- }
现在就可以运行了,运行结果如下:
界面有点丑
在WPF中使用ArcGIS Engine的更多相关文章
- 如何在WPF程序中使用ArcGIS Engine的控件
原文 http://www.gisall.com/html/47/122747-4038.html WPF(Windows Presentation Foundation)是美国微软公司推出.NET ...
- 使用XAML在WPF项目中承载ArcGIS Engine地图控件开发
原文 http://blog.csdn.net/flexmapserver/article/details/5868882 用Windows Form进行ArcGIS Engine二次开发时常见的形式 ...
- 关于WPF中承载 ArcGIS控件。
原文 http://www.cnblogs.com/zoe-j/archive/2011/05/18/2050208.html 之前就做过WPF的应用,之前承载的MapGIS的二次开发控件,今天写一下 ...
- 安装ArcGIS Engine 9.3
本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217003.html 准备: ArcGIS Engine 9.3.crack_for ...
- 【转载】Python与ArcGIS Engine的集成
本文转载自Fransico<Python与ArcGIS Engine的集成> 1 在Python中调用AO类库 1.1 准备工作 本文所使用环境:ArcGIS 10.0.Python ...
- VC、OpenGL、ArcGIS Engine开发的二维三维结合的GIS系统
一.前言 众所周知,二维GIS技术发展了近四十年,伴随着计算机软硬件以及关系型数据库的飞速发展,二维GIS技术已日臻完善.在对地理信息的分析功能上有着无可比拟的优势.一些宏观的地理信息,一维的地理信息 ...
- WPF/ArcGIS Engine三维开发和EVC3/4升级到VS项目建议(转)
系统环境:Windows 7 专业版,Visual Studio 2010,ArcGIS Engine 9.3 1.创建项目 创建一个WPF的项目,必须选择.Net framework 3.5(AE9 ...
- WPF & ArcGIS Engine三维开发入门攻略
原文 http://www.cnblogs.com/Realh/archive/2010/12/14/1906112.html 前些日子在做ESRI的开发大赛,从刚开始接触ArcGIS Engine( ...
- 转-ArcGIS Engine中的License设置
AE开发中的License有两种方法进行设置,一种是通过LicenseControl控件,另一种是通过IAoInitialize接口设置.整个应用程序中只能有一种方式存在,如果进行了两种License ...
随机推荐
- SendMessage参数
http://download.csdn.net/download/wshjldaxiong/4830242
- Sql Server 面试题
1.用一条SQL语句 查询出每门课都大于80分的学生姓名 name kecheng fenshu 张三 语文 81张三 数学 75李四 语文 ...
- Js,alert出现乱码问题,赶紧记下来,额~~~
原文 http://www.cnblogs.com/still-windows7/archive/2011/08/28/2156010.html 前些天还可以正常使用的js文件,在添加了一些东西后,其 ...
- eclipse打开文件位置Open Explorer 插件
,OpenExplorer插件可以满足这个功能,可以到https://github.com/samsonw/OpenExplorer/downloads下载最新版本,将jar包放到eclipse的pl ...
- ORA-3136报错
当使用错误的用户名或密码登陆数据库时,会提示如下报错内容: bash-4.1$ sqlplus a/a@test SQL*Plus: Release 10.2.0.4.0 - Production o ...
- elasticsearh 中每个节点中需要有相同的插件
elasticsearh 中每个节点中需要有相同的插件 [2016-09-13 19:25:24,049][INFO ][discovery.zen ] [node02] failed to send ...
- 利用btrace工具监控在线运行java程序
一.作用 可以用于对运行中java程序进行诊断监控分析,也可以用于开发阶段查看一些异常信息或者调用过程(如有些第三方代码没有源代码,不便于debug调试). 注:如果用于对在线运行系统的诊断,需 ...
- Payssion,海外本地支付_海外本地收款_小语种本地支付_外贸收款_外贸网店收款_欧洲本地支付_俄罗斯本地支付_巴西支付_跨境支付_PAYSSION,让跨境支付更轻松!
Payssion,海外本地支付_海外本地收款_小语种本地支付_外贸收款_外贸网店收款_欧洲本地支付_俄罗斯本地支付_巴西支付_跨境支付_PAYSSION,让跨境支付更轻松! 首页 / 关于 ...
- 《Java程序员面试笔试宝典》之Java与C/C++有什么异同
Java与C++都是面向对象语言,都使用了面向对象思想(例如封装.继承.多态等),由于面向对象有许多非常好的特性(继承.组合等),使得二者都有很好的可重用性. 需要注意的是,二者并非完全一样,下面主要 ...
- fcitx-rime添加五笔/五笔拼音
简介 Rime,全名:中州韵输入法引擎,它不仅仅是一个输入法,也是一个输入法算法框架.Rime 支持拼音.双拼.注音.五笔和仓颉等音码.形码输入法. 安装 Debian sid 用户可以使用下面命令安 ...