Index: Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/CategorialThemeItem.cs =================================================================== diff -u -r1df4e869896a36a0b847ef497b6a48c270b25ce0 -rb6ffe77a74979f9893a1b338a13acce47c57feda --- Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/CategorialThemeItem.cs (.../CategorialThemeItem.cs) (revision 1df4e869896a36a0b847ef497b6a48c270b25ce0) +++ Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/CategorialThemeItem.cs (.../CategorialThemeItem.cs) (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -15,23 +15,22 @@ public CategorialThemeItem(string category, IStyle style, object value) { - label = category; - this.style = (IStyle) style.Clone(); + Label = category; + Style = (IStyle) style.Clone(); Value = value; } public CategorialThemeItem(string category, IStyle style) { - label = category; - this.style = (IStyle) style.Clone(); + Label = category; + Style = (IStyle) style.Clone(); } private CategorialThemeItem(CategorialThemeItem another) { - label = another.Label; - style = (IStyle) another.Style.Clone(); - + Label = another.Label; + Style = (IStyle) another.Style.Clone(); Value = another.Value; } @@ -64,7 +63,7 @@ public override int CompareTo(object obj) { - return label.CompareTo(((CategorialThemeItem) obj).label); + return Label.CompareTo(((CategorialThemeItem) obj).Label); } } } \ No newline at end of file Index: Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/GradientThemeItem.cs =================================================================== diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -rb6ffe77a74979f9893a1b338a13acce47c57feda --- Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/GradientThemeItem.cs (.../GradientThemeItem.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b) +++ Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/GradientThemeItem.cs (.../GradientThemeItem.cs) (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -11,15 +11,15 @@ public GradientThemeItem(IStyle style, string label, string range) { - this.label = label; - this.style = (IStyle) style.Clone(); + Label = label; + Style = (IStyle) style.Clone(); this.range = range; } public GradientThemeItem(GradientThemeItem another) { - label = another.Label; - style = (IStyle) another.Style.Clone(); + Label = another.Label; + Style = (IStyle) another.Style.Clone(); range = another.Range.Clone() as string; } @@ -38,7 +38,7 @@ public override int CompareTo(object obj) { - return label.CompareTo(((GradientThemeItem) obj).label); + return Label.CompareTo(((GradientThemeItem) obj).Label); } } } \ No newline at end of file Index: Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/ThemeItem.cs =================================================================== diff -u -r29074485032e73e932140ea9980c21d929e4dc08 -rb6ffe77a74979f9893a1b338a13acce47c57feda --- Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/ThemeItem.cs (.../ThemeItem.cs) (revision 29074485032e73e932140ea9980c21d929e4dc08) +++ Core/GIS/src/Core.GIS.SharpMap/Rendering/Thematics/ThemeItem.cs (.../ThemeItem.cs) (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -1,7 +1,6 @@ using System; using System.ComponentModel; using System.Drawing; -using Core.Common.Utils; using Core.GIS.GeoAPI.Geometries; using Core.GIS.SharpMap.Api; using Core.GIS.SharpMap.Styles; @@ -10,8 +9,8 @@ { public abstract class ThemeItem : IThemeItem, ICloneable { - protected string label; - protected IStyle style; + private string label; + private IStyle style; /// /// The label identifying this ThemeItem (for example shown in a legend). @@ -39,7 +38,21 @@ set { OnPropertyChanging("Style"); + + if (style != null) + { + style.PropertyChanging -= OnPropertyChanging; + style.PropertyChanged -= OnPropertyChanged; + } + style = value; + + if (style != null) + { + style.PropertyChanging += OnPropertyChanging; + style.PropertyChanged += OnPropertyChanged; + } + OnPropertyChanged("Style"); } } @@ -85,6 +98,14 @@ } } + private void OnPropertyChanging(object sender, PropertyChangingEventArgs e) + { + if (PropertyChanging != null) + { + PropertyChanging(sender, e); + } + } + public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) @@ -95,6 +116,14 @@ } } + private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (PropertyChanged != null) + { + PropertyChanged(sender, e); + } + } + #endregion } } \ No newline at end of file Index: Core/GIS/test/Core.GIS.SharpMap.Tests/Core.GIS.SharpMap.Tests.csproj =================================================================== diff -u -rb8ba6aba1df53a77e72e1fe9cfa73c62aadadeb6 -rb6ffe77a74979f9893a1b338a13acce47c57feda --- Core/GIS/test/Core.GIS.SharpMap.Tests/Core.GIS.SharpMap.Tests.csproj (.../Core.GIS.SharpMap.Tests.csproj) (revision b8ba6aba1df53a77e72e1fe9cfa73c62aadadeb6) +++ Core/GIS/test/Core.GIS.SharpMap.Tests/Core.GIS.SharpMap.Tests.csproj (.../Core.GIS.SharpMap.Tests.csproj) (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -134,8 +134,10 @@ Resources.resx + + Index: Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/CategorialThemeItemTest.cs =================================================================== diff -u --- Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/CategorialThemeItemTest.cs (revision 0) +++ Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/CategorialThemeItemTest.cs (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -0,0 +1,31 @@ +using System.ComponentModel; +using Core.GIS.SharpMap.Api; +using Core.GIS.SharpMap.Rendering.Thematics; +using Core.GIS.SharpMap.Styles; +using NUnit.Framework; + +namespace Core.GIS.SharpMap.Tests.Rendering.Thematics +{ + [TestFixture] + public class CategorialThemeItemTest + { + [Test] + public void CategorialThemeItemBubblesPropertyChangesOfStyle() + { + var counter = 0; + var categorialThemeItem = new CategorialThemeItem("", new VectorStyle()); + + ((INotifyPropertyChanged) categorialThemeItem).PropertyChanged += (sender, e) => + { + if (sender is IStyle) + { + counter++; + } + }; + + ((VectorStyle) categorialThemeItem.Style).EnableOutline = true; + + Assert.AreEqual(1, counter); + } + } +} Index: Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/GradientThemeItemTest.cs =================================================================== diff -u --- Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/GradientThemeItemTest.cs (revision 0) +++ Core/GIS/test/Core.GIS.SharpMap.Tests/Rendering/Thematics/GradientThemeItemTest.cs (revision b6ffe77a74979f9893a1b338a13acce47c57feda) @@ -0,0 +1,31 @@ +using System.ComponentModel; +using Core.GIS.SharpMap.Api; +using Core.GIS.SharpMap.Rendering.Thematics; +using Core.GIS.SharpMap.Styles; +using NUnit.Framework; + +namespace Core.GIS.SharpMap.Tests.Rendering.Thematics +{ + [TestFixture] + public class GradientThemeItemTest + { + [Test] + public void GradientThemeItemBubblesPropertyChangesOfStyle() + { + var counter = 0; + var gradientThemeItem = new GradientThemeItem(new VectorStyle(), "", ""); + + ((INotifyPropertyChanged)gradientThemeItem).PropertyChanged += (sender, e) => + { + if (sender is IStyle) + { + counter++; + } + }; + + ((VectorStyle) gradientThemeItem.Style).EnableOutline = true; + + Assert.AreEqual(1, counter); + } + } +}