Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapDataCollectionProperties.cs =================================================================== diff -u -rc0b11bd2f03f6e836efa4cdc640ea974113712ec -r1842e169ca9a255a5d601409a93fed507e9327ca --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapDataCollectionProperties.cs (.../MapDataCollectionProperties.cs) (revision c0b11bd2f03f6e836efa4cdc640ea974113712ec) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapDataCollectionProperties.cs (.../MapDataCollectionProperties.cs) (revision 1842e169ca9a255a5d601409a93fed507e9327ca) @@ -21,10 +21,11 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using Core.Common.Gui.PropertyBag; +using Core.Common.Util; using Core.Common.Util.Attributes; using Core.Components.Gis.Data; -using Core.Components.Gis.Helpers; using Core.Plugins.Map.Properties; namespace Core.Plugins.Map.PropertyClasses @@ -74,42 +75,13 @@ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_MapDataCollection))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_IsVisible_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapDataCollection_IsVisible_Description))] - public bool IsVisible + [TypeConverter(typeof(EnumTypeConverter))] + public MapDataCollectionVisibility Visibility { get { - return data.IsVisible; + return data.GetVisibility(); } - set - { - Dictionary childStates = MapDataCollectionHelper.GetChildVisibilityStates(data); - - data.IsVisible = value; - data.NotifyObservers(); - - NotifyChildren(childStates); - - NotifyParents(); - } } - - private void NotifyParents() - { - foreach (MapDataCollection parent in parents) - { - parent.NotifyObservers(); - } - } - - private static void NotifyChildren(Dictionary childStates) - { - foreach (KeyValuePair child in childStates) - { - if (child.Key.IsVisible != child.Value) - { - child.Key.NotifyObservers(); - } - } - } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapDataCollectionPropertiesTest.cs =================================================================== diff -u -r12652870d19153635f4b59f04a244f1df288a3d4 -r1842e169ca9a255a5d601409a93fed507e9327ca --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapDataCollectionPropertiesTest.cs (.../MapDataCollectionPropertiesTest.cs) (revision 12652870d19153635f4b59f04a244f1df288a3d4) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapDataCollectionPropertiesTest.cs (.../MapDataCollectionPropertiesTest.cs) (revision 1842e169ca9a255a5d601409a93fed507e9327ca) @@ -22,22 +22,21 @@ using System; using System.ComponentModel; using System.Linq; -using Core.Common.Base; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; +using Core.Common.Util; using Core.Components.Gis.Data; using Core.Components.Gis.TestUtil; using Core.Plugins.Map.PropertyClasses; using NUnit.Framework; -using Rhino.Mocks; namespace Core.Plugins.Map.Test.PropertyClasses { [TestFixture] public class MapDataCollectionPropertiesTest { private const int namePropertyIndex = 0; - private const int isVisiblePropertyIndex = 1; + private const int visibilityPropertyIndex = 1; [Test] public void Constructor_MapDataCollectionNull_ThrowsArgumentNullException() @@ -76,7 +75,10 @@ Assert.AreSame(mapDataCollection, properties.Data); Assert.AreEqual(mapDataCollection.Name, properties.Name); - Assert.AreEqual(mapDataCollection.IsVisible, properties.IsVisible); + Assert.AreEqual(mapDataCollection.GetVisibility(), properties.Visibility); + + TestHelper.AssertTypeConverter( + nameof(MapDataCollectionProperties.Visibility)); } [Test] @@ -101,74 +103,12 @@ "De naam van deze kaartlagenmap.", true); - PropertyDescriptor isVisibleProperty = dynamicProperties[isVisiblePropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isVisibleProperty, + PropertyDescriptor visibilityProperty = dynamicProperties[visibilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(visibilityProperty, mapDataCollectionCategory, "Weergeven", - "Geeft aan of deze kaartlagenmap wordt weergegeven."); + "Geeft aan of deze kaartlagenmap wordt weergegeven.", + true); } - - [Test] - public void IsVisible_Always_NotifiesDataAndParents() - { - // Setup - var mocks = new MockRepository(); - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()).Repeat.Times(2); - mocks.ReplayAll(); - - var parentMapDataCollection = new MapDataCollection("Parent 1"); - var mapDataCollection = new MapDataCollection("Collection"); - - parentMapDataCollection.Add(mapDataCollection); - - parentMapDataCollection.Attach(observer); - mapDataCollection.Attach(observer); - - var properties = new MapDataCollectionProperties(mapDataCollection, new[] - { - parentMapDataCollection - }); - - // Call - properties.IsVisible = false; - - // Assert - mocks.VerifyAll(); - } - - [Test] - [TestCase(true, 1)] - [TestCase(false, 4)] - public void GivenPropertiesWithChildren_WhenIsVisibleChanged_ThenOnlyChangedChildrenNotified(bool isVisible, int expectedNotifications) - { - // Given - var mocks = new MockRepository(); - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()).Repeat.Times(expectedNotifications); - mocks.ReplayAll(); - - var mapDataCollection = new MapDataCollection("Collection"); - var childLayer1 = new TestFeatureBasedMapData(); - var childCollection = new MapDataCollection("Child"); - var childLayer2 = new TestFeatureBasedMapData(); - - mapDataCollection.Add(childLayer1); - mapDataCollection.Add(childCollection); - childCollection.Add(childLayer2); - - mapDataCollection.Attach(observer); - childLayer1.Attach(observer); - childCollection.Attach(observer); - childLayer2.Attach(observer); - - var properties = new MapDataCollectionProperties(mapDataCollection, Enumerable.Empty()); - - // When - properties.IsVisible = isVisible; - - // Then - mocks.VerifyAll(); - } } } \ No newline at end of file