Index: src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/WmsMapLayerTreeViewNodePresenter.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/WmsMapLayerTreeViewNodePresenter.cs (.../WmsMapLayerTreeViewNodePresenter.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/WmsMapLayerTreeViewNodePresenter.cs (.../WmsMapLayerTreeViewNodePresenter.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -9,54 +9,48 @@ { public class WmsMapLayerTreeViewNodePresenter : TreeViewNodePresenterBaseForPluginGui { - private IGisGuiService gisGuiService; - private static WmsLayer currentWmsLayer; + private readonly IGisGuiService gisGuiService; public WmsMapLayerTreeViewNodePresenter(GuiPlugin guiPlugin, IGisGuiService gisGuiService) : base(guiPlugin) { this.gisGuiService = gisGuiService; } - // small hack - public static WmsLayer CurrentWmsLayer - { - get { return currentWmsLayer; } - set { currentWmsLayer = value; } - } + public static WmsLayer CurrentWmsLayer { get; set; } public override void UpdateNode(ITreeNode parentNode, ITreeNode node, Client.WmsServerLayer layer) { node.Text = layer.Name; node.Tag = layer; - node.Checked = currentWmsLayer.LayerList.Contains(layer.Name); + node.Checked = CurrentWmsLayer.LayerList.Contains(layer.Name); node.ShowCheckBox = true; } - + public override void OnNodeChecked(ITreeNode node) { - Client.WmsServerLayer layer = (Client.WmsServerLayer)node.Tag; - if(node.Checked) + Client.WmsServerLayer layer = (Client.WmsServerLayer) node.Tag; + if (node.Checked) { - List oldLayers = new List(currentWmsLayer.LayerList); + List oldLayers = new List(CurrentWmsLayer.LayerList); // TODO: add support for layer order when dragging will work - currentWmsLayer.LayerList.Clear(); - foreach (Client.WmsServerLayer childLayer in currentWmsLayer.RootLayer.ChildLayers) + CurrentWmsLayer.LayerList.Clear(); + foreach (Client.WmsServerLayer childLayer in CurrentWmsLayer.RootLayer.ChildLayers) { - if(childLayer.Name.Equals(layer.Name) || oldLayers.Contains(childLayer.Name)) + if (childLayer.Name.Equals(layer.Name) || oldLayers.Contains(childLayer.Name)) { - currentWmsLayer.LayerList.Add(childLayer.Name); + CurrentWmsLayer.LayerList.Add(childLayer.Name); } } } else { - currentWmsLayer.LayerList.Remove(layer.Name); + CurrentWmsLayer.LayerList.Remove(layer.Name); } - currentWmsLayer.RenderRequired = true; - gisGuiService.RefreshMapView(currentWmsLayer.Map); + CurrentWmsLayer.RenderRequired = true; + gisGuiService.RefreshMapView(CurrentWmsLayer.Map); } } } \ No newline at end of file