第一范文网 - 专业文章范例文档资料分享平台

C#二次开发ArcGIS查询功能

来源:用户分享 时间:2025/5/23 14:30:46 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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

//获取鼠标点击位置 m_point =

m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_isMouseDown = true;

// TODO: Add ZoomIn.OnMouseDown implementation }

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

//MouseDown为发生时返回 if (!m_isMouseDown) return;

IActiveView pActiveView = m_hookHelper.ActiveView; //m_feedBack追踪鼠标移动 if (m_feedBack == null) {

m_feedBack = newNewEnvelopeFeedbackClass(); m_feedBack.Display = pActiveView.ScreenDisplay; //开始追踪

m_feedBack.Start(m_point); }

//追踪鼠标移动位置

m_feedBack.MoveTo(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y));

}

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

//MouseDown为发生时返回 if (!m_isMouseDown) return;

IActiveView pActiveView = m_hookHelper.ActiveView; //获取MouseUp发生时的范围并放大 IEnvelope pEnvelope;

if (m_feedBack == null)//鼠标未拉框时进行固定比例尺放大 {

pEnvelope = pActiveView.Extent; pEnvelope.Expand(0.5, 0.5, true); pEnvelope.CenterAt(m_point); } else

{ //停止追踪

pEnvelope = m_feedBack.Stop();

//判断新的范围的高度和宽度是否为零

if (pEnvelope.Width == 0 || pEnvelope.Height == 0) {

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

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

m_feedBack = null; m_isMouseDown = false; } } //获取新的范围

pActiveView.Extent = pEnvelope; //刷新视图

pActiveView.Refresh();

m_feedBack = null; m_isMouseDown = false;

// TODO: Add ZoomIn.OnMouseUp implementation }

#endregion } }

9、ZoomOut类源码

namespace MyMap.Classes {

///

/// Summary description for ZoomOut. ///

[Guid(\)] [ClassInterface(ClassInterfaceType.None)] [ProgId(\)] publicsealedclassZoomOut : 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

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

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

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 //记录鼠标位置

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

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

privateINewEnvelopeFeedback m_feedBack;

privateIHookHelper m_hookHelper;

public ZoomOut() {

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) {

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

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

if (m_hookHelper == null)

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

// TODO: Add ZoomOut.OnCreate implementation }

publicoverridevoid OnClick() {

// TODO: Add ZoomOut.OnClick implementation }

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

// TODO: Add ZoomOut.OnMouseDown implementation //当前地图视图为空时返回

if (m_hookHelper.ActiveView == null) return;

//获取鼠标点击位置 m_point =

m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_isMouseDown = true; }

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

// TODO: Add ZoomOut.OnMouseMove implementation //MouseDown为发生时返回 if (!m_isMouseDown) return;

IActiveView pActiveView = m_hookHelper.ActiveView; //m_feedBack追踪鼠标移动 if (m_feedBack == null) {

m_feedBack = newNewEnvelopeFeedbackClass(); m_feedBack.Display = pActiveView.ScreenDisplay; //开始追踪

m_feedBack.Start(m_point); }

//追踪鼠标移动位置

m_feedBack.MoveTo(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y));

}

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

// TODO: Add ZoomOut.OnMouseUp implementation //MouseDown为发生时返回 if (!m_isMouseDown) return;

IActiveView pActiveView = m_hookHelper.ActiveView;

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

搜索更多关于: C#二次开发ArcGIS查询功能 的文档
C#二次开发ArcGIS查询功能.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c19whw7d81f2r4yi9c8hj79c964hjsm00lc8_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top