当前位置:首页 >> 建筑/土木 >>

如何让ITool类工具在使用过程中实现鼠标中键平移地图


如何让 ITool 类工具在使用过程中实现鼠标中键平移地图

private IScreenDisplay m_focusScreenDisplay; private bool m_PanOperation; public esriMapViewer() { InitializeComponent(); } private { switch (e.button) { case 4: IPoint point = new PointClass(); point.PutCoords(e.mapX, e.mapY); m_focusScreenDisplay = axMapControl.ActiveView.ScreenDisplay; m_focusScreenDisplay.PanStart(point); m_PanOperation = true; if (axMapControl.CurrentTool == null) axMapControl.MousePointer esriControlsMousePointer.esriPointerHand; break; default: break; } } private { if (e.button == 4) { if (!m_PanOperation) return; IPoint point = new PointClass(); point.PutCoords(e.mapX, e.mapY); m_focusScreenDisplay.PanMoveTo(point); } } private { if (e.button == 4) void axMapControl_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e) void axMapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) = void axMapControl_OnMouseDown(object sender,

IMapControlEvents2_OnMouseDownEvent e)

{ if (!m_PanOperation) return; IEnvelope extent = m_focusScreenDisplay.PanStop(); if (extent != null) { m_focusScreenDisplay.DisplayTransformation.VisibleBounds = extent; m_focusScreenDisplay.Invalidate(null, (short)esriScreenCache.esriAllScreenCaches); } m_PanOperation = false; if (axMapControl.CurrentTool == null) axMapControl.MousePointer esriControlsMousePointer.esriPointerDefault; } } = true,

言归正传,在 ArcMap 中,在使用工具如编辑工具进行点线面绘制时,也是可以通过中键来实现平移 的,这个需要一点点小技巧来实现,其实也简单,就是截获住中键事件,停止使用当前工具的相关操 作,并把当前鼠标样式变换到平移用的那只“小手”,下面以官方例子的 ZoomInTool 工具的实现代码为 例子,稍稍作了点修改,以达到本文的目的。继续贴代码: public sealed class esriMapZoomInToolClass : BaseTool { private IHookHelper m_hookHelper; private INewEnvelopeFeedback m_feedBack; private IPoint m_point; private Boolean m_isMouseDown; private bool m_changeCursor; public esriMapZoomInToolClass() { // // TODO: Define values for the public properties // base.m_category = ""; //localizable text base.m_caption = ""; base.m_message = ""; base.m_toolTip = ""; base.m_name "MyCategory_MyTool") try { // // TODO: change resource name if necessary = //localizable text //localizable text //localizable text ""; //unique id, non-localizable (e.g.

// //string bitmapResourceName = GetType().Name + ".bmp"; //base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.ZoomIn.cur"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } } #region Overriden Class Methods /// <summary> /// Occurs when this tool is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (m_hookHelper == null) m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; // TODO: } /// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { // TODO: Add esriMapZoomInToolClass.OnClick implementation } public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 4) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.Hand.cur"); m_changeCursor = true; return; } if (m_changeCursor) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.ZoomIn.cur"); m_changeCursor = false; Add esriMapZoomInToolClass.OnCreate implementation

} if (Button != 1) return; // TODO: Add esriMapZoomInToolClass.OnMouseDown implementation m_point m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_isMouseDown = true; } public override void OnMouseMove(int Button, int Shift, int X, int Y) { if (Button == 4) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.Hand.cur"); m_changeCursor = true; return; } if (m_changeCursor) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.ZoomIn.cur"); m_changeCursor = false; } // TODO: Add esriMapZoomInToolClass.OnMouseMove implementation if (!m_isMouseDown) return; //Start an envelope feedback if (m_feedBack == null) { m_feedBack = new NewEnvelopeFeedbackClass(); m_feedBack.Display = m_hookHelper.ActiveView.ScreenDisplay; m_feedBack.Start(m_point); } //Move the envelope feedback IPoint m_feedBack.MoveTo(point); } public override void OnMouseUp(int Button, int Shift, int X, int Y) { if (Button == 4) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.Hand.cur"); m_changeCursor = true; return; point = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); =

} if (m_changeCursor) { base.m_cursor = new System.Windows.Forms.Cursor(GetType(), "Cursor.ZoomIn.cur"); m_changeCursor = false; } // TODO: Add esriMapZoomInToolClass.OnMouseUp implementation if (!m_isMouseDown) return; //Get the focus map IActiveView pActiveView = (IActiveView)m_hookHelper.FocusMap; //If an envelope has not been tracked IEnvelope pEnvelope; if (m_feedBack == null) { //Zoom in from mouse click pEnvelope = pActiveView.Extent; pEnvelope.Expand(0.5, 0.5, true); pEnvelope.CenterAt(m_point); } else { //Stop the envelope feedback pEnvelope = m_feedBack.Stop(); //Exit if the envelope height or width is 0 if (pEnvelope.Width == 0 || pEnvelope.Height == 0) { m_feedBack = null; m_isMouseDown = false; } } //Set the new extent pActiveView.Extent = pEnvelope; //Refresh the active view pActiveView.Refresh(); m_feedBack = null; m_isMouseDown = false; } public override void Refresh(int hDC) { if (m_feedBack != null) m_feedBack.Refresh(hDC); base.Refresh(hDC); } #endregion



相关文章:
IDL-ITools手册
图像的频域滤波以及图像的旋转、放大、平移和各种格 ...它真正的贡献在于 ITool 的底层即:IDL 智能工具...它是一系列对 象类文件的设置和设计,使用户可以...
AE中实现 Control中的各种图形工具的方法
新闻网页贴吧知道音乐图片视频地图百科文库 ...类: 前面有 Controls 后面有 tool 的工具都可以用...CurrentTool = Cmd as ITool; } 同类的方法中用...
AE中实现_Control中的各种图形工具的方法
新闻 网页 贴吧 知道 音乐 图片 视频 地图 百科...类: 前面有 Controls 后面有 tool 的工具都可以用...CurrentTool = Cmd as ITool; } 同类的方法中用...
gis软件设计实验报告完整版
打印窗体界面 创建打印窗体类:PrintPageLayoutForm,...2. 地图浏览模块 A. 地图工具 实现工具栏中的控件...ITool tool = command as ITool; command.OnCreate...
GIS实习报告_图文
快捷键 设计、 工具栏设计 加载地图、 浮动加 载...任务栏里显示) StartPosition->CenterScreen(让窗口...CurrentTool = pselect as ITool; } 点选: I...
AE常用类、接口解释
14、Carto 类库支持地图的创建和显示,这些地图可以在...类库中有一个开发控件及与其一起使用的命令和工具。...5、IFeatureClass 接口是获取和设置要素类属性的主要...
AE中实现Control中的各种图形工具的方法
AE中实现Control中的各种图形工具的方法_计算机软件及...类:前面有 Controls 以) 示例: 后面有 tool 的...同类的方法中用到此方法的还有以下等: 放大: I...
使用VC++开发基于ArcEngine的三维管线距离分析组件
一定的规则制作的(ICommand/ITool 接口的实现), 主控件的特定事件(如鼠标、键盘事件)里调用 工具里对应的方法,再通过其 他组件共同协作,即可完成各种地图操作...
国家测绘成果档案存储与服务设施项目培训手册-空间大数...
构建软件所的开发工具包以及使已完成的应用程序...定义,包括 ICommand 、 IToolIToolControl ...Map 对象有操作地图中所有图层的属性:空间参考、地图...
C#+arcengine
选择“地图”选项卡,拖入 MapControl 控件,设置 ...此时,工具条中还没有任何工具,添加的方法也很简单...private ITool m_mapActiveTool = null; private ...
更多相关标签: