Exemplo n.º 1
0
 public void Dispose()
 {
     if (_canvas != null)
     {
         if (_canvas.LayerContainer.VectorHost != null)
         {
             IMap map = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).Map as IMap;
             if (map != null && map.LayerContainer != null)
             {
                 map.LayerContainer.Remove(_layer);
             }
         }
         _canvas = null;
     }
     if (_mapRuntime != null)
     {
         _mapRuntime = null;
     }
     if (_datasource != null)
     {
         _datasource.Dispose();
         _datasource = null;
     }
     if (_labeldef != null)
     {
         _labeldef.Dispose();
         _labeldef = null;
     }
     if (_layer != null)
     {
         _layer.Dispose();
         _layer = null;
     }
     OID = 0;
 }
Exemplo n.º 2
0
        private void UpdateLayerColor()
        {
            IVectorHostLayer hostLayer = _activeViewer.Canvas.LayerContainer.VectorHost as IVectorHostLayer;

            if (hostLayer == null)
            {
                return;
            }
            IMap map = hostLayer.Map as IMap;

            CodeCell.AgileMap.Core.ILayer lyr = map.LayerContainer.GetLayerByName(_layerName);
            if (lyr != null)
            {
                CodeCell.AgileMap.Core.IFeatureLayer fetLayer = lyr as CodeCell.AgileMap.Core.IFeatureLayer;
                ISymbol symbol = fetLayer.Renderer.CurrentSymbol;
                if (symbol != null)
                {
                    IFillSymbol fillSymbol = symbol as IFillSymbol;
                    if (fillSymbol == null)
                    {
                        return;
                    }
                    fillSymbol.OutlineSymbol.Color = btnColor.BackColor;
                }
            }
        }
Exemplo n.º 3
0
        private void SetRenderer(CodeCell.AgileMap.Core.IFeatureLayer fetLayer)
        {
            IFeatureRenderer      render = fetLayer.Renderer;
            SimpleFeatureRenderer sr     = render as SimpleFeatureRenderer;
            IFillSymbol           sym    = sr.Symbol as IFillSymbol;

            sym.OutlineSymbol.Color = Color.Blue;
        }
Exemplo n.º 4
0
        private void SetLabel(CodeCell.AgileMap.Core.IFeatureLayer fetLayer)
        {
            LabelDef df = fetLayer.LabelDef as LabelDef;

            if (df == null)
            {
                return;
            }
            df.EnableLabeling = true;
            df.ForeColor      = Color.Red;
            df.Fieldname      = "name";
            _labeldef         = df;
        }
Exemplo n.º 5
0
 private static void TryApplyStyle(CodeCell.AgileMap.Core.IFeatureLayer fetLayer, string dataTypeId)
 {
     //根据文件类型应用显示方案
     string[] mcdfnames = Directory.GetFiles(Path.GetDirectoryName(MicapsFileProcessor.DATATYPE_CONFIG_DIR), "*.mcd");
     //应用默认方案
     if (mcdfnames == null || mcdfnames.Length < 1)
     {
         SimpleMarkerSymbol sym = new SimpleMarkerSymbol(masSimpleMarkerStyle.Circle);
         sym.Size          = new System.Drawing.Size(3, 3);
         fetLayer.Renderer = new SimpleFeatureRenderer(sym);
         return;
     }
     else
     {
         string fname = null;
         foreach (string item in mcdfnames)
         {
             if (dataTypeId == Path.GetFileNameWithoutExtension(item))
             {
                 fname = item;
                 break;
             }
         }
         if (fname != null)
         {
             XDocument doc    = XDocument.Load(fname);
             var       result = doc.Element("Map").Element("Layers").Elements();
             if (result == null)
             {
                 return;
             }
             LabelDef         labelDef      = null;
             IFeatureRenderer featureRender = null;
             GetFeatureRenderFromMcd(doc, out labelDef, out featureRender);
             if (labelDef != null)
             {
                 fetLayer.LabelDef = labelDef;
             }
             if (featureRender != null)
             {
                 fetLayer.Renderer = featureRender;
             }
         }
     }
 }
Exemplo n.º 6
0
        public SimpleVectorObjectHost(string name, ICanvas canvas, string[] fieldNames)
        {
            if (fieldNames != null)
            {
                _fldNames = fieldNames;
            }
            _canvas     = canvas;
            _mapRuntime = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).MapRuntime as IMapRuntime;
            _datasource = new CodeCell.AgileMap.Core.MemoryDataSource(name, enumShapeType.Polygon, _fldNames);
            CodeCell.AgileMap.Core.IFeatureClass fetClass = new CodeCell.AgileMap.Core.FeatureClass(_datasource);
            CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new CodeCell.AgileMap.Core.FeatureLayer(name, fetClass);
            _layer = fetLayer;
            IMap map = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).Map as IMap;

            if (map != null)
            {
                map.LayerContainer.Append(fetLayer);
            }
            SetLabel(fetLayer);
            SetRenderer(fetLayer);
        }
Exemplo n.º 7
0
        public void DisplayLonLat(float[] lats, float[] lons, string fname)
        {
            Feature[] fs = ConstructPoint(lats, lons);

            //CanvasViewer cv = new CanvasViewer(OpenFileFactory.GetTextByFileName(fname), _smartSession);
            //_smartSession.SmartWindowManager.DisplayWindow(cv);

            ICanvasViewer cv = _smartSession.SmartWindowManager.ActiveCanvasViewer;

            if (cv == null)
            {
                return;
            }
            ICanvas c = cv.Canvas;

            if (c == null)
            {
                return;
            }
            CodeCell.AgileMap.Core.IFeatureLayer layer = CreateAndLoadVectorLayerForMicaps(_smartSession, cv.Canvas, fname, fs);
        }
Exemplo n.º 8
0
        protected override CodeCell.AgileMap.Core.ISymbol GetSymbol()
        {
            if (string.IsNullOrEmpty(_layerName) || _dataFrame == null || _dataFrame.Provider == null)
            {
                return(null);
            }
            IDataFrameDataProvider provider = _dataFrame.Provider as IDataFrameDataProvider;

            if (provider == null || provider.Canvas == null)
            {
                return(null);
            }
            IVectorHostLayer hostLayer = provider.Canvas.LayerContainer.VectorHost as IVectorHostLayer;

            if (hostLayer == null)
            {
                return(null);
            }
            IMap map = hostLayer.Map as IMap;

            if (map == null)
            {
                return(null);
            }
            CodeCell.AgileMap.Core.ILayer layer = map.LayerContainer.GetLayerByName(_layerName);
            if (layer == null)
            {
                return(null);
            }
            CodeCell.AgileMap.Core.IFeatureLayer fetLayer = layer as CodeCell.AgileMap.Core.IFeatureLayer;
            if (fetLayer == null || fetLayer.Renderer == null)
            {
                return(null);
            }
            return(fetLayer.Renderer.CurrentSymbol);
        }