在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 ...
随机推荐
- 索引列上的统计 <第一篇>
一.索引在查询优化中的角色 SQL Server的查询优化器是基于开销的优化器.它通过确认选择性.数据的唯一性以及过滤数据(通过WHERE或JOIN子句)所使用的列来决定最佳的数据访问机制.统计与索引 ...
- 商派shopex
http://www.shopex.cn/48release/shopexsingle_exper.php 在线体验 前台体验:http://demo.shopex.com.cn/485 后台体验:h ...
- UVA 11374 Airport Express(枚举+最短路)
枚举每条商业线<a, b>,设d[i]为起始点到每点的最短路,g[i]为终点到每点的最短路,ans便是min{d[a] + t[a, b] + g[b]}.注意下判断是否需要经过商业线.输 ...
- Linux 块设备驱动 (一)
1.块设备的I/O操作特点 字符设备与块设备的区别: 块设备只能以块为单位接受输入和返回输出,而字符设备则以字符为单位. 块设备对于I/O请求有对应的缓冲区,因此它们可以选择以什么顺序进行响应,字符设 ...
- yii2学习的论坛
http://www.yiifans.com/forum.php http://www.yiichina.com/ http://www.yiichina.com/
- python高级编程(第12章:优化学习)2
#优化策略 #3个原则 """ 1a:寻找其他原因:确定第三方服务器或资源不是问题所在 2a:度量硬件:确定资源足够用 3a:编写速度测试:创建带有速度要求的场景 &qu ...
- Windows Live Writer 代码插件改造
源码和插件都在后面,如果不想看我神神叨叨的可以直接到文章后面下载 一 .找插件 在使用Windows Live Writer 经常要用到插入代码的功能,根据博客园中教程,分别使用了: WindowsL ...
- 关于c语言的一个小bug(c专家编程)
不多说,说了都是累赘!直接看代码吧! #include <stdio.h> int array[] = {23, 34, 12, 17, 204, 99, 16}; #define TOT ...
- HDU4907小技巧
原题http://acm.hdu.edu.cn/showproblem.php?pid=4907 Task schedule Time Limit: 2000/1000 MS (Java/Others ...
- Linux系统守护进程详解ntsysv 可以关掉那些服务
acpid, haldaemon, messagebus, klogd,network, syslogd 以上几个服务必须开启!其他的分析如下: 1.NetworkManager,NetworkMa ...