关于WPF中承载 ArcGIS控件。

原文 http://www.cnblogs.com/zoe-j/archive/2011/05/18/2050208.html

之前就做过WPF的应用,之前承载的MapGIS的二次开发控件,今天写一下承载的Arcgis的相关控件,

首先,Arcgis的控件不支持WPF,我得环境是vs2010,Engine10,Arcgis的控件支持的还是以前的.net 3.5的winform。但是接触过WPF的都觉得WPF的视觉效果,和用户体验都会比较好,这个时候就需要用承载,WPF的控件中有一个是 windowsformshost的控件,这个可以称为是宿主控件吧,然后它里面可以承载一个winform的子控件。

添加引用

  • ESRI.ArcGIS.AxControls—Contains the AxMapControl.
  • ESRI.ArcGIS.System—Contains the AoInitialiseClass class (used to set up the ArcGIS Engine license).
  • ESRI.ArcGIS.Version—Contains runtime manager functionality to bind a specific ArcGIS installation on the machine.

原理就是这样,接下来讲一下首先呢是建项目,然后选择的时候直接选择.net3.5下面的WPF应用,然后是要添加引用,一个是Arcgis 的 axcontrol一个是 control然后,添加这个引用WindowsFormsIntegration,这个是用来承载控件的引用,然后再xmal下面写好空间里面的这样一 句 xmlns:in="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" Loaded="Window_Loaded",然后就可以直接在wpf下面戴上几个WindowsFormsHost这样的控件,定义好名字和大小位 置,然后在c#代码中,windows的load事件中定义几个arcgis的控件,然后再用这样的格式的代码来实现承载


wfhlin.Child = mylincense;

前面的wfhlin是我定义的windowsformshost的名字,后面的mylincense是我定义的一个 axlincense控件

在app.xmal.cs中写好关于权限许可的代码如下


 protectedoverridevoid OnStartup(StartupEventArgs e)
{
base.OnStartup(e); InitializeEngineLicense();
} privatevoid InitializeEngineLicense()
{
AoInitialize aoi =new AoInitializeClass(); //More license choices can be included here.
esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngine;
if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
{
aoi.Initialize(productCode);
}
}

在调用这个方法的时候

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
上一篇:普通用户ssh无密码登录设置


下一篇:python socket编程---从使用Python开发一个Socket示例说到开发者的思维和习惯问题