private void RemoveVectorLayer(ICanvas canvas, RadMenuItem item) { IVectorHostLayer vectorHost = canvas.LayerContainer.VectorHost; if (vectorHost == null) { return; } Map map = vectorHost.Map as Map; if (map == null) { return; } CodeCell.AgileMap.Core.ILayer[] layers = map.LayerContainer.Layers; if (layers == null || layers.Length == 0) { return; } CodeCell.AgileMap.Core.ILayer removeLayer = null; foreach (CodeCell.AgileMap.Core.ILayer layer in layers) { if (layer.Name == item.Tag.ToString()) { removeLayer = layer; } } if (removeLayer != null) { (vectorHost.Map as Map).LayerContainer.Remove(removeLayer); } }
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; } } }
public void AdjustOrder(int insertIndex, ILayerItem item) { if (item.Tag is CodeCell.AgileMap.Core.ILayer) { foreach (GeoDo.RSS.Core.DrawEngine.ILayer layer in _viewer.Canvas.LayerContainer.Layers) { if (layer is IVectorHostLayer) { IVectorHostLayer hostLayer = layer as IVectorHostLayer; IMap map = hostLayer.Map as IMap; CodeCell.AgileMap.Core.ILayer lyr = item.Tag as CodeCell.AgileMap.Core.ILayer; map.LayerContainer.AdjustOrder(lyr, map.LayerContainer.Layers[insertIndex]); foreach (ILayerItem it in Items) { if (it is ILayerItemGroup && it.Tag is IVectorHostLayer) { (it as ILayerItemGroup).Items.Remove(item); (it as ILayerItemGroup).Items.Insert(insertIndex, item); } } break; } } } if (item.Tag is GeoDo.RSS.Core.DrawEngine.IRenderLayer || item.Tag is IVectorHostLayer) { this.Items.Remove(item); this.Items.Insert(insertIndex, item); _viewer.Canvas.LayerContainer.Layers.Remove(item.Tag as GeoDo.RSS.Core.DrawEngine.ILayer); _viewer.Canvas.LayerContainer.Layers.Insert(insertIndex, item.Tag as GeoDo.RSS.Core.DrawEngine.ILayer); } RefreshViewer(); }
private void RemoveVectorLayer(string filename) { try { ILayoutHost host = null; ICanvas canvas = GetCanvasFromSession(ref host); if (canvas == null) { return; } IVectorHostLayer vectorHost = canvas.LayerContainer.VectorHost; if (vectorHost == null) { return; } Map map = vectorHost.Map as Map; if (map == null) { return; } CodeCell.AgileMap.Core.ILayer _layer = shps[filename.ToLower()]; map.LayerContainer.Remove(_layer); canvas.Refresh(enumRefreshType.VectorLayer); if (host != null) { host.Render(true); } RefreshLayerManager(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void ClearLineLayers() { if (linLayerName == null || linLayerName.Count == 0) { return; } ICanvasViewer viewer = _session.SmartWindowManager.ActiveCanvasViewer; if (viewer == null) { return; } CodeCell.AgileMap.Core.ILayer removeLayer = null; foreach (string name in linLayerName) { foreach (GeoDo.RSS.Core.DrawEngine.ILayer layer in viewer.Canvas.LayerContainer.Layers) { if (layer is IVectorHostLayer) { IVectorHostLayer hostLayer = layer as IVectorHostLayer; IMap map = hostLayer.Map as IMap; if (map.LayerContainer != null) { removeLayer = map.LayerContainer.GetLayerByName(name); } if (removeLayer != null) { map.LayerContainer.Remove(removeLayer); break; } } } } Update(); }
/// <summary> /// 设置标注和矢量的绘制风格 /// </summary> /// <param name="lyr"></param> /// <param name="shpFname"></param> private void TryApplyStyle(AgileMap.ILayer lyr, string shpFname) { string mcdfname = Path.ChangeExtension(shpFname, ".mcd"); if (!File.Exists(mcdfname)) { return; } XDocument doc = XDocument.Load(mcdfname); 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) { (lyr as CodeCell.AgileMap.Core.IFeatureLayer).LabelDef = labelDef; } if (featureRender != null) { (lyr as CodeCell.AgileMap.Core.IFeatureLayer).Renderer = featureRender; } }
private AgileMap.ILayer LoadFeatureLayer(string shpFname, object arguments) { AgileMap.ILayer lyr = null;//IFeatureLayer //lyr = TryLoadFeatureLayerFromMcd(shpFname); //if (lyr == null) lyr = VectorLayerFactory.CreateFeatureLayer(shpFname, arguments); TryApplyStyle(lyr, shpFname); return(lyr); }
private CodeCell.AgileMap.Core.ILayer TryGetLayer(string layerName) { IVectorHostLayer hostLayer = _activeViewer.Canvas.LayerContainer.VectorHost as IVectorHostLayer; if (hostLayer == null) { return(null); } IMap map = hostLayer.Map as IMap; CodeCell.AgileMap.Core.ILayer lyr = map.LayerContainer.GetLayerByName(layerName); return(lyr); }
public void AddData(string fname, object arguments) { AgileMap.ILayer lyr = LoadFeatureLayer(fname, arguments); if (lyr != null) { //AppFeatureAttribute(lyr); if (_mapRuntime == null || _isDisposed) { CreateMapRuntime(); } if (_mapRuntime.Map == null) { _mapRuntime.Apply(new Map()); } ; _mapRuntime.Map.LayerContainer.Append(lyr); } }
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); }