C#二次开发ArcGIS查询功能

loading 分享 2026-8-27 下载文档

[地理信息系统课程设计报告]

ArcGISCategoryUnregistration(registerType); }

#region ArcGIS Component Category Registrar generated code privatestaticvoid ArcGISCategoryRegistration(Type registerType) {

string regKey = string.Format(\, registerType.GUID);

ControlsCommands.Register(regKey); }

privatestaticvoid ArcGISCategoryUnregistration(Type registerType) {

string regKey = string.Format(\, registerType.GUID);

ControlsCommands.Unregister(regKey); }

#endregion #endregion //获取视图范围

privateIScreenDisplay m_focusScreenDisplay = null; //标记操作进程

privatebool m_PanOperation;

privateIHookHelper m_hookHelper; public Pan() {

base.m_category = \; //localizable text base.m_caption = \漫游\; //localizable text base.m_message = \漫游\; //localizable text base.m_toolTip = \漫游\; //localizable text

base.m_name = \; //unique id, non-localizable (e.g. \ try

{

string bitmapResourceName = GetType().Name + \;

base.m_bitmap = newBitmap(GetType(), bitmapResourceName);

base.m_cursor = newSystem.Windows.Forms.Cursor(GetType(), GetType().Name + \); }

catch (Exception ex) {

System.Diagnostics.Trace.WriteLine(ex.Message, \); } }

#region Overridden Class Methods publicoverridevoid OnCreate(object hook) {

if (m_hookHelper == null)

m_hookHelper = newHookHelperClass();

[地理信息系统课程设计报告]29 / 38

[地理信息系统课程设计报告]

m_hookHelper.Hook = hook;

// TODO: Add Pan.OnCreate implementation }

publicoverridevoid OnClick() {

// TODO: Add Pan.OnClick implementation }

publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) {

//判断是否鼠标左键

if (Button != 1) return; //获取视图范围并开始漫游

IActiveView pActiveView = m_hookHelper.ActiveView;

m_focusScreenDisplay = pActiveView.ScreenDisplay;

IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_focusScreenDisplay.PanStart(pPoint); //标记漫游操作为真

m_PanOperation = true;

// TODO: Add Pan.OnMouseDown implementation }

publicoverridevoid OnMouseMove(int Button, int Shift, int X, int Y) {

//判断是否鼠标左键

if (Button != 1) return; //是否漫游状态

if (!m_PanOperation) return; //追踪鼠标

IPoint pPoint = m_focusScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_focusScreenDisplay.PanMoveTo(pPoint); // TODO: Add Pan.OnMouseMove implementation }

publicoverridevoid OnMouseUp(int Button, int Shift, int X, int Y) {

//判断是否鼠标左键

if (Button != 1) return; //是否漫游状态

if (!m_PanOperation) return;

IEnvelope pExtent = m_focusScreenDisplay.PanStop(); //判断移动区域是否为空 if (pExtent != null) {

m_focusScreenDisplay.DisplayTransformation.VisibleBounds = pExtent; m_focusScreenDisplay.Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches); }

[地理信息系统课程设计报告]30 / 38

[地理信息系统课程设计报告]

//关闭漫游状态

m_PanOperation = false;

// TODO: Add Pan.OnMouseUp implementation }

#endregion } }

8、ZoomIn类源码

namespace MyMap.Classes {

[Guid(\)] [ClassInterface(ClassInterfaceType.None)] [ProgId(\)] publicsealedclassZoomIn : BaseTool {

#region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)]

staticvoid RegisterFunction(Type registerType) {

// Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); }

[ComUnregisterFunction()] [ComVisible(false)]

staticvoid UnregisterFunction(Type registerType) {

// Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); }

#region ArcGIS Component Category Registrar generated code privatestaticvoid ArcGISCategoryRegistration(Type registerType) {

string regKey = string.Format(\, registerType.GUID);

ControlsCommands.Register(regKey); }

privatestaticvoid ArcGISCategoryUnregistration(Type registerType) {

string regKey = string.Format(\, registerType.GUID);

ControlsCommands.Unregister(regKey);

[地理信息系统课程设计报告]31 / 38

[地理信息系统课程设计报告]

}

#endregion #endregion //记录鼠标位置

privateIPoint m_point; //标记MouseDown是否发生

privateBoolean m_isMouseDown; //追踪鼠标移动产生新的Envelope

privateINewEnvelopeFeedback m_feedBack; privateIHookHelper m_hookHelper; public ZoomIn() {

base.m_category = \; //localizable text base.m_caption = \放大\; //localizable text base.m_message = \放大\; //localizable text base.m_toolTip = \放大\; //localizable text

base.m_name = \; //unique id, non-localizable (e.g. \ try

{

string bitmapResourceName = GetType().Name + \;

base.m_bitmap = newBitmap(GetType(), bitmapResourceName);

base.m_cursor = newSystem.Windows.Forms.Cursor(GetType(), GetType().Name + \); }

catch (Exception ex) {

System.Diagnostics.Trace.WriteLine(ex.Message, \); } }

#region Overridden Class Methods publicoverridevoid OnCreate(object hook) {

if (m_hookHelper == null)

m_hookHelper = newHookHelperClass(); m_hookHelper.Hook = hook;

// TODO: Add ZoomIn.OnCreate implementation }

publicoverridevoid OnClick() {

// TODO: Add ZoomIn.OnClick implementation }

publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) {

//当前地图视图为空时返回

if (m_hookHelper.ActiveView == null) return;

[地理信息系统课程设计报告]32 / 38


C#二次开发ArcGIS查询功能.doc 将本文的Word文档下载到电脑
搜索更多关于: C#二次开发ArcGIS查询功能 的文档
相关推荐
相关阅读