Exemplo n.º 1
0
 private void 全域导出ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (frmExpMap == null || frmExpMap.IsDisposed)
     {
         frmExpMap = new mapexport(axMapControl1);
     }
     frmExpMap.isRegion = false;//表示为全域导出
     frmExpMap.geometry = axMapControl1.ActiveView.Extent;
     frmExpMap.Show();
     frmExpMap.Activate();
 }
Exemplo n.º 2
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            IActiveView pActiveview = axMapControl1.ActiveView;
            IEnvelope   envelope    = new EnvelopeClass();

            pPointPt = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            switch (mousedownname)
            {
            case "":
                break;

            case "zoomin":                                                                               //拉框放大
                envelope = axMapControl1.TrackRectangle();                                               //获取拉框信息
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0) //判断是否为空框
                {
                    return;
                }
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "zoomout":    //拉框缩小
                envelope = axMapControl1.TrackRectangle();
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0)
                {
                    return;
                }
                double dwidth  = pActiveview.Extent.Width * pActiveview.Extent.Width / envelope.Width;
                double dheight = pActiveview.Extent.Height * pActiveview.Extent.Height / envelope.Height;
                double dXmin   = pActiveview.Extent.XMin - ((envelope.XMin - pActiveview.Extent.XMin) * pActiveview.Extent.Width / envelope.Width);
                double dYmin   = pActiveview.Extent.YMin - ((envelope.YMin - pActiveview.Extent.YMin) * pActiveview.Extent.Height / envelope.Height);
                double dxMAX   = dXmin + dwidth;
                double dyMAX   = dYmin + dheight;
                envelope.PutCoords(dXmin, dYmin, dxMAX, dyMAX);
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "manyou":    //漫游
                axMapControl1.Pan();
                break;

            case "MeasureLength":    //长度量测

                if (pNewLineFeedback == null)
                {
                    pNewLineFeedback = new NewLineFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                   //实例化追踪线对象
                    pNewLineFeedback.Start(pPointPt);    //设置起点,开始动态绘制
                    dToltaLength = 0;
                }
                else    //如果追踪线对象不为空,则添加当前鼠标点
                {
                    pNewLineFeedback.AddPoint(pPointPt);
                }
                if (dSegmentLength != 0)
                {
                    dToltaLength = dToltaLength + dSegmentLength;
                }
                break;

            case "MeasureArea":    //面积量测

                if (pNewPolygonFeedback == null)
                {
                    pNewPolygonFeedback = new NewPolygonFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                                                     //实例化面对象
                    pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集
                    pNewPolygonFeedback.Start(pPointPt);                                   //开始绘制多边形
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }
                else
                {
                    pNewPolygonFeedback.AddPoint(pPointPt);
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }

                break;

            case "selectfeature":    //要素选择
                IEnvelope pEnv = axMapControl1.TrackRectangle();
                IGeometry pGeo = pEnv;
                if (pEnv.IsEmpty)    //若为空则在鼠标当前点进行选择部分区域作为框
                {
                    tagRECT r;
                    r.left   = e.x - 5;
                    r.top    = e.y - 5;
                    r.right  = e.x + 5;
                    r.bottom = e.y + 5;
                    pActiveview.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                    pEnv.SpatialReference = pActiveview.FocusMap.SpatialReference;
                }
                pGeo = pEnv;
                axMapControl1.Map.SelectByShape(pGeo, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                break;

            case "ExportRegion":
                pActiveview.GraphicsContainer.DeleteAllElements();
                pActiveview.Refresh();
                IPolygon pPolygon = ExportMap.DrawPolygon(axMapControl1);
                if (pPolygon == null)
                {
                    return;
                }
                ExportMap.AddElement(pPolygon, pActiveview);
                if (frmExpMap == null || frmExpMap.IsDisposed)
                {
                    frmExpMap = new mapexport(axMapControl1);
                }
                frmExpMap.isRegion = true;
                frmExpMap.geometry = pPolygon;
                frmExpMap.Show();
                frmExpMap.Activate();
                break;
            }
        }