private void AddGroupChildLayers() { if (Layer is GroupLayerBase) { ObservableCollection<LayerItemViewModel> mapLayerItems = new ObservableCollection<LayerItemViewModel>(); if ((Layer as GroupLayerBase).ChildLayers != null) { foreach (Layer layer in (Layer as GroupLayerBase).ChildLayers.Where(l => l.ShowLegend)) { Layer layerToFind = layer; MapLayerItem mapLayerItem = LayerItems == null ? null : LayerItems.FirstOrDefault(item => item.Layer == layerToFind) as MapLayerItem; if (mapLayerItem == null || mapLayerItems.Contains(mapLayerItem)) // else reuse existing map layer item to avoid querying again the legend and lose the item states (note : contains test if for the degenerated case where a layer is twice or more in a group layer) { // Create a new map layer item mapLayerItem = new MapLayerItem(layer) { LegendTree = this.LegendTree, LayerItemsOptions = LegendTree.LayerItemsOptions}; if (_dispatcher != null) _dispatcher.BeginInvoke(new Action(() => mapLayerItem.Refresh())); else mapLayerItem.Refresh(); } mapLayerItems.Add(mapLayerItem); } } LayerItems = mapLayerItems; #if !SILVERLIGHT // Don't display the AcceleratedDisplayLayers root node if (Layer is AcceleratedDisplayLayers) IsTransparent = true; #endif } }
private void AddGroupChildLayers() { if (Layer is GroupLayer) { ObservableCollection<LayerItemViewModel> mapLayerItems = new ObservableCollection<LayerItemViewModel>(); if ((Layer as GroupLayer).ChildLayers != null) { foreach (Layer layer in (Layer as GroupLayer).ChildLayers) { Layer layerToFind = layer; MapLayerItem mapLayerItem = LayerItems == null ? null : LayerItems.FirstOrDefault(item => item.Layer == layerToFind) as MapLayerItem; if (mapLayerItem == null || mapLayerItems.Contains(mapLayerItem)) // else reuse existing map layer item to avoid querying again the legend and lose the item states (note : contains test if for the degenerated case where a layer is twice or more in a group layer) { // Create a new map layer item mapLayerItem = new MapLayerItem(layer) { LegendTree = this.LegendTree }; if (_dispatcher != null) _dispatcher.BeginInvoke(new Action(() => mapLayerItem.Refresh())); else mapLayerItem.Refresh(); } mapLayerItems.Add(mapLayerItem); } } LayerItems = mapLayerItems; } }