Пример #1
0
 /// <summary>
 /// 主视图的OnMouseDown事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     //当空间查询的状态为真时
     if (IsSpatialSearch)
     {
         //获取精确图层
         ILayer pLayer = axMapControl1.get_Layer(Get_Layer("北部湾"));
         //将图层强转成要素图层
         IFeatureLayer pFtLayer = pLayer as IFeatureLayer;
         //将要素图层的图层类强转成要素类
         IFeatureClass pFtClass = pFtLayer.FeatureClass as IFeatureClass;
         //随着鼠标拖动得到一个矩形框
         IEnvelope pEnvelope = axMapControl1.TrackRectangle();
         //调用核心空间查询函数(采用空间相交的方法esriSpatialRelIntersects)
         dataGridView1.DataSource = SpatialSearch(pFtClass, "",
                                                  pEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects);
         axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
 }
Пример #2
0
 private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (axMapControl2.Map.LayerCount > 0)
     {
         if (e.button == 1)
         {
             IPoint pPoint = new PointClass();
             pPoint.PutCoords(e.mapX, e.mapY);
             axMapControl1.CenterAt(pPoint);
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
         else if (e.button == 2)
         {
             IEnvelope pEnv = axMapControl2.TrackRectangle();
             axMapControl1.Extent = pEnv;
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
Пример #3
0
 private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     // 按下鼠标左键移动矩形框
     if (e.button == 1)
     {
         IPoint pPoint = new PointClass();
         pPoint.PutCoords(e.mapX, e.mapY);
         IEnvelope pEnvelope = this.axMapControl1.Extent;
         pEnvelope.CenterAt(pPoint);
         this.axMapControl1.Extent = pEnvelope;
         this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
     // 按下鼠标右键绘制矩形框
     else if (e.button == 2)
     {
         IEnvelope pEnvelop = this.axMapControl2.TrackRectangle();
         this.axMapControl1.Extent = pEnvelop;
         this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
 }
Пример #4
0
 /// <summary>
 /// 鹰眼地图的OnMouseDown事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (axMapControl2.LayerCount > 0)
     {
         //如果e.button==1, 则表示按下的是鼠标左键
         if (e.button == 1)
         {
             axMapControl2.Refresh();
             //捕捉鼠标单击时的地图坐标
             IPoint pPoint = new PointClass();
             pPoint.PutCoords(e.mapX, e.mapY);
             //将地图的中心点移动到鼠标点击的点pPoint
             axMapControl1.CenterAt(pPoint);
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
         else if (e.button == 2)
         {//如果e.button==2, 则表示按下的是鼠标右键
             //鹰眼地图的TrackRectangle()方法, 随着鼠标拖动得到一个矩形框
             IEnvelope pEnvelope = axMapControl2.TrackRectangle();
             axMapControl1.Extent = pEnvelope;//鼠标拖动生成的矩形框范围
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
Пример #5
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     SelectPoint(e.mapX.ToString(), e.mapY.ToString(), CheckLoading);
 }
Пример #6
0
        // 在地图上点击学校,获取支教信息
        private void axMapControl_Main_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            // 选择学校
            IMap       pMap       = axMapControl_Main.Map;
            IEnumLayer pEnumLayer = pMap.get_Layers(null, true);

            pEnumLayer.Reset();
            ILayer        pLayer = pEnumLayer.Next();
            IFeatureLayer pFeatureLayer;

            while (pLayer != null)
            {
                if (pLayer.Name == "china")
                {
                    pFeatureLayer            = (IFeatureLayer)pLayer;
                    pFeatureLayer.Selectable = false;
                }
                pLayer = pEnumLayer.Next();
            }

            IGeometry   selectGeometry = null;
            IEnvelope   pEnv;
            IActiveView pActiveView = axMapControl_Main.ActiveView;

            pEnv = axMapControl_Main.TrackRectangle();
            if (pEnv.IsEmpty == true)
            {
                ESRI.ArcGIS.esriSystem.tagRECT r;
                r.bottom = e.y + 5;
                r.top    = e.y - 5;
                r.left   = e.x - 5;
                r.right  = e.x + 5;
                pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
            }
            selectGeometry = pEnv as IGeometry;
            axMapControl_Main.Map.ClearSelection();
            axMapControl_Main.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            axMapControl_Main.Map.SelectByShape(selectGeometry, null, false);
            axMapControl_Main.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

            // 显示信息
            ISelection pselect = pMap.FeatureSelection;

            IEnumFeatureSetup pEnumFeatureSetup = (IEnumFeatureSetup)pselect;

            pEnumFeatureSetup.AllFields = true;
            IEnumFeature pEnumFeature = (IEnumFeature)pEnumFeatureSetup;

            //pEnumFeature.Reset();
            pfeature = pEnumFeature.Next();

            if (pfeature == null)
            {
                return;
            }

            SiteID = (dynamic)pfeature.get_Value(0);
            //GdbDrive Gdp = new GdbDrive();
            Searcher GDs = new Searcher();

            GDs.TableName = "SANexus";
            GDs.idField.Add("SID");
            GDs.idData.Add(SiteID);
            GDs.Fields.Add("TID");
            gdb.Query(ref GDs);

            if (GDs.array.Count < 1)
            {
                MessageBox.Show("该地区无支教活动!");
                return;
            }
            LookUp(GDs.array[0][0]);


            //resultGrid.Rows[0].Cells[0].Value = name;
            //signUpGrid.Rows[0].Cells[0].Value = pfeature.get_Value(2).ToString();
        }
 //地图鼠标点击事件
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1)
     {
     }
 }
Пример #8
0
 private void axMapControlR_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
 }
Пример #9
0
        /// <summary>
        /// 鼠标点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void myMap_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            try
            {
                if (e.button == 4)
                {
                    myMap.Pan();
                }

                IActiveView        pActiveView        = myMap.ActiveView;
                IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
                IPoint             Click_Point        = new PointClass();
                IEnumElement       pEnumEle;
                IElement           pElement;
                Click_Point.PutCoords(e.mapX, e.mapY);

                //    //无人机单位添加--获取图上经纬度
                //    if (e.button == 1 && MainInterface.company != null && MainInterface.company.Text != "")
                //    {
                //        IPoint pnt = this.myMap.ToMapPoint(e.x, e.y);
                //        if (MainInterface.company == null) return;
                //        MainInterface.company.lat = pnt.Y.ToString();
                //        MainInterface.company.lon = pnt.X.ToString();
                //        MainInterface.company.ShowConpanyInfor();
                //        if (MainInterface.company.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //        {
                //            Main.Program.ShowUAVComp();
                //            Main.MainInterface.refQueryResults();
                //            MainInterface.company = null;
                //        }
                //    }

                //    //无人机单位编辑--获取图上经纬度
                //    if (e.button == 1 && MainInterface.modComp != null && MainInterface.modComp.Text != "")
                //    {
                //        IPoint pnt = this.myMap.ToMapPoint(e.x, e.y);
                //        if (MainInterface.modComp == null) return;
                //        MainInterface.modComp.lat = pnt.Y.ToString();
                //        MainInterface.modComp.lon = pnt.X.ToString();
                //        MainInterface.modComp.ShowConpanyInfor();
                //        if (MainInterface.modComp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //        {
                //            Main.Program.ShowUAVComp();
                //            Main.MainInterface.refQueryResults();
                //            MainInterface.modComp = null;
                //        }
                //    }

                //    //灾区添加--获取图上经纬度
                //    else if (e.button == 1 && MainInterface.addForm != null && MainInterface.addForm.Text != "")
                //    {
                //        IPoint pnt = this.myMap.ToMapPoint(e.x, e.y);
                //        if (MainInterface.addForm == null) return;
                //        MainInterface.addForm.lat = pnt.Y.ToString();
                //        MainInterface.addForm.lon = pnt.X.ToString();
                //        MainInterface.addForm.ShowConpanyInfor();
                //        if (MainInterface.addForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //        {
                //            MainInterface.treeRefresh();
                //            MainInterface.addForm = null;
                //        }
                //    }

                //    //灾区编辑--获取图上经纬度
                //    else if (e.button == 1 && MainInterface.modForm != null && MainInterface.modForm.Text != "")
                //    {
                //        IPoint pnt = this.myMap.ToMapPoint(e.x, e.y);
                //        if (MainInterface.modForm == null) return;
                //        MainInterface.modForm.lat = pnt.Y.ToString();
                //        MainInterface.modForm.lon = pnt.X.ToString();
                //        MainInterface.modForm.ShowConpanyInfor();
                //        if (MainInterface.modForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //        {
                //            MainInterface.treeRefresh();
                //            MainInterface.modForm = null;
                //        }
                //    }

                //    //障碍点添加--获取图上经纬度
                //    else if (e.button == 1 && Task.BarriesManager.frmBarriesAdd != null && Task.BarriesManager.frmBarriesAdd.Text != "")
                //    {
                //        IPoint pnt = this.myMap.ToMapPoint(e.x, e.y);
                //        if (Task.BarriesManager.frmBarriesAdd == null) return;
                //        Task.BarriesManager.frmBarriesAdd.lat = pnt.Y.ToString();
                //        Task.BarriesManager.frmBarriesAdd.lon = pnt.X.ToString();
                //        Task.BarriesManager.frmBarriesAdd.ShowConpanyInfor();
                //        if (Task.BarriesManager.frmBarriesAdd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //        {
                //            Main.Program.ShowBarries();
                //            Task.BarriesManager.Refesh();
                //            Task.BarriesManager.frmBarriesAdd = null;
                //        }
                //    }

                //    //依据点击位置获取元素
                //    pEnumEle = pGraphicsContainer.LocateElements(Click_Point, 0);
                //    if (pEnumEle != null)
                //    {
                //        pElement = pEnumEle.Next();
                //        if (pElement.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                //        {
                //            IPoint pPoint1 = pElement.Geometry as IPoint;
                //            IElementProperties pElmentProperties = pElement as IElementProperties;
                //            if (pElmentProperties.Name.Split('|')[0] == "Intersect")
                //            {
                //                ISymbol symbol = MapHelper.CreateSimpleSymbol(Color.Blue, 8, ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle);
                //                AddElement(pPoint1, symbol, "GatherPoint|" + pElmentProperties.Name.Substring(10));
                //            }
                //            else if (pElmentProperties.Name.Split('|')[0] == "GatherPoint")
                //            {
                //                pGraphicsContainer.DeleteElement(pElement);
                //            }

                //            else if (pElmentProperties.Name.Split('|')[0] == "UAVInfor")
                //            {
                //                int uavID = Convert.ToInt32(pElmentProperties.Name.Split('|')[1]);
                //                Core.Model.UAVBD UAVModel = new Core.Model.UAVBD();
                //                Core.DAL.UAVBD UAVDAL = new Core.DAL.UAVBD();
                //                UAVModel = UAVDAL.GetModel(uavID);
                //                IPoint pnt = new ESRI.ArcGIS.Geometry.Point();
                //                pnt.X = UAVModel.X;
                //                pnt.Y = UAVModel.Y;
                //                CoScheduling.Main.DisaArea.DisaAreaHelper.CreateTextElment(pnt, UAVModel.Name);
                //            }
                //            else if (pElmentProperties.Name == "UAVCallout")
                //            {
                //                pGraphicsContainer.DeleteElement(pElement);
                //            }

                //            else if (pElmentProperties.Name.Split('|')[0] == "VolInfo") //志愿者信息
                //            {
                //                int VolID = Convert.ToInt32(pElmentProperties.Name.Split('|')[1]);
                //                Volunteer.VUserInfo frm = new Volunteer.VUserInfo();
                //                frm.ID = VolID;
                //                frm.Show();
                //            }



                //            pActiveView.Refresh();
                //        }
                //        else if (pElement.Geometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                //        {
                //            IPolygon pPolygon = pElement.Geometry as IPolygon;
                //            IElementProperties pElmentProperties = pElement as IElementProperties;
                //            if (pElmentProperties.Name.Split('|')[0] == "TaskState")//任务执行状态
                //            {
                //                int uid = Convert.ToInt32(pElmentProperties.Name.Split('|')[1].Split(',')[1]);
                //                Main.UAV.FrmUAVMessage uavInfo = new UAV.FrmUAVMessage();
                //                uavInfo.StartPosition = FormStartPosition.CenterParent;
                //                uavInfo.UID = uid;
                //                uavInfo.Show();
                //            }
                //            else if (pElmentProperties.Name.Split('|')[0] == "SatResaultInfo") //卫星规划结果信息
                //            {
                //                //获取规划结果id
                //                int imgID = Convert.ToInt32(pElmentProperties.Name.Split('|')[1]);
                //                CoScheduling.Core.Model.SatelliteResault model = new CoScheduling.Core.Model.SatelliteResault();
                //                CoScheduling.Core.DAL.SatelliteResault dal_model = new CoScheduling.Core.DAL.SatelliteResault();
                //                //根据id获取规划结果实体类
                //                model = dal_model.GetModel(imgID);
                //                //重新绘制图形
                //                Core.Map.MapHelper map = new Core.Map.MapHelper(Program.myMap);
                //                ISymbol pSymbol = map.CreateSimpleFillSymbol(Color.Blue, 4, esriSimpleFillStyle.esriSFSCross);
                //                IPolygon satPolygon = Core.Generic.Convertor.ToPolygon(model.POLYGONSTRING);
                //                Program.myMap.FlashShape(satPolygon, 10, 100, pSymbol);

                //                //关闭已打开详细信息窗口
                //                foreach (Form form in Application.OpenForms)
                //                {
                //                    if (form.Name == "SatelliteResaultDetail")
                //                    {
                //                        form.Close();
                //                        break;
                //                    }
                //                }
                //                //弹出详细信息窗口
                //                Satellite.SatelliteResaultDetail newform = new Satellite.SatelliteResaultDetail(imgID);
                //                newform.StartPosition = FormStartPosition.CenterScreen;
                //                newform.Show();

                //            }
                //        }
                //    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误:" + ex.Message);
            }
        }