C#鹰眼_带拖动

简介:

 

结合help中给的例子,又使用DisPlayFeedBack,实现在鹰眼中拖动。拖动过程中小边框的显示问题解决的不是很好,还望大家多多指教。
实现如下:
两个MapControl控件:axMapControl1和axMapControl2,axMapControl2存放鹰眼地图。
主要变量有:
private IEnvelope m_Envelope;   //The envelope drawn on the small MapControl---axMapControl2.
private System.Object m_FillSymbol;   //The symbol used to draw the envelope on the small MapControl

//axMapControl1中的事件

private void CreateOverviewSymbol() //create the symbol used in the small MapControl ,自定义函数
        {
            //Get the IRGBColor interface.
            IRgbColor color = new RgbColorClass();
            //Set the color properties.
            color.RGB = 255;
            //Get the ILine symbol interface.
            ILineSymbol outline = new SimpleLineSymbolClass();
            //Set the line symbol properties.
            outline.Width = 1.5;
            outline.Color = color;
            //Get the IFillSymbol interface.
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            //Set the fill symbol properties.
            simpleFillSymbol.Outline = outline;
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
            m_FillSymbol = simpleFillSymbol;
        }
private void axMapControl1_OnMapReplaced(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e) //更新axMapControl1地图时装载鹰眼地图
        {
            axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);
            axMapControl2.Extent=axMapControl1.FullExtent;                       
            m_Envelope = axMapControl1.ActiveView.Extent;
        }

private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {   //axMapControl1的范围变化时,设置鹰眼小边框m_Envelope 的大小
            axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            m_Envelope = e.newEnvelope as IEnvelope;
        }
private void axMapControl1_OnAfterDraw(object sender, IMapControlEvents2_OnAfterDrawEvent e)
        {
            if (m_Envelope == null) return;
            //If the foreground phase has drawn.
            esriViewDrawPhase viewDrawPhase = (esriViewDrawPhase)e.viewDrawPhase;
            if (viewDrawPhase == esriViewDrawPhase.esriViewForeground)
            {
                axMapControl2.DrawShape(m_Envelope as IGeometry, ref m_FillSymbol);
            }
        }
几个变量:
private IMoveEnvelopeFeedback pSmallViewerEnvelope ;//鹰眼小地图的红框
private IPoint pSmallViewerMouseDownPt ;//拖动时鼠标落点
private bool isTrackingSmallViewer = false; //标识是否在拖动
static int moveCount = 0 ;//记录移动的个数,为移动过程中显示红框用。权宜之计,望高手提出更好解决方案

//axMapControl2中的事件
private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)//鹰眼互动
        {
            //IPoint pt = new PointClass();
            pSmallViewerMouseDownPt = new PointClass();
            pSmallViewerMouseDownPt.PutCoords(e.mapX, e.mapY);
            axMapControl1.CenterAt(pSmallViewerMouseDownPt);


            isTrackingSmallViewer = true;
            if (pSmallViewerEnvelope == null)
            {
                pSmallViewerEnvelope = new MoveEnvelopeFeedbackClass();
                pSmallViewerEnvelope.Display = axMapControl2.ActiveView.ScreenDisplay;
                pSmallViewerEnvelope.Symbol = (ISymbol)m_FillSymbol;
            }
            pSmallViewerEnvelope.Start(m_Envelope, pSmallViewerMouseDownPt);
            
        }
      
       private void axMapControl2_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (isTrackingSmallViewer)
            {
                moveCount++;
                if (moveCount % 4 == 0)//因为一刷新,红框就没了。所以每移动4次就刷新一下,保持红框的连续性。
                    axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                pSmallViewerMouseDownPt.PutCoords(e.mapX, e.mapY);
                pSmallViewerEnvelope.MoveTo(pSmallViewerMouseDownPt);

            }            
        }
       private void axMapControl2_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
        {
            if (pSmallViewerEnvelope != null)
            {
                m_Envelope = pSmallViewerEnvelope.Stop();
                axMapControl1.Extent = m_Envelope;
                isTrackingSmallViewer = false;               
            }
        }

版权说明

  如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
  作      者:温景良
  文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

0
0
« 上一篇: C#制作鹰眼全过程(带注释)
» 下一篇: AE实现不同图层的合并C#代码
posted @ 2008-12-10 15:07 温景良(Jason) Views( 1115) Comments( 0) Edit 收藏
 
相关文章
|
10月前
|
前端开发 JavaScript
uniapp移动端悬浮按钮(吸附边缘)
uniapp移动端悬浮按钮(吸附边缘)
419 0
|
2月前
|
数据可视化 数据挖掘 BI
|
4月前
推荐一款酷炫闪烁的告警按钮
闪烁的告警按钮
34 1
|
9月前
技术好文:UITableView(可滚动到顶部和底部)
技术好文:UITableView(可滚动到顶部和底部)
49 0
|
10月前
|
测试技术 定位技术
【sgDragMoveTile】自定义组件:拖拽瓦片图、地图、大图,滚动条对应同步滚动
【sgDragMoveTile】自定义组件:拖拽瓦片图、地图、大图,滚动条对应同步滚动
|
JSON 前端开发 数据可视化
Echarts实战案例代码(4):地图散点气泡图飞线(迁徙线)API接口前端处理数据的解决方案
Echarts实战案例代码(4):地图散点气泡图飞线(迁徙线)API接口前端处理数据的解决方案
364 0
如何实现一个丝滑的点击水波效果
本文为Varlet组件库源码主题阅读系列第九篇,读完本篇,可以了解到如何使用一个`div`创建一个点击的水波效果。
119 0
html+css实战190-侧导航布局-箭头
html+css实战190-侧导航布局-箭头
174 0
html+css实战190-侧导航布局-箭头
|
监控 数据可视化 前端开发
轻松教你搞定组件的拖拽, 缩放, 多控制点伸缩和拖拽数据上报
最近笔者专注于研究可视化搭建平台的解决方案, 分析了很多拖拽组件和页面动态化技术, 也在 H5-Dooring 项目中做了很多技术实现, 包括:
493 0
|
C++
Qt Qwdget 汽车仪表知识点拆解5 标题栏图标闪烁
先贴上效果图,注意,没有写逻辑,都是乱动的
155 0
Qt Qwdget 汽车仪表知识点拆解5 标题栏图标闪烁