zoukankan      html  css  js  c++  java
  • C#制作鹰眼全过程(带注释)

    axMapControl1是主控件,axMapControl2鹰眼控件

    要看清楚事件响应

     

    1.鹰眼地图资源载入

    privatevoid axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)

            {

                //当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换

                axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);

                axMapControl2.Extent = axMapControl2.FullExtent;

            }

    2.绘制鹰眼矩形框

    private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)

            {

     

                // 得到新范围

                IEnvelope pEnv = (IEnvelope)e.newEnvelope;

     

                IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;

                IActiveView pAv = pGra as IActiveView;

                //在绘制前,清除axMapControl2中的任何图形元素

                pGra.DeleteAllElements();

     

                IRectangleElement pRectangleEle = new RectangleElementClass();

                IElement pEle = pRectangleEle as IElement;

                pEle.Geometry = pEnv;

     

                //设置鹰眼图中的红线框

                IRgbColor pColor = new RgbColorClass();

                pColor.Red = 255;

                pColor.Green = 0;

                pColor.Blue = 0;

                pColor.Transparency = 255;

                //产生一个线符号对象

                ILineSymbol pOutline = new SimpleLineSymbolClass();

                pOutline.Width = 2;

                pOutline.Color = pColor;

     

                //设置颜色属性

                pColor = new RgbColorClass();

                pColor.Red = 255;

                pColor.Green = 0;

                pColor.Blue = 0;

                pColor.Transparency = 0;

                //设置填充符号的属性

                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

                pFillSymbol.Color = pColor;

                pFillSymbol.Outline = pOutline;

     

                IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

                pFillShapeEle.Symbol = pFillSymbol;

                pGra.AddElement((IElement)pFillShapeEle, 0);

                pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            } 3. 实现互动

       private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)

            {

                IPoint pPt=new PointClass ();

                pPt.PutCoords (e.mapX ,e.mapY );

                //改变主控件的视图范围

                axMapControl1 .CenterAt (pPt );

            }

     

     

     

  • 相关阅读:
    Supervisord管理进程实践
    centos7优化启动项,关闭一些不必要开启的服务
    centos彻底删除文件夹、文件命令(centos 新建、删除、移动、复制等命令)讲解
    CentOS 7 vi编辑命令
    C# 23种设计模式汇总
    设计模式——速记口诀
    CentOS 7.x设置自定义开机启动,添加自定义系统服务
    T-SQL 之 事务
    T-SQL 之 触发器
    T-SQL 之 表变量和临时表
  • 原文地址:https://www.cnblogs.com/cuiguanghe/p/2963651.html
Copyright © 2011-2022 走看看