AxControls与Controls之联系区别(转)

本文深入探讨了ESRI.ArcGIS.AxControls与ESRI.ArcGIS.Controls的区别,揭示了它们在ArcEngine与Visual Studio集成中的作用。文章详细介绍了如何在VS中添加并使用这两个程序集,以及它们在全局程序集缓存中的位置。同时,澄清了Ax开头的控件与常规类的关系,指出AxMapControl与MapControl指向同一对象。

ESRI.ArcGIS.AxControls 与 ESRI.ArcGIS.Controls的各种含义,

ArcEngine与 VS2005/08紧密集成,在工具箱中有基本的ArcEngine 控件,这里控件来源于那里呢?通过在工具箱的快捷菜单中的“选择项”命令,可以看到如下图选项:

 

从上图所以看出,工具箱中

 

这些控件,均来源于,ESRI.ArcGis.AxControl 这个程序集中,这个程序集已经位于全局程序集缓存(Global Assembly Cache,GAC目录中,什么时全局程序集缓存目录呢?这个问题可以详细参考《框架设计(第2版) CLR Via C#》一书P61页,一般来说,该目录的路径是:C:\WINDOWS\assembly

以下是在该目录底下找到该程序集的截图:

 

根据信息,尝试在cmd窗口中执行以下命令,将会看到,这个程序集实际对应的dll文件,

chdir C:\WINDOWS\assembly

chdir GAC_MSIL

chdir ESRI.ArcGIS.AxControls

chdir 9.3.0.1770__8fc3cc631e44ad86

dir

命令执行截图如下:

 

当将一个 axLicenseControl和一个axMapControl 添加到窗口上时,可以发现,在引用中添加了以下程序集:

 

注意,看起来似乎是名称空间,其实是程序集!

可以在属性窗口中看到各程序集的路径。

ESRI.ArcGIS.AxControls:C:\Program Files\ArcGIS\DotNet\ESRI.ArcGIS.AxControls.dll

ESRI.ArcGIS.Controls:C:\Program Files\ArcGIS\DotNet\ESRI.ArcGIS.Controls.dll

通过对象浏览器,可以看到,两个程序集下的名称空间都是:ESRI.ArcGIS.Controls

如下图:

 

所以,不可能使用 using ESRI.ArcGIS.AxControls这样的语句的!因为这不是一个名称空间,而使用 using ESRI.ArcGIS.Controls 这个名称空间下面的类时,你可能使用了 ESRI.ArcGIS.AxControls或者 ESRI.ArcGIS.Controls 程序集下的类。

ESRI.ArcGIS.AxControls程序集下主要类是各种以Ax开头的控件类及与之相关的事件类

ESRI.ArcGIS.Controls 程序集下的类,就是我们常的各种类。

事实上,在.NET Framework组件中,AxMapControl与 MapControl是指向同一东西的!如下图:

 

 

总结完成

namespace 李佳怡2023030331 { partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl(); this.axMapControl1 = new ESRI.ArcGIS.Controls.AxMapControl(); this.axTOCControl1 = new ESRI.ArcGIS.Controls.AxTOCControl(); this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl(); this.btnAttrQuery = new System.Windows.Forms.Button(); this.btnDrawTrack = new System.Windows.Forms.Button(); this.btnClearTrack = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axMapControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit(); this.SuspendLayout(); // // axLicenseControl1 // this.axLicenseControl1.Enabled = true; this.axLicenseControl1.Location = new System.Drawing.Point(44, 352); this.axLicenseControl1.Name = "axLicenseControl1"; this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState"))); this.axLicenseControl1.Size = new System.Drawing.Size(32, 32); this.axLicenseControl1.TabIndex = 0; // // axMapControl1 // this.axMapControl1.Location = new System.Drawing.Point(163, 70); this.axMapControl1.Name = "axMapControl1"; this.axMapControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMapControl1.OcxState"))); this.axMapControl1.Size = new System.Drawing.Size(399, 291); this.axMapControl1.TabIndex = 1; // // axTOCControl1 // this.axTOCControl1.Location = new System.Drawing.Point(22, 70); this.axTOCControl1.Name = "axTOCControl1"; this.axTOCControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState"))); this.axTOCControl1.Size = new System.Drawing.Size(112, 291); this.axTOCControl1.TabIndex = 2; // // axToolbarControl1 // this.axToolbarControl1.Location = new System.Drawing.Point(25, 13); this.axToolbarControl1.Name = "axToolbarControl1"; this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState"))); this.axToolbarControl1.Size = new System.Drawing.Size(536, 28); this.axToolbarControl1.TabIndex = 3; // // btnAttrQuery // this.btnAttrQuery.Location = new System.Drawing.Point(763, 70); this.btnAttrQuery.Name = "btnAttrQuery"; this.btnAttrQuery.Size = new System.Drawing.Size(89, 39); this.btnAttrQuery.TabIndex = 4; this.btnAttrQuery.Text = "属性查询"; this.btnAttrQuery.UseVisualStyleBackColor = true; this.btnAttrQuery.Click += new System.EventHandler(this.btnAttrQuery_Click); // // btnDrawTrack // this.btnDrawTrack.Location = new System.Drawing.Point(763, 140); this.btnDrawTrack.Name = "btnDrawTrack"; this.btnDrawTrack.Size = new System.Drawing.Size(89, 38); this.btnDrawTrack.TabIndex = 5; this.btnDrawTrack.Text = "绘制轨迹"; this.btnDrawTrack.UseVisualStyleBackColor = true; //this.btnDrawTrack.Click += new System.EventHandler(this.btnDrawTrack_Click); // // btnClearTrack, // // 原代码(被注释): //this.btnDrawTrack.Click += new System.EventHandler(this.btnDrawTrack_Click); //this.btnClearTrack.Click += new System.EventHandler(this.btnClearTrack_Click); // 修正后: this.btnDrawTrack.Click += new System.EventHandler(this.btnDrawTrack_Click); //this.btnClearTrack.Click += new System.EventHandler(this.btnClearTrack_Click); this.btnClearTrack.Location = new System.Drawing.Point(763, 208); this.btnClearTrack.Name = "btnClearTrack"; this.btnClearTrack.Size = new System.Drawing.Size(89, 42); this.btnClearTrack.TabIndex = 6; this.btnClearTrack.Text = "重绘轨迹"; this.btnClearTrack.UseVisualStyleBackColor = true; //this.btnClearTrack.Click += new System.EventHandler(this.btnClearTrack_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(864, 503); this.Controls.Add(this.btnClearTrack); this.Controls.Add(this.btnDrawTrack); this.Controls.Add(this.btnAttrQuery); this.Controls.Add(this.axToolbarControl1); this.Controls.Add(this.axTOCControl1); this.Controls.Add(this.axMapControl1); this.Controls.Add(this.axLicenseControl1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axMapControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit(); this.ResumeLayout(false); // 新增的鼠标按下事件绑定 this.axMapControl1.OnMouseDown += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseDownEventHandler(this.axMapControl1_OnMouseDown); } #endregion private ESRI.ArcGIS.Controls.AxLicenseControl axLicenseControl1; private ESRI.ArcGIS.Controls.AxTOCControl axTOCControl1; private ESRI.ArcGIS.Controls.AxToolbarControl axToolbarControl1; private System.Windows.Forms.Button btnAttrQuery; public ESRI.ArcGIS.Controls.AxMapControl axMapControl1; private System.Windows.Forms.Button btnDrawTrack; private System.Windows.Forms.Button btnClearTrack; } } 警告 1 由于程序集“d:\Program Files (x86)\ArcGIS\DeveloperKit10.2\DotNet\ESRI.ArcGIS.AxControls.dll”创建了对嵌入互操作程序集“c:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Common\stdole.dll”的间接引用,因此创建了对该程序集的引用。请考虑更改其中一个程序集的“嵌入互操作类型”属性。这样不能运行
11-27
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值