Пример #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            IGeometry pGeometry = AOUtil.GetSelectGeometry(m_axMapControl);

            if (pGeometry == null)
            {
                return;
            }

            double bufferDis = Convert.ToDouble(txtBuffer.Text);

            ITopologicalOperator pTopologicalOperator = pGeometry as ITopologicalOperator;
            IGeometry            pBufferGeometry      = pTopologicalOperator.Buffer(bufferDis);

            m_axMapControl.DrawShape(pBufferGeometry);
        }
Пример #2
0
        private void axMapControlMainMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            int statusFlag = CommonLib.MapMouseFlag;

            if (statusFlag <= 1)
            {
                return;
            }

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

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

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

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

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

                default:
                    CommonLib.MapGeometry = null;
                    break;
                }

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

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

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

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

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

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

            //#endregion
            #endregion
        }