Index: src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapTreeViewNodePresenter.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapTreeViewNodePresenter.cs (.../MapTreeViewNodePresenter.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapTreeViewNodePresenter.cs (.../MapTreeViewNodePresenter.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -6,6 +6,7 @@ using DelftTools.Controls; using DelftTools.Shell.Gui; using DelftTools.Shell.Gui.Swf; +using DeltaShell.Plugins.SharpMapGis.Gui.Properties; using SharpMap; using SharpMap.Api.Layers; using SharpMap.Layers; @@ -14,11 +15,9 @@ { public class MapTreeViewNodePresenter : TreeViewNodePresenterBaseForPluginGui { - private static readonly Bitmap MapIcon = Properties.Resources.Map; + private static readonly Bitmap MapIcon = Resources.Map; - public MapTreeViewNodePresenter(GuiPlugin guiPlugin) : base(guiPlugin) - { - } + public MapTreeViewNodePresenter(GuiPlugin guiPlugin) : base(guiPlugin) {} public override bool CanRenameNode(ITreeNode node) { @@ -32,21 +31,17 @@ var indexOfCoordinateSystem = newName.IndexOf(string.Format(" ({0})", map.CoordinateSystem.Name), StringComparison.InvariantCulture); if (indexOfCoordinateSystem >= 0) + { newName = newName.Substring(0, indexOfCoordinateSystem); + } } if (map.Name != newName) + { map.Name = newName; + } } - private static void SetNodeText(ITreeNode node, Map map) - { - if (map.CoordinateSystem != null) - node.Text = string.Format("{0} ({1})", map.Name, map.CoordinateSystem.Name); - else - node.Text = map.Name; - } - public override void UpdateNode(ITreeNode parentNode, ITreeNode node, Map map) { SetNodeText(node, map); @@ -62,16 +57,6 @@ } } - protected override void OnPropertyChanged(Map map, ITreeNode node, PropertyChangedEventArgs e) - { - if (node == null) return; - - if (e.PropertyName == "Name") - { - SetNodeText(node, map); - } - } - public override IEnumerable GetChildNodeObjects(Map map, ITreeNode node) { return map.Layers.Where(l => l.ShowInTreeView); @@ -115,5 +100,30 @@ } } } + + protected override void OnPropertyChanged(Map map, ITreeNode node, PropertyChangedEventArgs e) + { + if (node == null) + { + return; + } + + if (e.PropertyName == "Name") + { + SetNodeText(node, map); + } + } + + private static void SetNodeText(ITreeNode node, Map map) + { + if (map.CoordinateSystem != null) + { + node.Text = string.Format("{0} ({1})", map.Name, map.CoordinateSystem.Name); + } + else + { + node.Text = map.Name; + } + } } } \ No newline at end of file