Example #1
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //IMapDocument mxd;
            string x;
            x = e.mapX.ToString("#########.########");
            string y;
            y = e.mapY.ToString("#########.########");

            string data;
            data = "";
            data += string.Format("The map has x coordinate {0} \n y coordinate {1}", x, y);

            Form1 msgForm = new Form1();
            msgForm.label1.Text = data;
            //msgForm.ShowDialog();
            IPropertySet location = new PropertySet();
            location.SetProperty("ps","C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb");
            string featureBuffer = "C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb\\Buffer";
            string featurePoint = "C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb\\AdditionalPoint";
            IFeatureWorkspace ws;
            IFeature newPoint = ws.OpenFeatureClass(featurePoint) as IFeature;
            IFeature newBuffer = ws.OpenFeatureClass(featureBuffer) as IFeature;

                Geom.IPoint point = new Geom.PointClass();
                point.PutCoords(e.mapX, e.mapY);
                newPoint.Shape = point;
                IFeatureClass pointFC = newPoint as IFeatureClass;
                newPoint.Store();
        }
Example #2
0
        private void axMapControlMain_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //实现不同的选择

            this.axMapControlMain.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            IGeometry geometry = null;
            switch (iFlagSelection)
            {
                case 0:
                    ESRI.ArcGIS.Geometry.Point point = new ESRI.ArcGIS.Geometry.PointClass();
                    point.X = e.mapX;
                    point.Y = e.mapY;
                    geometry = point as IGeometry;
                    break;
                case 1:
                    geometry = this.axMapControlMain.TrackRectangle();
                    break;
                case 2:
                    geometry = this.axMapControlMain.TrackPolygon();
                    break;
                case 3:
                    geometry = this.axMapControlMain.TrackCircle();
                    break;
                case 4:
                    geometry = this.axMapControlMain.TrackLine();
                    break;
            }
            this.axMapControlMain.Map.SelectByShape(geometry, null, false);
            this.axMapControlMain.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            this.axMapControlMain.CurrentTool = null;
        }
Example #3
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint        point        = new PointClass();
            IFeatureClass featureClass = null;

            if (m_Feature == null)
            {
                return;
            }
            switch (strOperator)
            {
            case "move":
                //将当前鼠标位置的点转换为地图上的坐标
                point = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                {
                    //设置显示对象,并启动移动
                    m_MovePointFeedback.Display = m_activeView.ScreenDisplay;
                    m_MovePointFeedback.Start(m_Feature.Shape as IPoint, point);
                }
                else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                {
                    //设置显示对象,并启动移动
                    m_MoveLineFeedback.Display = m_activeView.ScreenDisplay;
                    m_MoveLineFeedback.Start(m_Feature.Shape as IPolyline, point);
                }
                else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                {
                    //设置显示对象,并启动移动
                    m_MovePolygonFeedback.Display = m_activeView.ScreenDisplay;
                    m_MovePolygonFeedback.Start(m_Feature.Shape as IPolygon, point);
                }
                break;
            }
        }
Example #4
0
 private void method_8(object obj, IMapControlEvents2_OnMouseDownEvent mapControlEvents2_OnMouseDownEvent)
 {
     if (mapControlEvents2_OnMouseDownEvent.button == 1 && m_iApp.MapControl.CurrentTool == null)
     {
         this.SetMousePoint(mapControlEvents2_OnMouseDownEvent.x, mapControlEvents2_OnMouseDownEvent.y);
     }
 }
Example #5
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (axMap.MousePointer == esriControlsMousePointer.esriPointerPan)
            {
                axMap.Pan();
            }

            if (e.button == 4)
            {
                //     axMap.MousePointer = esriControlsMousePointer.esriPointerPan;
                axMap.Pan();
            }

            if (isBuffering && e.button == 1)
            {
                //选择要素
                selectFeatrue(e.x, e.y);

                if (mFeatures != null)
                {
                    mFeatures.Clear();
                }

                ////获取缓冲区的要素
                mFeatures = MapManager.createBuffer(axMap, bufferSize, "story", false);

                //删除以前生成的缓冲区要素
                for (int i = 0; i < mStoryTips.Count; i++)
                {
                    MyTip tip = mStoryTips[i];
                    tip.Close();
                }
                mStoryTips.Clear();

                List <String> ids = new List <string>();
                for (int i = 0; i < mFeatures.Count; i++)
                {
                    IFeature feature = mFeatures[i];
                    if (feature != null)
                    {
                        String id = (string)MapManager.getFieldByName(feature, "story_id");

                        MyTip storyTip = new MyTip(id);

                        storyTip.TopMost  = true;
                        storyTip.Location = MapManager.getCurrentCoord(feature, axMap, this, storyTip);

                        if (isCanTipShow(storyTip))
                        {
                            storyTip.Show();
                        }



                        mStoryTips.Add(storyTip);
                    }
                }
            }
        }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         //Popup the menu
         m_navigationMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
     }
 }
Example #7
0
 private void axMapControl_sub_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         IEnvelope pEnv = axMapControl_sub.TrackRectangle();
         axMapControl1.Extent = pEnv;
     }
 }
        private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint point = new PointClass();

            point.X = e.mapX;
            point.Y = e.mapY;
            axMapControl1.CenterAt(point);
        }
Example #9
0
 /// <summary>
 /// 主地图控件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         //弹出右键菜单
         m_menuMap.PopupMenu(e.x, e.y, m_mapControl.hWnd);
     }
 }
Example #10
0
        private void MapHawkEye_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IEnvelope pEnvelope = MapHawkEye.TrackRectangle();

            MapHawkEye.ActiveView.Refresh();
            EngineFuntions.m_AxMapControl.ActiveView.Extent = pEnvelope;
            EngineFuntions.m_AxMapControl.ActiveView.Refresh();
        }
Example #11
0
 void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (4 == e.button)
     {
         mScreenDisplay = this.axMapControl1.ActiveView.ScreenDisplay;
         mScreenDisplay.PanStart(mScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y));
     }
 }
Example #12
0
        //鹰眼图鼠标下落事件
        private void axMapControl_Eagle_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint Pnt;

            Pnt = new ESRI.ArcGIS.Geometry.Point();
            Pnt.PutCoords(e.mapX, e.mapY);
            axMapControl_1.CenterAt(Pnt);
            axMapControl_1.Refresh();
        }
Example #13
0
        private void axMapControl1_OnMouseDown(object sender,
                                               IMapControlEvents2_OnMouseDownEvent e)
        {
//            鼠标中键平移图层
            if (e.button == 4)
            {
                axMapControl1.Pan();
            }
        }
Example #14
0
 private void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (eventInited == 0)
     {
         mapControl.OnMouseMove += mapControl_OnMouseMove;
         mapControl.OnMouseUp   += mapControl_OnMouseUp;
         eventInited             = 1;
     }
 }
Example #15
0
        void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (axMapControl1.CurrentTool != null)
            {
                return;
            }
            axMapControl1.Focus();
            switch (m_CurMapOperation)
            {
            case MapOperation.MapSelectByRect:
                MapSelectByGeometry();
                break;

            case MapOperation.Map_PointSel:
                Map_PointSel(e.mapX, e.mapY);
                break;

            case MapOperation.MapCircleSelect:
                MapSelectByGeometry();
                break;

            case MapOperation.MapPolygonSelect:
                MapSelectByGeometry();
                break;

            case MapOperation.MapUserIdentify:
                MapUserIdentify(e.mapX, e.mapY);
                break;

            case MapOperation.MapSelectPrint:
                MapSelectPrint();
                break;

            case MapOperation.MapCreateLine:
                CreateLine();
                break;

            case MapOperation.MapAddRectangleElement:
                AddRectangleElement();
                break;

            case MapOperation.MapAddCircleElemnt:
                AddCircleElement();
                break;

            case MapOperation.MapAddEllipseElemnt:
                AddEllipseElement();
                break;

            case MapOperation.MapAddPolygonElement:
                AddPolygonElement();
                break;

            default:
                break;
            }
        }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     AxMapControl MapControl = (AxMapControl)sender;
     if (e.button == 4)
     {
         MapControl.ActiveView.ScreenDisplay.PanStart(axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y));
         MapControl.MousePointer = esriControlsMousePointer.esriPointerPan;
     }
 }
Example #17
0
 private void axMapControl_main_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 4)
     {
         m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerPanning;
         m_pMapC2.Pan();
         m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerArrow;
     }
 }
Example #18
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (pFeatureLayer != null)
     {
         if (e.button == 2)
         {
             contextMenuStrip1.Show(new System.Drawing.Point(e.x + 191, e.y + 52));
         }
     }
 }
Example #19
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         System.Drawing.Point p = new System.Drawing.Point();
         p.X = e.x;
         p.Y = e.y;
         contextMenuStrip2.Show(axMapControl1, p);
     }
 }
Example #20
0
 private void axMapControl_HawkEye_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1)
     {
         m_pMapC2.CenterAt(new PointClass()
         {
             X = e.mapX, Y = e.mapY
         });
     }
 }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         if (e.button == 2)
         {
             m_toolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
         }
     }
 }
Example #22
0
 private void axMapControl_GlobeEye_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     try
     {
         showInfoOnMap.ZoomToPoint(this.axGlobeControl1, e.mapX, e.mapY);  //点击鹰眼地图,可以zoom到相应位置
         ////动画飞行
         //GISFunction.ZoomToPointWithAnimation.ZoomToPointAnimation(this.axGlobeControl1, e.mapX, e.mapY);
     }
     catch { }
 }
Example #23
0
 /// <summary>
 /// 编辑点按下事件
 /// </summary>
 /// <param name="element"></param>
 /// <param name="e"></param>
 private void editPoint_MarkerMouseDownEvent(IElement element, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (element == null)
     {
         return;
     }
     currentPoint = new PointClass();
     currentPoint.PutCoords(e.mapX, e.mapY);
     currentMarker = element as Model.EditMarker;
 }
Example #24
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     #region 中键点击:地图移动
     if (e.button == 4)
     {
         this.pMapC2.MousePointer = esriControlsMousePointer.esriPointerPanning;
         this.pMapC2.Pan();
         this.pMapC2.MousePointer = esriControlsMousePointer.esriPointerArrow;
     }
     #endregion
 }
Example #25
0
        /// <summary>
        /// 鼠标单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && !isControl)
            {
                downPoint = new MapLngLat(e.mapX, e.mapY);
                if (listMapPoints.Count == 0)
                {
                    ResultEventArgs(" ");
                    listMapPoints.Add(downPoint);
                    switch (measureType)
                    {
                    case "distance":
                        Kml kmlLine = new Kml();
                        kmlLine.Placemark.Name = "mea_line";

                        KmlLineString line = new KmlLineString();
                        line.PositionList       = listMapPoints;
                        line.Color              = Color.Gray;
                        line.Width              = 2;
                        kmlLine.Placemark.Graph = line;
                        IMFElement element = null;
                        layer.AddElement(kmlLine, out element);
                        measureLine = element as IMFLine;    //绘制完成后得到该图元
                        isFinish    = false;
                        break;

                    case "area":
                        Kml kml = new Kml();
                        kml.Placemark.Name = "mea_arcPolygon";
                        Color outlineColor = Color.Blue;
                        Color fillColor    = Color.Black;
                        kml.Placemark.Graph = new KmlPolygon()
                        {
                            FillColor = fillColor, OutLineColor = outlineColor, OutLineSize = 1, PositionList = listMapPoints
                        };
                        IMFElement element1 = null;
                        layer.AddElement(kml, out element1);
                        measurePolygon = element1 as IMFPolygon;
                        isFinish       = false;
                        break;
                    }
                }
                else
                {
                    listMapPoints.Add(downPoint);
                }

                if (segmentLength != 0)
                {
                    //长度
                    toltalLength += segmentLength;
                }
            }
        }
Example #26
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (miAddFeature.Checked == true)
     {
         IPoint point = new PointClass();
         point.PutCoords(e.mapX, e.mapY);
         DataOperator dataOperator = new DataOperator(axMapControl1.Map);
         dataOperator.AddFeatureToLayer("Observation Stations", "观测站", point);
     }
     return;
 }
Example #27
0
        public static void box_select(IMapControlEvents2_OnMouseDownEvent e)
        {
            mainForm.mainform.mainMapControl.CurrentTool = null;
            IMap        pMap        = mainForm.mainform.mainMapControl.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IEnvelope   pEnv        = new EnvelopeClass();

            pEnv = mainForm.mainform.mainMapControl.TrackRectangle();
            pMap.SelectByShape(pEnv, null, false);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
        //选座
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint pPoint = new PointClass(); //创建点实例 = 座位选取

            pPoint.PutCoords(e.mapX, e.mapY); // 也就是 pPoint.X = e.mapX;pPoint.Y = e.mapY;

            ITopologicalOperator pTopo = pPoint as ITopologicalOperator;
            //IGeometry pGeometry;//定义选座缓冲区范围
            IGeometry pGeometry = (IGeometry)pTopo.Buffer(1);//点缓冲区

            QueryByGeometry2(pGeometry);
        }
Example #29
0
        /// <summary>
        /// 鹰眼地图控制器按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EagleEyeMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //if (EagleEyeMapControl.Map.LayerCount > 0)
            //{
            //    // 按下鼠标左键,移动矩形框
            //    if (e.button == 1)
            //    {
            //        if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax)
            //        {
            //            CanDrag = true;
            //        }
            //        MoveRectPoint = new PointClass();
            //        // 记录点击的第一个点的坐标
            //        MoveRectPoint.PutCoords(e.mapX, e.mapY);
            //    }
            //    //按下鼠标右键绘制矩形框
            //    else if (e.button == 2)
            //    {
            //        IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle();

            //        IPoint pTempPoint = new PointClass();
            //        pTempPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2);
            //        MainMapControl.Extent = pEnvelope;
            //        //矩形框的高宽和数据试图的高宽不一定成正比,这里做一个中心调整
            //        MainMapControl.CenterAt(pTempPoint);
            //    }
            //}
            if (EagleEyeMapControl.Map.LayerCount > 0)
            {
                //按下鼠标左键移动矩形框
                if (e.button == 1)
                {
                    //如果指针落在鹰眼的矩形框中,标记可移动
                    if (e.mapX > pEnv.XMin && e.mapY > pEnv.YMin && e.mapX < pEnv.XMax && e.mapY < pEnv.YMax)
                    {
                        CanDrag = true;
                    }
                    MoveRectPoint = new PointClass();
                    MoveRectPoint.PutCoords(e.mapX, e.mapY);  //记录点击的第一个点的坐标
                }
                //按下鼠标右键绘制矩形框
                else if (e.button == 2)
                {
                    IEnvelope pEnvelope = EagleEyeMapControl.TrackRectangle();

                    IPoint pTempPoint = new PointClass();
                    pTempPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2);
                    MainMapControl.Extent = pEnvelope;
                    //矩形框的高宽和数据试图的高宽不一定成正比,这里做一个中心调整
                    MainMapControl.CenterAt(pTempPoint);
                }
            }
        }
Example #30
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            ////记录鼠标点击的点
            //IPoint pNewPoint = new PointClass();
            //pNewPoint.PutCoords(e.mapX, e.mapY);

            //if (mPointCollectionNet == null)
            //    mPointCollectionNet = new MultipointClass();
            ////添加点,before和after标记添加点的索引,这里不定义
            //object before = Type.Missing;
            //object after = Type.Missing;
            //mPointCollectionNet.AddPoint(pNewPoint, ref before, ref after);
        }
Example #31
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IEnvelope extent;

            if (e.button != 2)
            {
                if (this._mainMapControl != null)
                {
                    if (this.axMapControl1.LayerCount > 0)
                    {
                        IEnvelope xMin = this.axMapControl1.TrackRectangle();
                        if ((xMin.IsEmpty || xMin.Width == 0 ? false : xMin.Height != 0))
                        {
                            extent = this._mainMapControl.Extent;
                            double width = extent.Width / extent.Height;
                            if (xMin.Width <= xMin.Height * width)
                            {
                                xMin.XMax = xMin.XMin + xMin.Height * width;
                            }
                            else
                            {
                                xMin.YMin = xMin.YMax - xMin.Width / width;
                            }
                        }
                        else
                        {
                            extent    = this._mainMapControl.Extent;
                            xMin.XMin = e.mapX - (extent.XMax - extent.XMin) / 2;
                            xMin.XMax = e.mapX + (extent.XMax - extent.XMin) / 2;
                            xMin.YMin = e.mapY - (extent.YMax - extent.YMin) / 2;
                            xMin.YMax = e.mapY + (extent.YMax - extent.YMin) / 2;
                        }
                        if ((this._rectangleElement.Geometry != null ? true : !this._rectangleElement.Geometry.IsEmpty))
                        {
                            this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground,
                                                                         this._rectangleElement, this._envelope);
                        }
                        this._envelope = xMin;
                        this._rectangleElement.Geometry = xMin;
                        this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,
                                                                     this._rectangleElement, this._envelope);
                        this._canDo    = false;
                        Cursor.Current = Cursors.WaitCursor;
                        this._mainMapControl.Extent = xMin;
                        this._mainMapControl.ActiveView.Refresh();
                        Cursor.Current = Cursors.Default;
                        this._canDo    = true;
                    }
                }
            }
        }
Example #32
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (this.axMapControl1.Map.LayerCount != 0)

            {
                // 按下鼠标左键移动矩形框

                if (e.button == 1)

                {
                    IPoint pPoint = new PointClass();

                    pPoint.PutCoords(e.mapX, e.mapY);
                    IEnvelope pEnv = GetEnvelope(pPoint);
                    //IEnvelope pEnvelope = pAxMapCtrl.Extent;

                    //pEnvelope.CenterAt(pPoint);
                    pAxMapCtrl.Extent = pEnv;
                    //pAxMapCtrl.CenterAt(pPoint);// = pEnvelope;

                    pAxMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }

                // 按下鼠标右键绘制矩形框

                else if (e.button == 2)

                {
                    double    fAxMapCtrlRatio = pAxMapCtrl.Extent.Width / pAxMapCtrl.Extent.Height;
                    IEnvelope pEnvelop        = this.axMapControl1.TrackRectangle();//若画出的形状和主控件比例不一样则转化
                    double    fEnvRatio       = pEnvelop.Width / pEnvelop.Height;
                    double    midX            = pEnvelop.XMin + (pEnvelop.XMax - pEnvelop.XMin) / 2;
                    double    midY            = pEnvelop.YMin + (pEnvelop.YMax - pEnvelop.YMin) / 2;
                    IEnvelope realEnv         = new EnvelopeClass();
                    if (fEnvRatio > fAxMapCtrlRatio)
                    {
                        realEnv.PutCoords(midX - pEnvelop.Height * fAxMapCtrlRatio / 2, midY - pEnvelop.Height / 2,
                                          midX + pEnvelop.Height * fAxMapCtrlRatio / 2, midY + pEnvelop.Height / 2);
                    }
                    else
                    {
                        realEnv.PutCoords(midX - pEnvelop.Width / 2, midY - pEnvelop.Width / fAxMapCtrlRatio / 2,
                                          midX + pEnvelop.Width / 2, midY + pEnvelop.Width / fAxMapCtrlRatio / 2);
                    }
                    //realEnv.Project(pEnvelop.SpatialReference);
                    pAxMapCtrl.Extent = realEnv;

                    pAxMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
        }
Example #33
0
        //鹰眼地图:左键拖动矩形框、右键绘制矩形框
        private void axMapControlEagleMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (axMapControlEagleMap.Map.LayerCount == 0)
            {
                return;
            }
            //按下鼠标左键拖动矩形框
            if (e.button == 1)
            {
                IPoint point = new ESRI.ArcGIS.Geometry.Point();
                point.PutCoords(e.mapX, e.mapY);
                IEnvelope envelope = axMapControlMainMap.Extent;
                envelope.CenterAt(point);
                axMapControlMainMap.Extent = envelope;
                axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            //按下鼠标右键绘制矩形框
            else if (e.button == 2)
            {
                IEnvelope envelope = axMapControlEagleMap.TrackRectangle();

                //计算新显示框范围
                double newWidth  = 0;
                double newHeight = 0;
                if (envelope.IsEmpty)
                {
                    return;
                }
                if (envelope.Width / envelope.Height > axMapControlMainMap.ActiveView.Extent.Width / axMapControlMainMap.ActiveView.Extent.Height)
                {//宽相同
                    newWidth  = envelope.Width;
                    newHeight = envelope.Width * axMapControlMainMap.ActiveView.Extent.Height / axMapControlMainMap.ActiveView.Extent.Width;
                }
                else//高相同
                {
                    newHeight = envelope.Height;
                    newWidth  = envelope.Height * axMapControlMainMap.ActiveView.Extent.Width / axMapControlMainMap.ActiveView.Extent.Height;
                }

                double midX = (envelope.XMin + envelope.XMax) / 2;
                double midY = (envelope.YMin + envelope.YMax) / 2;
                double xmi  = midX - newWidth / 2;
                double xma  = midX + newWidth / 2;
                double ymi  = midY - newHeight / 2;
                double yma  = midY + newHeight / 2;
                envelope.PutCoords(xmi, ymi, xma, yma);

                axMapControlMainMap.Extent = envelope;
                axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
        }
Example #34
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     double xpoint = e.mapX;
     double ypoint = e.mapY;
     IPoint point = new PointClass();
     point.PutCoords(xpoint, ypoint);
     IWorkspaceFactory wsf = new FileGDBWorkspaceFactory();
     IFeatureWorkspace ws = wsf.OpenFromFile(@"\\alexn\TestGDB\Feature.gdb", 0) as IFeatureWorkspace;
     IGeoDataset pointfc = ws.OpenFeatureClass(@"Points") as IGeoDataset;
     point.SpatialReference = pointfc.SpatialReference;
     //IGeometry point2 = point as IGeometry;
     IFeatureClass pointfc2 = pointfc as IFeatureClass;
     IFeature pointfc3 = pointfc2.CreateFeature();
     IFeatureCursor pointFC = pointfc2.Insert(true);
     IFeatureBuffer fbuffer = pointfc2.CreateFeatureBuffer();
     fbuffer.Shape = point;
     pointFC.InsertFeature(fbuffer);
     IActiveView display = axMapControl1.ActiveView;
     display.Activate(0);
     display.Refresh();
 }
Example #35
0
        private void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            switch (e.button)
            {
                case 1:
                    #region 左键按下,进入点选激活功能模式
                    IMap pMap = mapControl.Map;
                    pMap.ClearSelection();
                    IActiveView pActiveView = pMap as IActiveView;
                    IGeometry pGeometry = mapControl.TrackCircle();
                    ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();
                    pSelectionEnv.DefaultColor = GetRGBColor(0, 255, 0);
                    pMap.SelectByShape(pGeometry, pSelectionEnv, false);

                    //获取高亮选择集要素
                    ISelection selection = pMap.FeatureSelection;
                    IEnumFeatureSetup enumFeatureSetup = selection as IEnumFeatureSetup;
                    enumFeatureSetup.AllFields = true;
                    IEnumFeature enumFeature = enumFeatureSetup as IEnumFeature;
                    enumFeature.Reset();
                    IFeature feature = enumFeature.Next();
                    while (feature != null)
                    {
                        TextBlockTitle.Text = feature.get_Value(feature.Fields.FindField("Name")).ToString();//可以得到任意字段的值
                        TextBlockDiscription.Text = feature.get_Value(feature.Fields.FindField("Description")).ToString();
                        feature = enumFeature.Next();
                    }
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
                    //axMapControlContent.Refresh();
                    #endregion
                    break;
                case 2:
                    break;
                case 4://中键,pan()
                    mapControl.Pan();
                    break;
                default:
                    break;
            }
        }
Example #36
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IEnvelope objEnvelope = null;

            IPoint pPoint = null;
            IActiveView pActiveView = axMapControl1.ActiveView.FocusMap as IActiveView;
            pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            frmPointQuery frmPointQuery1 = new frmPointQuery();
            switch (m_BasicOperationTool)
            {
                case "isZoomIn":
                    objEnvelope = axMapControl1.TrackRectangle();
                    axMapControl1.Extent = objEnvelope;
                    break;
                case "isZoomOut":
                    objEnvelope = axMapControl1.TrackRectangle();
                    double mapWidth = objEnvelope.Width;
                    double mapHeight = objEnvelope.Height;
                    double x1 = pPoint.X;
                    double x2 = pPoint.X + mapWidth;
                    double y1 = pPoint.Y;
                    double y2 = pPoint.Y - mapHeight * 2;
                    objEnvelope.XMax = x2 + mapWidth * 2;
                    objEnvelope.XMin = x1 - mapWidth * 2;
                    objEnvelope.YMax = y2 - mapHeight * 2;
                    objEnvelope.YMin = y1 + mapHeight * 2;
                    axMapControl1.Extent = objEnvelope;
                    break;
                case "isZoomPan":
                    axMapControl1.Pan();
                    break;
                case "isQuery":
                    IDisplayTransformation pDT = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation;
                    pPoint = pDT.ToMapPoint(e.x, e.y);

                    frmPointQuery1.userControl11.SetQueryFeature(axMapControl1.Map, pPoint);
                    frmPointQuery1.ShowDialog();
                    break;
                case "isMeasure":
                    m_bInUse = true;
                    m_pStartPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); ;
                    break;
                case "isSelRectangle":
                    objEnvelope = axMapControl1.TrackRectangle();
                    frmPointQuery1.userControl11.SetQueryFeatureByRect(axMapControl1.Map, objEnvelope);
                    frmPointQuery1.ShowDialog();
                    break;
                case "isSelLine":
                    objEnvelope = axMapControl1.TrackLine().Envelope;
                    frmPointQuery1.userControl11.SetQueryFeatureByRect(axMapControl1.Map, objEnvelope);
                    frmPointQuery1.ShowDialog();
                    break;
                case "isSelEcllipse":
                    objEnvelope = axMapControl1.TrackCircle().Envelope;
                    frmPointQuery1.userControl11.SetQueryFeatureByRect(axMapControl1.Map, objEnvelope);
                    frmPointQuery1.ShowDialog();
                    break;
                case "isSelPolygon":
                    objEnvelope = axMapControl1.TrackPolygon().Envelope;
                    frmPointQuery1.userControl11.SetQueryFeatureByRect(axMapControl1.Map, objEnvelope);
                    frmPointQuery1.ShowDialog();
                    break;
                case "AddNetworkPoint":
                    break;
                case "isFindWaterValve":
                    BurstSetEdgeFlag(pPoint);
                    break;
                case "isUpstreamTrace":
                    Utility.UpStreamTrace(this, pPoint, pGeoNetwork);
                    break;
                case "isProfileAnalysis":

                    Utility.ProfileSetJunctionFlag(this, ref pNetFlagArray, pPoint, pGeoNetwork);
                    break;
                case "isSewerTvSurvey":

                    break;

            }
        }
Example #37
0
        private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                IElement element = m_AOI as IElement;
                IEnvelope envelope = element.Geometry.Envelope as IEnvelope;

                if (HitTest(envelope, e.mapX, e.mapY))
                {
                    IFillShapeElement fillSymbol = m_AOI as IFillShapeElement;

                    fillSymbol.Symbol = m_pSelectedSymbol;

                    IPoint point = new PointClass();
                    point.PutCoords(e.mapX, e.mapY);
                    envelope.CenterAt(point);

                    m_AOI.Geometry = envelope;

                    UpdateUI();
                }
            }
        }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
         //Popup the menu
         m_navigationMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
 }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         m_toolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
     }
        
 }      
Example #40
0
 private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
 }
Example #41
0
 private void UCMap_MouseDown(object sender,IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button==2)
         Pan();
 }
Example #42
0
        private void mainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                if (this.mapRightClickPoint == null)
                {
                    this.mapRightClickPoint = new PointClass();
                }
                this.mapRightClickPoint.PutCoords(e.mapX, e.mapY);
                IGraphicsContainer pGraphicContainer = this.mainMapControl.Map as IGraphicsContainer;
                IEnumElement pEnumElement = pGraphicContainer.LocateElements(this.mapRightClickPoint, this.mainMapControl.ActiveView.Extent.Width / 500);
                if (pEnumElement != null)
                {
                    return;
                }
                else
                {
                    this.contextMenuMapNormal.Show(this.mainMapControl as Control, new System.Drawing.Point(e.x, e.y));
                }
            }
            else if (e.button == 1)
            {
                if (this.btnDrawNewText.Checked == false) return;

                if (this.mapTextPoint == null)
                {
                    this.mapTextPoint = new PointClass();
                }
                this.mapTextPoint.PutCoords(e.mapX, e.mapY);
                this.txtNewText.Location = new System.Drawing.Point(e.x, e.y);
                this.txtNewText.Text = "文本";
                this.txtNewText.Visible = true;
                this.txtNewText.Focus();
                this.txtNewText.SelectAll();
                this.btnDrawNewText.Checked = false;
            }
        }
Example #43
0
 private void mapControlMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (programStepUserControl != null)
         programStepUserControl.mapControlMouseDown(sender, e);
 }
 //axMapControl2鼠标响应,左键移动矩形框,右键绘制矩形框
 private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (this.axMapControl2.Map.LayerCount != 0)
     {
         // 按下鼠标左键移动矩形框 
         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); 
         }
     }
 }
        public static string GetXMQMC(AxMapControl _mapControl, IMapControlEvents2_OnMouseDownEvent e)
        {
            string xzqmc = "";
            try
            {

                if (_mapControl.Map.LayerCount == 0)
                {
                    return xzqmc;
                }
                IIdentify pIdentify = _mapControl.Map.get_Layer(0) as IIdentify; //通过图层获取 IIdentify 实例
                IPoint pPoint = new ESRI.ArcGIS.Geometry.Point(); //新建点来选择
                IArray pIDArray;
                IIdentifyObj pIdObj;
                pPoint.PutCoords(e.mapX, e.mapY);      //定义点
                int delta = 500;
                IEnvelope envelope = new EnvelopeClass();
                envelope.XMin = e.mapX - delta;
                envelope.XMax = e.mapX + delta;
                envelope.YMin = e.mapY - delta;
                envelope.YMax = e.mapY + delta;
                IGeometry geo = envelope as IGeometry;
                IZAware zAware = geo as IZAware;
                zAware.ZAware = true;

                pIDArray = pIdentify.Identify(geo);       //通过点获取数组,用点一般只能选择一个元素
                if (pIDArray != null)
                {
                    //取得要素
                    pIdObj = pIDArray.get_Element(0) as IIdentifyObj;       //取得要素
                    pIdObj.Flash(_mapControl.ActiveView.ScreenDisplay);     //闪烁效果
                    IRowIdentifyObject rowIdentify = pIdObj as IRowIdentifyObject;
                    IFeature feature = rowIdentify.Row as IFeature;
                    if (feature != null)
                    {
                        IFields fields = feature.Fields;
                        int xmqmcFieldIndex = fields.FindField("XZQMC");
                        xzqmc = Convert.ToString(feature.get_Value(xmqmcFieldIndex));
                    }
                }
                else
                {
                    //MessageBox.Show("Nothing!");
                }
            }
            catch
            {
            }
            return xzqmc;
        }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (findpath.Checked)
     {
         IPoint ipNew;
         if (ippoints == null)
             ippoints = new MultipointClass();
         ipNew = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
         object o = Type.Missing;
         ippoints.AddPoint(ipNew, ref o, ref o);
         cls.StopPoints = ippoints;
         drawpoints(ippoints);
     }
     if (findpath2.Checked)
     {
         IPoint ipNew;
         if (ippoints == null)
             ippoints = new MultipointClass();
         ipNew = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
         object o = Type.Missing;
         ippoints.AddPoint(ipNew, ref o, ref o);
         cls.StopPoints = ippoints;
         drawpoints(ippoints);
     }
     if (distanceprocess.Checked)
     {
         IPoint ipNew;
         if (ippoints == null)
             ippoints = new MultipointClass();
         ipNew = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
         object o = Type.Missing;
         ippoints.AddPoint(ipNew, ref o, ref o);
         createpolyline(ippoints);
         if (ipPolyResult != null)
             drawpathline(ipPolyResult);
         drawpoints(ippoints);
     }
     if (areaprocess.Checked)
     {
         IGraphicsContainer pgraghicscontainer = axMapControl1.Map as IGraphicsContainer;
         IActiveView pactiveview = pgraghicscontainer as ESRI.ArcGIS.Carto.IActiveView;
         IPoint ipNew;
         if (ippoints == null)
             ippoints = new MultipointClass();
         ipNew = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
         object o = Type.Missing;
         ippoints.AddPoint(ipNew, ref o, ref o);
         createpolyline(ippoints);
         if (ipPolyResult != null)
         {
             drawpathline(ipPolyResult);
         }
         drawpoints(ippoints);
     }
     if (identify.Checked)
     {
         int m_px = e.x;
         int m_py = e.y;
         selectfeature(m_px, m_py);
     }
     if (select.Checked)
     {
         int m_px = e.x;
         int m_py = e.y;
         selectfeature(m_px, m_py);
     }
 }
Example #47
0
        //地图点击事件,获取点击区域的X Y 单位:米
        private void axMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            label1.Text = "X: " + e.mapX + "    Y:" + e.mapY+"  米";
            Demo01 frm = null;
            if (frm == null || frm.IsDisposed)
                frm = new Demo01();

            frm.Show();
            frm.TopMost = true;
        }
        public void onMapControlMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e, InnerRoad innerRoad)
        {
            IPolyline innerRoadPolyline = mapControl.TrackLine() as IPolyline;
            //这里是不是要对画好的线做一下检查, 比如保证内部路穿过了小区区域.

            ILineElement innerRoadLineElement = new LineElementClass();
            IElement element = innerRoadLineElement as IElement;
            element.Geometry = innerRoadPolyline;
            innerRoad.lineElement = innerRoadLineElement;
            innerRoad.updatePath();
            GisUtil.DrawPolylineElement(innerRoadLineElement, mapControl);
            mainWindow.unmask();
        }
 private bool onMapControlMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     bool handled = false;
     if (SelectMainRoadUserControl.mapControlMouseDown != null)
     {
         handled = SelectMainRoadUserControl.mapControlMouseDown(sender, e);
         if (handled)
             return true;
     }
     if (SelectVillageUserControl.mapControlMouseDown != null)
     {
         handled = SelectVillageUserControl.mapControlMouseDown(sender, e);
         if (handled)
             return true;
     }
     return false;
 }
Example #50
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && insertbiaozhu)
            {
                agp.CreateTextElment(axMapControl1, e.mapX, e.mapY, "测试");
            }
            if (e.button == 1 && insertpoint)
            {
                IFeatureLayer oFeatureLayer = axMapControl1.get_Layer(axMapControl1.LayerCount - 1) as IFeatureLayer;
                agp.AddPointByStore(axMapControl1, oFeatureLayer, e.mapX, e.mapY);
            }

            if (e.button == 1 && insertline)
            {
                IFeatureLayer oFeatureLayer = axMapControl1.get_Layer(axMapControl1.LayerCount - 1) as IFeatureLayer;
                agp.AddLineByWrite(this.axMapControl1 ,oFeatureLayer, e.mapX, e.mapY);
            }

            if (e.button == 1 && insertPolygon)
            {
                IFeatureLayer oFeatureLayer = axMapControl1.get_Layer(axMapControl1.LayerCount - 1) as IFeatureLayer;
                agp.AddPolygonByWrite(this.axMapControl1, oFeatureLayer, e.mapX, e.mapY);
            }

            if (e.button == 1 && search)//如果是查询状态并且是左键点击 
            {

                if (identifyDialog.IsDisposed)
                {
                    ShowIdentifyDialog();
                }
                identifyDialog.OnMouseDown(e.button, e.mapX, e.mapY);
                //IMap pMap;
                //int i;
                //IPoint pPoint;
                //pMap = axMapControl1.Map;
                //pPoint = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

                //IEnvelope pEnv;
                //pEnv = axMapControl1.ActiveView.Extent;
                //pEnv.Height = 1;
                //pEnv.Width = 1;
                //pEnv.CenterAt(pPoint);

                ////执行查询获取符号条件的要素
                //List<IFeature> pFList = agp.GetSeartchFeatures(axMapControl1.get_Layer(0) as IFeatureLayer, pEnv);
                //if (pFList.Count > 0)
                //{
                //    //消息显示查询目标的信息
                //    SearchViewInfo frm = null;
                //    if (frm == null || frm.IsDisposed)
                //        frm = new SearchViewInfo(pFList[0]);

                //    frm.Show();
                //    frm.TopMost = true;
                //}
                //else

                //{
                //    MessageBox.Show ("没有找到任何节点!");
                //}
            }

            if (e.button == 2 && !bSearch)//如果是右键并且不是查询状态
            {

                if (axMapControl1.DocumentFilename != "")
                {
                    m_ToolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
                }
            }

            //if (bSearch && e.button == 1)//如果是查询状态并且是左键点击 
            //{
            //    //设置鼠标样式为十字丝
            //    this.axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            //    //获取画定范围的Geometry
            //    IGeometry pGeometry = this.axMapControl1.TrackPolygon();
            //    //添加半透名临时图形
            //    agp.AddTransTempEle(this.axMapControl1, pGeometry, true);



            //    //for (int a = 0; a < axMapControl1.LayerCount; a++)
            //    //{


            //    IFeatureLayer pFeatureLayer = this.axMapControl1.get_Layer(1) as IFeatureLayer;

            //    attribute pAttribute = new attribute(pFeatureLayer);
            //    //执行查询获取符号条件的要素
            //    List<IFeature> pFList = agp.GetSeartchFeatures(pFeatureLayer, pGeometry);
            //    //设置信息显示窗体中DataGridView的属性
            //    //设置行数pFList.Count+1包括字段名哪一行即表头
            //    pAttribute.dataGridView1.RowCount = pFList.Count + 1;
            //    //设置边界风格
            //    pAttribute.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken;
            //    //设置列数
            //    pAttribute.dataGridView1.ColumnCount = pFList[0].Fields.FieldCount;
            //    //遍历第一个要素的字段用于给列头赋值(字段的名称)
            //    for (int m = 0; m < pFList[0].Fields.FieldCount; m++)
            //    {
            //        pAttribute.dataGridView1.Columns[m].HeaderText = pFList[0].Fields.get_Field(m).AliasName;
            //    }
            //    //遍历要素
            //    for (int i = 0; i < pFList.Count; i++)
            //    {
            //        IFeature pFeature = pFList[i];
            //        for (int j = 0; j < pFeature.Fields.FieldCount; j++)
            //        {
            //            //填充字段值
            //            pAttribute.dataGridView1[j, i].Value = pFeature.get_Value(j).ToString();
            //        }
            //    }

            //    pAttribute.Show();
            //    //}
            //}
        }
Example #51
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            #region  主窗体右键
            /////地图视窗鼠标事件
            IToolbarMenu mapPopMenu = null;
            mapPopMenu = new ToolbarMenu();
            if (e.button == 2)
            {
                /* IMap pMap = axMapControl1.Map;
                 IActiveView pActiveView = pMap as IActiveView;
                 IEnvelope pEnv = axMapControl1.TrackRectangle();
                 pActiveView.Extent = pEnv;
                 pActiveView.Refresh();*/

                //地图视窗右键菜单功能

                mapPopMenu.AddItem(new ControlsSelectTool(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapPanTool(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapFullExtentCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapIdentifyTool(), -1, 3, false, esriCommandStyles.esriCommandStyleIconAndText);//识别工具
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 4, false, esriCommandStyles.esriCommandStyleIconAndText);//
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 5, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsSelectFeaturesTool(), -1, 6, false, esriCommandStyles.esriCommandStyleIconAndText);//选择要素工具
                mapPopMenu.AddItem(new ControlsClearSelectionCommand(), -1, 7, false, esriCommandStyles.esriCommandStyleIconAndText);//缩放所选要素
                mapPopMenu.AddItem(new ControlsZoomToSelectedCommand(), -1, 8, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentBackCommand(), -1, 9, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentForwardCommand(), -1, 10, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.SetHook(axMapControl1);//// 得到地图视窗右键菜单
                mapPopMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);//弹出显示菜单
            }
            /*  if (e.button == 1)//左键因为右键要取消
              {
                  IMap pMap = axMapControl1.Map;
                   IActiveView pActiveView = pMap as IActiveView;
                   IEnvelope pEnv = axMapControl1.TrackRectangle();
                   pActiveView.Extent = pEnv;
                   pActiveView.Refresh();
              }
             * */
            //此事件不会触发
            if (e.button == 3)//如果鼠标中间改为ControlsMapPanTool会更好
            {
                IMap pMap = axMapControl1.Map;
                IActiveView pActiveView = pMap as IActiveView;
                IEnvelope pEnv = axMapControl1.TrackRectangle();
                pActiveView.Extent = pEnv;
                pActiveView.Refresh();
            }
            #endregion

            //if (e.button == 2)
            //{
            //    IMap pMap = axMapControl1.Map;
            //    IActiveView pActiveView = pMap as IActiveView;
            //    IEnvelope pEnv = axMapControl1.TrackRectangle();
            //    pActiveView.Extent = pEnv;
            //    pActiveView.Refresh();
            //}
            //网络分析
            if (clicked != true)
                return;
            IPoint ipNew;
            if (m_ipPoints == null)
            {
                m_ipPoints = new MultipointClass();
            }
            ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            object o = Type.Missing;
            m_ipPoints.AddPoint(ipNew, ref o, ref o);

            IElement element;
            ITextElement textelement = new TextElementClass();
            element = textelement as IElement;
            clickedcount++;
            textelement.Text = clickedcount.ToString();
            element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            pGC.AddElement(element, 0);
            m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Example #52
0
 private void mapControl_OP_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1 && m_currentButton > 0)
     {
         //弹出右键菜单
         //DataEditCommon.contextMenu.PopupMenu(e.x, e.y, this.mapControl_OP.hWnd);
         var pt = mapControl_OP.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
         pt = SnapSetting.getSnapPoint(pt);
         switch (m_currentButton)
         {
             case 1:
                 var gasPressureInfoEnteringForm = new GasPressureInfoEntering { GasPressurePoint = pt };
                 gasPressureInfoEnteringForm.ShowDialog(); //绘制瓦斯压力点
                 m_currentButton = 0; //解除当前按钮
                 break;
             case 2:
                 var gasContentInfoEnteringForm = new GasContentInfoEntering { GasContentPoint = pt };
                 gasContentInfoEnteringForm.ShowDialog(); //绘制瓦斯含量点
                 m_currentButton = 0; //解除当前按钮
                 break;
             case 3:
                 var gasGushQuantityInfoEnteringForm = new GasGushQuantityInfoEntering
                 {
                     GasGushQuantityPoint = pt
                 };
                 gasGushQuantityInfoEnteringForm.ShowDialog(); //绘制瓦斯涌出量点
                 m_currentButton = 0; //解除当前按钮
                 break;
         }
     }
 }
Example #53
0
 void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     IMap map = m_MapControl.Map;
     System.Drawing.Point pnt=new System.Drawing.Point(e.x,e.y);
     MapSelectionHelperClass.SelectFeatureByPoint(map, pnt, 10);
     ((IActiveView)map).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
 }
 private void axMapControl2_OnMouseDown(object sender, 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();
             axMapControl2.Extent = penv;
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
Example #55
0
        private void axMapControl1_OnMouseDown_1(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            //IMap pMap = axMapControl1.Map;
            //IGeometry pGeometry = axMapControl1.TrackRectangle();       //获取框选几何
            //ISelectionEnvironment pSelectionEnv = new SelectionEnvironment(); //新建选择环境
            //IRgbColor pColor = new RgbColor();
            //pColor.Red = 255;
            //pSelectionEnv.DefaultColor = pColor;         //设置高亮显示的颜色!

            //pMap.SelectByShape(pGeometry, pSelectionEnv, false); //选择图形!
            //axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Example #56
0
        ////////////protected override void OnNotifyMessage(System.Windows.Forms.Message m)
        ////////////{
        ////////////    /*This method of suppressing resize drawing works by examining the windows messages 
        ////////////    sent to the form. When a form starts resizing, windows sends the WM_ENTERSIZEMOVE 
        ////////////    Windows(messge). At this point we suppress drawing to the MapControl and 
        ////////////    PageLayoutControl and draw using a "stretchy bitmap". When windows sends the 
        ////////////    WM_EXITSIZEMOVE the form is released from resizing and we resume with a full 
        ////////////    redraw at the new extent.
        ////////////    Note in DotNet forms we can not simply use the second parameter in a Form_Load 
        ////////////    event to automatically detect when a form is resized as follows:
        ////////////    AxPageLayoutControl1.SuppressResizeDrawing(False, Me.Handle.ToInt32)
        ////////////    This results in a System.NullException when the form closes (after layers have been 
        ////////////    loaded). This is a limitation caused by .Net's particular implementation of its 
        ////////////    windows message pump which conflicts with "windows subclassing" used to watch the
        ////////////    forms window.*/
        ////////////    base.OnNotifyMessage (m);
        ////////////    if (m.Msg == WM_ENTERSIZEMOVE)
        ////////////    {
        ////////////        axMapControl1.SuppressResizeDrawing(true, 0);
        ////////////    }
        ////////////    else if (m.Msg == WM_EXITSIZEMOVE)
        ////////////    {
        ////////////        axMapControl1.SuppressResizeDrawing(false, 0);
        ////////////    }
        ////////////}
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //On Error GoTo ErrorHandler

            if (MDIApplication.ParentForm.pyBtn == 1)
            {
                if (this.axMapControl1.ActiveView.FocusMap.SelectionCount >= 1)
                {
                    //////////IGeometry pGeometry ;
                    //////////IPoint pPoint ;
                    //////////IEnvelope pEnvelope ;
                    m_pScreenDisplay = this.axMapControl1.ActiveView.ScreenDisplay;
                    //'目前对第一层的要素
                    pMap = this.axMapControl1.ActiveView.FocusMap;
                    pSR = pMap.SpatialReference;
                    // '当前参考系为图层坐标系统WGS84
                    //'Dim name As String
                    //'name = pSR.name
                    //'MsgBox "name is" & name

                    if (this.axMapControl1.ActiveView.FocusMap.LayerCount == 0)
                    {
                        MessageBox.Show("当前工程没有可操作图层");
                        return;
                    }

                    //'得到鼠标点击的起点坐标
                    pPoint = m_pScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                    X_First = pPoint.X;
                    Y_First = pPoint.Y;

                    IEnumFeature pEnumFeat = (IEnumFeature)this.axMapControl1.ActiveView.FocusMap.FeatureSelection;
                    pEnumFeat.Reset();
                    if (pEnumFeat == null)
                    {
                        return;
                    }
                    m_pFeature = pEnumFeat.Next();
                    IPolygon polygon = (IPolygon)m_pFeature.Shape;
                    //'Feature类型为Polygon
                    m_pDisplayFeedback = new MovePolygonFeedback();
                    m_pDisplayFeedback.Display = m_pScreenDisplay;

                    IMovePolygonFeedback pMovePolygonF = (IMovePolygonFeedback)m_pDisplayFeedback;

                    //pMovePolygonF.Start( m_pFeature.Shape, pPoint);

                    pMovePolygonF.Start(polygon, pPoint);

                    this.axMapControl1.ActiveView.Refresh();

                    //    '设置鼠标外观,鼠标形状作为判断标志

                    //    'Dim m_pMouseCursor As esriFramework.MouseCursor
                    //    'Set m_pMouseCursor = New MouseCursor
                    //    'm_pMouseCursor.SetCursor 5
                    //'ErrorHandler:
                    //    'MsgBox Err.Description
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
Example #57
0
        private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1)//左键画红框
            {
                pEn = axMapControl2.TrackRectangle();
                axMapControl1.Extent = pEn;
                axMapControl2.DrawShape(pEn, ref oFillobject);
            }
            if (e.button == 2)//右键拖动红框
            {
                pSmallViewerMouseDownPt = new PointClass();
                pSmallViewerMouseDownPt.PutCoords(e.mapX, e.mapY);
                axMapControl1.CenterAt(pSmallViewerMouseDownPt);

                isTrackingSmallViewer = true;
                if (pSmallViewerEnvelope == null)
                {
                    pSmallViewerEnvelope = new MoveEnvelopeFeedbackClass();
                    pSmallViewerEnvelope.Display = axMapControl2.ActiveView.ScreenDisplay;
                    pSmallViewerEnvelope.Symbol = (ISymbol)oFillobject;
                }
                pSmallViewerEnvelope.Start(pEn, pSmallViewerMouseDownPt);
            }
        }
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1)
     {
         string xzqmc = clsGISHandler.GetXMQMC(this.axMapControl1, e);
         if(xzqmc!=""){
             GetFeatureInfo(xzqmc);
         }
     }
     else if (e.button == 4)
     {
         axMapControl1.ActiveView.ScreenDisplay.PanStart(axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y));
         axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPan;
     }
 }
Example #59
0
        private void nw_query(IMapControlEvents2_OnMouseDownEvent e)
        {
            //axMapControl1
            ILayer layer = m_datasource.GetAdministrativeMap().get_Layer(m_query_area_detail);
            ILayer layer_shiyi =null;// = axMapControl1.Map.get_Layer (m_selectedLayer);
            ILayer layer_cishi = null;//= axMapControl1.Map.get_Layer(m_selectedLayer);
            getLayer(m_query_area_detail, ref layer_shiyi, ref layer_cishi);
            //resolveNameRate(layer.Name);
            //resolveNameRange(layer.Name);

            //layer_name[1];
            //
            axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;

            ESRI.ArcGIS.Geometry.IGeometry geometry = null;
            ESRI.ArcGIS.Geometry.Point pt = new ESRI.ArcGIS.Geometry.Point();
            pt.X = e.mapX;
            pt.Y = e.mapY;
            geometry = pt as ESRI.ArcGIS.Geometry.IGeometry;
               // geometry = axMapControl1.TrackRectangle();

            ISpatialFilter pSpatialFilter = new SpatialFilterClass();
            IQueryFilter pQueryFilter = pSpatialFilter as ISpatialFilter;
            //设置过滤器的Geometry
            pSpatialFilter.Geometry = geometry;
            //设置空间关系类型
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//esriSpatialRelContains;

            //获取FeatureCursor游标
            IFeatureLayer featureLayer = layer as IFeatureLayer;
            //获取featureLayer的featureClass
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = featureClass.Search(pQueryFilter, true);
            //遍历FeatureCursor
            IFeature pFeature = pFeatureCursor.NextFeature();

            //获取FeatureCursor游标
            IFeatureLayer featureLayer1 = layer_shiyi as IFeatureLayer;
            //获取featureLayer的featureClass
            IFeatureClass featureClass1 = featureLayer1.FeatureClass;
            IFeatureCursor pFeatureCursor1 = featureClass1.Search(pQueryFilter, true);
            //遍历FeatureCursor
            IFeature pFeature1 = pFeatureCursor1.NextFeature();

            //获取FeatureCursor游标
            IFeatureLayer featureLayer2 = layer_cishi as IFeatureLayer;
            //获取featureLayer的featureClass
            IFeatureClass featureClass2 = featureLayer2.FeatureClass;
            IFeatureCursor pFeatureCursor2 = featureClass2.Search(pQueryFilter, true);
            //遍历FeatureCursor
            IFeature pFeature2 = pFeatureCursor2.NextFeature();

            //QueryForm qf =new QueryForm(m_bin_path);
            m_qf.m_mapControl = axMapControl1;
            m_qf.m_featureLayer = featureLayer;
            m_qf.m_query_name = m_range_en;
            m_qf.m_mucao = m_mucao;
            m_qf.QueryForm_SetText( m_mucao);
            //qf.m_layername = "当前图层:" + layer.Name;

            System.Windows.Forms.ListView listView_data = m_qf.nw_getListView();
            listView_data.Items.Clear();
            m_qf.m_range = m_range;

            listView_data.Columns.Clear();
            listView_data.Columns.Add(m_range + "名", 120, HorizontalAlignment.Left);//省名,,
            listView_data.Columns.Add("适宜面积比", 120, HorizontalAlignment.Left);
            listView_data.Columns.Add("适宜面积", 120, HorizontalAlignment.Left);
            listView_data.Columns.Add("次适宜面积比", 120, HorizontalAlignment.Left);
            listView_data.Columns.Add("次适宜面积", 120, HorizontalAlignment.Left);

            string area1 = "area" + m_rate_en;
            string rate1 = "rate" + m_rate_en;
            string area2 = "area" + m_rate_en;
            string rate2 = "rate" + m_rate_en;
            if(pFeature1 != null)
            {
                for (int i = 0; i < pFeature1.Fields.FieldCount;++i )
                {
                    if (pFeature1.Fields.Field[i].Name.IndexOf("area_") > -1)
                    {
                        area1 = pFeature1.Fields.Field[i].Name;
                    }
                    else if(pFeature1.Fields.Field[i].Name.IndexOf("rate_")>-1)
                    {
                        rate1 =  pFeature1.Fields.Field[i].Name;
                    }

                }
            }
            if (pFeature2 != null)
            {
                for (int i = 0; i < pFeature2.Fields.FieldCount; ++i)
                {
                    if (pFeature2.Fields.Field[i].Name.IndexOf("area_") > -1)
                    {
                        area2 = pFeature2.Fields.Field[i].Name;
                    }
                    else if (pFeature2.Fields.Field[i].Name.IndexOf("rate_") > -1)
                    {
                        rate2 = pFeature2.Fields.Field[i].Name;
                    }

                }
            }
            System.Collections.Generic.List<IFeature> pList = new System.Collections.Generic.List<IFeature>();

            while(pFeature != null)
            {

                // ESRI.ArcGIS.Geodatabase.IField filed = pFeature.Fields.FindField("rate_shiyi");
                //ESRI.ArcGIS.Geodatabase.IRowBuffer buff = (IRowBuffer)pFeature;
                //string str = buff.Value[pFeature.Fields.FindField("NAME")].ToString();
                //ESRI.ArcGIS.Geodatabase.IRow row = pFeature.Table.GetRow(pFeature.OID);
                //string str = row.Value[].ToString();
                //double a = System.Convert.ToDouble(row.get_Value(pFeature.Fields.FindField(nw_getQueryFiledName())));
                //pList.Add()
                //pList.Add(pFeature.);

                ListViewItem lvi = new ListViewItem();
               // ESRI.ArcGIS.Geodatabase.IRowBuffer buff = (IRowBuffer)pFeature;
               m_nactcn= lvi.Text = pFeature.Value[pFeature.Fields.FindField(m_range_en)].ToString();
                if (pFeature1!= null)
                {
                    lvi.SubItems.Add(pFeature1.Value[pFeature1.Fields.FindField(rate1)].ToString());//rate_shiyi
                    lvi.SubItems.Add(System.Convert.ToDecimal(pFeature1.Value[pFeature1.Fields.FindField(area1)]).ToString("N"));//
                }

                if (pFeature2 != null)
                {
                    lvi.SubItems.Add(pFeature2.Value[pFeature2.Fields.FindField(rate2)].ToString());//rate_shiyi
                    lvi.SubItems.Add(System.Convert.ToDecimal(pFeature2.Value[pFeature2.Fields.FindField(area2)]).ToString("N"));//
                }
                bool isNotAllNull = false;
                for (int i=1;i<lvi.SubItems.Count;++i)
                {
                    if(lvi.SubItems[i].Text.Trim() != "")
                    {
                        //MessageBox.Show(lvi.SubItems[i].Text.Trim());
                        isNotAllNull = true;
                        break;
                    }
                }

                if(isNotAllNull)
                    listView_data.Items.Add(lvi);

               pFeature = pFeatureCursor.NextFeature();
                if(pFeature1 != null)
                pFeature1 = pFeatureCursor1.NextFeature();
                if (pFeature2 != null)
                pFeature2 = pFeatureCursor2.NextFeature();

            }
            if (listView_data.Items.Count == 0)
            {
                MessageBox.Show("暂无数据!");
                return;
            }
            axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerDefault;
            m_qf.Show();
            highLight(featureLayer);
               /*  if (pFeature != null)
            {
                axMapControl1.Map.SelectFeature(axMapControl1.get_Layer(0), pFeature);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            axMapControl1.Map.SelectByShape(geometry, null, false);
             axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);*/
        }
Example #60
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //make sure that the user right clicked
            if (m_isQuery && 1 == e.button)
            {
               // m_isQuery = false;//��ʱ��������

                nw_query(e);
                return;
            }
            if (2 != e.button)
                return;
            m_isQuery = false;
            m_mapControlContextMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
        }