现在的位置: 首页 > 综合 > 正文

arcengine 跨屏幕画多边并计算面积

2013年02月16日 ⁄ 综合 ⁄ 共 1726字 ⁄ 字号 评论关闭

 

  //Color函数
        private IRgbColor GetRGBColor(int red, int green, int blue)
        {
            IRgbColor rgb = new RgbColorClass();
            rgb.Red = red;
            rgb.Green = green;
            rgb.Blue = blue;
            return rgb;
        }

        private IPolygon DrawPolygon()
        {
            IActiveView pActiveView;
            ISimpleFillSymbol pSimpleFillSymbol;

            IRubberBand pRubberBand;
            IPolygon pPolygon;

            pActiveView = (IActiveView)axMapControl1.Map;
            pSimpleFillSymbol = new SimpleFillSymbolClass();
            pSimpleFillSymbol.Color = GetRGBColor(255, 22, 11);
            pRubberBand = new RubberPolygonClass();
            //pPolygon =pRubberBand .TrackNew (pActiveView .ScreenDisplay ,(ISymbol )pSimpleFillSymbol );
            pPolygon = (IPolygon)pRubberBand.TrackNew(pActiveView.ScreenDisplay, (ISymbol)pSimpleFillSymbol);
            pActiveView.ScreenDisplay.StartDrawing(pActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            pActiveView.ScreenDisplay.SetSymbol((ISymbol)pSimpleFillSymbol);
            pActiveView.ScreenDisplay.DrawPolygon((IGeometry)pPolygon);
            pActiveView.ScreenDisplay.FinishDrawing();
            return pPolygon;
        }

        private Double MeasurePolygon(IPolygon pPolygon)
        {
            IArea pArea = (IArea)pPolygon;
            Double dArea = Math.Abs(pArea.Area);
            return dArea;
        }

       
      

        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //if (boolAreaMeasure)
            {
                IPolygon pPloygon;
                Double dArea;
                pPloygon = DrawPolygon();
                dArea = MeasurePolygon(pPloygon);
                MessageBox.Show(dArea.ToString());
            }

        }

 

抱歉!评论已关闭.