示例#1
0
 private void ExportToMapItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (exportmapFrm == null || exportmapFrm.IsDisposed)
         {
             exportmapFrm = new ExportMapFrm(this.axMapcontrol);
         }
         exportmapFrm.GetGeometry = this.axMapcontrol.ActiveView.Extent;
         exportmapFrm.IsRgion     = false;
         exportmapFrm.Show();
         //激活窗体并赋予它焦点
         exportmapFrm.Activate();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        /// <summary>
        ///鼠标点击操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapcontrol_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            Dwnpoint = new PointClass();
            Dwnpoint = this.axMapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button != 1)
            {
                return;
            }
            #region 地图操作
            switch (pMouseOperate)
            {
            case  "区域导出":
                //删除绘制的图片
                this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements();
                this.axMapcontrol.ActiveView.Refresh();
                IPolygon polygon = DrawPolygon(this.axMapcontrol);
                if (polygon == null)
                {
                    return;
                }
                ExportMap.AddElement(polygon, this.axMapcontrol.ActiveView);
                if (polygon == null)
                {
                    return;
                }
                if (exportmapFrm == null || exportmapFrm.IsDisposed)
                {
                    exportmapFrm             = new ExportMapFrm(this.axMapcontrol);
                    exportmapFrm.IsRgion     = true;
                    exportmapFrm.GetGeometry = polygon as IGeometry;
                    exportmapFrm.Show();
                }
                exportmapFrm.GetGeometry = polygon;
                exportmapFrm.IsRgion     = true;
                //获取当前控件焦点
                exportmapFrm.Activate();
                break;

            case "MeasureLength":
                if (m_newline == null)
                {
                    m_newline         = new NewLineFeedbackClass();
                    m_newline.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newline.Start(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    TotalLength += SegmentLength;
                    m_newline.AddPoint(Dwnpoint);
                }
                break;

            case "MeasureArea":
                if (m_newpolygon == null || Area_Pocoll == null)
                {
                    m_newpolygon         = new NewPolygonFeedbackClass();
                    Area_Pocoll          = new PolygonClass();
                    m_newpolygon.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newpolygon.Start(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    m_newpolygon.AddPoint(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength += SegmentLength;
                }
                break;
            }


            #endregion
        }