Example #1
0
        //获取新建图层
        IGraphicsLayer getDemoLayer(IView view, string layerID)
        {
            IGraphicsLayer gLayer = view.getLayer(layerID);

            if (gLayer == null)
            {
                gLayer = Runtime.graphicEngine.newGraphicsLayer(
                    layerID, layerID);
                var sym_fill = GraphicsUtil.GetDefaultFillSymbol();
                var renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill);
                gLayer.setRenderer(renderer);
                gLayer.Opacity = 0.9;
                view.addLayer(gLayer);
            }
            return(gLayer);
        }
        void StartAnalyzing()
        {
            //Get input view
            IView view = InputCB.SelectedItem as IView;

            _spatialRef = view.spatialReference;

            //create new layer
            view.removeLayer("Rectanglelayer");  //clear the previous layer
            string         layerID  = "Rectanglelayer";
            IGraphicsLayer mlayer   = Runtime.graphicEngine.newGraphicsLayer(layerID, layerID);
            var            sym_fill = GraphicsUtil.GetDefaultFillSymbol();
            var            renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill);

            mlayer.setRenderer(renderer);
            mlayer.Opacity = 1.0;
            view.addLayer(mlayer);

            //Define local variables
            IGraphic m;
            int      count  = 0;
            int      result = 5;
            double   monpointX;
            double   monpointY;

            _monpoints = _prj.getSelectedObjs(_monitoringDomain, "MonPoint");
            foreach (DGObject mp in _mps)
            {
                MonPoint _mp = mp as MonPoint;
                foreach (string key in _mp.readingsDict.Keys)
                {
                    List <MonReading> a = _mp.readingsDict[key];
                    foreach (MonReading b in a)
                    {
                        if (System.Math.Abs(b.value) > mptb)
                        {
                            count++;
                        }
                    }

                    if (count <= 50)
                    {
                        result = 5;
                    }
                    else if (count <= 150)
                    {
                        result = 4;
                    }
                    else if (count <= 250)
                    {
                        result = 3;
                    }
                    else if (count <= 350)
                    {
                        result = 2;
                    }
                    else
                    {
                        result = 1;
                    }
                    ISymbol symbol = GetSymbol(result);

                    //Obtain borehole coordinates
                    IGraphicsLayer     mplayer      = view.getLayer("MonPoint");
                    IGraphicCollection mpcollection = mplayer.getGraphics(_mp);
                    m = mpcollection[0];
                    IGeometry mpgeometry = m.Geometry;
                    IMapPoint mpmappoint = mpgeometry as IMapPoint;
                    monpointX = mpmappoint.X;
                    monpointY = mpmappoint.Y;

                    //Draw rectangle
                    IMapPoint p1 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY + 2200, _spatialRef);
                    IMapPoint p2 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY - 2200, _spatialRef);
                    IMapPoint p3 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY - 2200, _spatialRef);
                    IMapPoint p4 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY + 2200, _spatialRef);
                    m        = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4);
                    m.Symbol = symbol;
                    IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection();
                    gc.Add(m);
                    mlayer.addGraphics(gc);
                }
            }
        }