示例#1
0
        public void zoomIn()
        {
            IEnvelope pEnvelope = mapControl.TrackRectangle();

            mapControl.Extent = pEnvelope;
            mapControl.Refresh();
        }
示例#2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IGeometry   geometry = null;
            IEnvelope   pEnv;
            IActiveView pActiveView = m_axMapControl.ActiveView;
            IMap        pMap        = m_axMapControl.Map;

            pEnv = m_axMapControl.TrackRectangle();
            if (pEnv.IsEmpty == true)
            {
                ESRI.ArcGIS.esriSystem.tagRECT rect;
                rect.bottom = Y + 5;
                rect.top    = Y - 5;
                rect.left   = X - 5;
                rect.right  = X + 5;
                pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref rect, 4);
                pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
            }
            geometry = pEnv as IGeometry;
            m_axMapControl.Map.SelectByShape(geometry, null, false);

            GetFeaturesByShape(geometry);

            this.m_axMapControl.Map.ClearSelection();
            this.m_axMapControl.ActiveView.Extent = pEnv;
            m_axMapControl.ActiveView.Refresh();//刷新
        }
示例#3
0
        //定义鼠标与地图交互的方法
        public void OperMap()
        {
            switch (strOperType)
            {
            case "LKZoomIn":
            {
                axMapControl1.Extent = axMapControl1.TrackRectangle();
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            break;

            default:
                break;
            }
        }
示例#4
0
        public void RectangleSelect(AxMapControl mapControl)
        {
            this.init();
            IEnvelope pEnv;

            pEnv = mapControl.TrackRectangle();
            //新建选择集对象
            ISelectionEnvironment pSelectionEnvR;

            pSelectionEnvR = new SelectionEnvironmentClass();
            //改变选择集的默认颜色
            pSelectionEnvR.DefaultColor = pColor;
            //选择要素,并将其放入选择集
            mapControl.Map.SelectByShape(pEnv, pSelectionEnvR, false);
            mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,
                                                 null, null);
        }
示例#5
0
 public void MoveEagl()
 {
     if (ed.button == 1)//探测鼠标左键
     {
         IPoint pPt = new ESRI.ArcGIS.Geometry.Point();
         //IPoint pPt = new PointClass();
         pPt.X = ed.mapX;
         pPt.Y = ed.mapY;
         IEnvelope pEnvelope = axMapControl1.Extent as IEnvelope;
         pEnvelope.CenterAt(pPt);
         axMapControl1.Extent = pEnvelope;
         axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
     else if (ed.button == 2)//探测鼠标右键
     {
         IEnvelope pEnvelope = axMapControl2.TrackRectangle();
         axMapControl1.Extent = pEnvelope;
         axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
 }
 //在鹰眼控件的OnMouseDown里使用
 public static void RectangleClick(AxMapControl mapControl1, AxMapControl mapControl2, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (mapControl2.Map.LayerCount != 0)
     {
         // 按下鼠标左键移动矩形框
         if (e.button == 1)
         {
             IPoint pPoint = new PointClass();
             pPoint.PutCoords(e.mapX, e.mapY);
             IEnvelope pEnvelope = mapControl1.Extent;
             pEnvelope.CenterAt(pPoint);
             mapControl1.Extent = pEnvelope;
             mapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
         // 按下鼠标右键绘制矩形框
         else if (e.button == 2)
         {
             IEnvelope pEnvelop = mapControl2.TrackRectangle();
             mapControl1.Extent = pEnvelop;
             mapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
示例#7
0
        public void OnMouseDownRun(IPoint clickPT)
        {
            IEnvelope envelope = mapControl.TrackRectangle();

            if (envelope.IsEmpty)
            {
                if (e == null)
                {
                    return;
                }
                tagRECT rect;
                rect.top    = e.y - 5;
                rect.bottom = e.y + 5;
                rect.left   = e.x - 5;
                rect.right  = e.x + 5;
                mapControl.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(envelope, ref rect, 4);
                envelope.SpatialReference = mapControl.ActiveView.FocusMap.SpatialReference;
            }
            IGeometry geometry = envelope as IGeometry;

            mapControl.Map.SelectByShape(geometry, null, false);
            mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
示例#8
0
        private void axMapControlMainMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            int statusFlag = CommonLib.MapMouseFlag;

            if (statusFlag <= 1)
            {
                return;
            }

            AxMapControlMainMap.MousePointer = esriControlsMousePointer.esriPointerCrosshair;//鼠标指针:十字状
            IPoint pPoint = AxMapControlMainMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            #region 11-19:空间查询(画点、线、面)
            if (statusFlag >= 11 && statusFlag <= 19)
            {
                object symbol = null;
                switch (statusFlag)
                {
                case 11:
                    IPoint point = new ESRI.ArcGIS.Geometry.Point();
                    point.X = e.mapX;
                    point.Y = e.mapY;
                    CommonLib.MapGeometry = point;
                    symbol = RenderOpt.GetSimpleMarkerSymbol("ff0000");
                    break;

                case 12:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackLine();
                    symbol = RenderOpt.GetSimpleLineSymbol("ff0000");
                    break;

                case 13:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackPolygon();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                case 14:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackRectangle();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                default:
                    CommonLib.MapGeometry = null;
                    break;
                }

                if (CommonLib.MapGeometry != null)
                {
                    //axMapControlMainMap.Map.SelectByShape(CommonLib.MapGeometry, null, false);
                    //axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    AxMapControlMainMap.DrawShape(CommonLib.MapGeometry, ref symbol);
                }
            }
            #endregion
            #region
            //#region 绘制图形
            //if (CommonLib.MapMouseFlag >= 1 && CommonLib.MapMouseFlag <= 4)
            //{
            //    //初始化Color
            //    IRgbColor rgbColor1 = new RgbColor();
            //    rgbColor1.Red = 255;
            //    rgbColor1.Green = 255;
            //    rgbColor1.Blue = 0;

            //    //初始化Symbol
            //    object symbol = null;
            //    if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline) //线
            //    {
            //        ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
            //        simpleLineSymbol.Color = rgbColor1;
            //        simpleLineSymbol.Width = 5;
            //        symbol = simpleLineSymbol;
            //    }
            //    else
            //    {
            //        ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol();
            //        simpleFillSymbol.Color = rgbColor1;
            //        symbol = simpleFillSymbol;
            //    }

            //    axMapControlMainMap.DrawShape(geometry, ref symbol);
            //}
            //else if (CommonLib.MapMouseFlag == 5)
            //{
            //    //初始化Color
            //    IRgbColor rgbColor2 = new RgbColor();
            //    rgbColor2.Red = 255;
            //    rgbColor2.Green = 0;
            //    rgbColor2.Blue = 0;

            //    //初始化Symbol
            //    object symbol = null;
            //    ITextSymbol textSymbol = new TextSymbol();
            //    textSymbol.Color = rgbColor2;
            //    symbol = textSymbol;

            //    axMapControlMainMap.DrawText(geometry, "顶你个肺", ref symbol);
            //}
            //#endregion

            //#region 空间选择
            //if (CommonLib.MapMouseFlag >= 11 && CommonLib.MapMouseFlag <= 15)
            //{
            //    axMapControlMainMap.Map.SelectByShape(geometry, null, false);
            //}
            //axMapControlMainMap.Refresh();

            //#endregion
            #endregion
        }