Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs =================================================================== diff -u -rd1b19bb139550ae19f474c28f94ff3329cae0236 -r18827eaade9901a6ba9e602774444dd34df6dac3 --- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d1b19bb139550ae19f474c28f94ff3329cae0236) +++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 18827eaade9901a6ba9e602774444dd34df6dac3) @@ -40,7 +40,7 @@ // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -175,6 +175,15 @@ } /// + /// Looks up a localized string similar to Categorieën. + /// + public static string FeatureBasedMapdata_Categories_DisplayName { + get { + return ResourceManager.GetString("FeatureBasedMapdata_Categories_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Toont de eigenschap op basis waarvan de kaartlaag is gecategoriseerd.. /// public static string FeatureBasedMapdata_MapThemeAttributeName_Description { Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx =================================================================== diff -u -rd1b19bb139550ae19f474c28f94ff3329cae0236 -r18827eaade9901a6ba9e602774444dd34df6dac3 --- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision d1b19bb139550ae19f474c28f94ff3329cae0236) +++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 18827eaade9901a6ba9e602774444dd34df6dac3) @@ -358,4 +358,7 @@ Enkel symbool + + Categorieën + \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/FeatureBasedMapDataProperties.cs =================================================================== diff -u -rd1b19bb139550ae19f474c28f94ff3329cae0236 -r18827eaade9901a6ba9e602774444dd34df6dac3 --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/FeatureBasedMapDataProperties.cs (.../FeatureBasedMapDataProperties.cs) (revision d1b19bb139550ae19f474c28f94ff3329cae0236) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/FeatureBasedMapDataProperties.cs (.../FeatureBasedMapDataProperties.cs) (revision 18827eaade9901a6ba9e602774444dd34df6dac3) @@ -24,6 +24,7 @@ using System.Drawing.Design; using System.Linq; using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; using Core.Components.Gis.Data; @@ -44,6 +45,7 @@ private const int selectedMetaDataAttributePropertyIndex = 4; private const int styleTypePropertyIndex = 5; private const int mapThemeAttributeNamePropertyIndex = 6; + private const int mapThemeCategoryPropertyIndex = 7; [PropertyOrder(namePropertyIndex)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Layer))] @@ -98,6 +100,26 @@ } } + [PropertyOrder(selectedMetaDataAttributePropertyIndex)] + [DynamicVisible] + [DynamicReadOnly] + [Editor(typeof(MetaDataAttributeEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Label))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.FeatureBasedMapdata_SelectedMetaDataAttribute_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.FeatureBasedMapdata_SelectedMetaDataAttribute_Description))] + public SelectableMetaDataAttribute SelectedMetaDataAttribute + { + get + { + return new SelectableMetaDataAttribute(data.SelectedMetaDataAttribute ?? string.Empty); + } + set + { + data.SelectedMetaDataAttribute = value.MetaDataAttribute; + data.NotifyObservers(); + } + } + [PropertyOrder(styleTypePropertyIndex)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.FeatureBasedMapdata_StyleType_DisplayName))] @@ -124,30 +146,27 @@ { get { - return data.MapTheme != null + return data.MapTheme != null ? data.MapTheme.AttributeName : string.Empty; } } - [PropertyOrder(selectedMetaDataAttributePropertyIndex)] + [PropertyOrder(mapThemeCategoryPropertyIndex)] [DynamicVisible] - [DynamicReadOnly] - [Editor(typeof(MetaDataAttributeEditor), typeof(UITypeEditor))] - [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Label))] - [ResourcesDisplayName(typeof(Resources), nameof(Resources.FeatureBasedMapdata_SelectedMetaDataAttribute_DisplayName))] - [ResourcesDescription(typeof(Resources), nameof(Resources.FeatureBasedMapdata_SelectedMetaDataAttribute_Description))] - public SelectableMetaDataAttribute SelectedMetaDataAttribute + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.FeatureBasedMapdata_Categories_DisplayName))] + [TypeConverter(typeof(ExpandableArrayConverter))] + public CategoryThemeProperties[] Categories { get { - return new SelectableMetaDataAttribute(data.SelectedMetaDataAttribute ?? string.Empty); + return data.MapTheme != null + ? data.MapTheme.CategoryThemes + .Select(theme => new CategoryThemeProperties(data.MapTheme.AttributeName, theme)) + .ToArray() + : new CategoryThemeProperties[0]; } - set - { - data.SelectedMetaDataAttribute = value.MetaDataAttribute; - data.NotifyObservers(); - } } [DynamicReadOnlyValidationMethod] @@ -170,7 +189,8 @@ return data.ShowLabels; } - if (propertyName == nameof(MapThemeAttributeName)) + if (propertyName == nameof(MapThemeAttributeName) + || propertyName == nameof(Categories)) { return data.MapTheme != null; } Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/FeatureBasedMapDataPropertiesTest.cs =================================================================== diff -u -r54d37f5365221367818b74e670e8544919cef483 -r18827eaade9901a6ba9e602774444dd34df6dac3 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/FeatureBasedMapDataPropertiesTest.cs (.../FeatureBasedMapDataPropertiesTest.cs) (revision 54d37f5365221367818b74e670e8544919cef483) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/FeatureBasedMapDataPropertiesTest.cs (.../FeatureBasedMapDataPropertiesTest.cs) (revision 18827eaade9901a6ba9e602774444dd34df6dac3) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Core.Common.Base; +using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using Core.Components.Gis.Data; @@ -45,7 +47,9 @@ private const int showLabelsPropertyIndex = 3; private const int selectedMetaDataAttributePropertyIndex = 4; private const int stylePropertyIndex = 5; + private const int mapThemeAttributeNamePropertyIndex = 5; + private const int mapThemeCategoriesPropertyIndex = 6; [Test] public void Constructor_ExpectedValues() @@ -57,22 +61,45 @@ Assert.IsInstanceOf>(properties); Assert.IsInstanceOf(properties); Assert.IsNull(properties.Data); + + TestHelper.AssertTypeConverter( + nameof(properties.Categories)); } [Test] - [TestCase(true)] - [TestCase(false)] - public void Data_SetNewMapPointDataInstance_ReturnCorrectPropertyValues(bool hasMapTheme) + public void Data_SetNewMapPointDataInstanceWithoutMapTheme_ReturnCorrectPropertyValues() { // Setup + var mapPointData = new MapPointData("Test"); + + var properties = new TestFeatureBasedMapDataProperties(); + + // Call + properties.Data = mapPointData; + + // Assert + Assert.AreEqual(mapPointData.Name, properties.Name); + Assert.AreEqual("Test feature based map data", properties.Type); + Assert.AreEqual(mapPointData.IsVisible, properties.IsVisible); + Assert.AreEqual(mapPointData.ShowLabels, properties.ShowLabels); + Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute); + Assert.AreEqual(mapPointData.MetaData, properties.GetAvailableMetaDataAttributes()); + + Assert.AreEqual("Enkel symbool", properties.StyleType); + Assert.IsEmpty(properties.MapThemeAttributeName); + CollectionAssert.IsEmpty(properties.Categories); + } + + [Test] + public void Data_SetNewMapPointDataInstanceWithMapTheme_ReturnCorrectPropertyValues() + { + // Setup var mapPointData = new MapPointData("Test") { - MapTheme = hasMapTheme - ? new MapTheme("Attribute", new[] - { - CategoryThemeTestFactory.CreateCategoryTheme() - }) - : null + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) }; var properties = new TestFeatureBasedMapDataProperties(); @@ -88,15 +115,16 @@ Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute); Assert.AreEqual(mapPointData.MetaData, properties.GetAvailableMetaDataAttributes()); - string expectedStyleTypeValue = hasMapTheme - ? "Categorie" - : "Enkel symbool"; - Assert.AreEqual(expectedStyleTypeValue, properties.StyleType); + Assert.AreEqual("Categorie", properties.StyleType); + Assert.AreEqual(mapPointData.MapTheme.AttributeName, properties.MapThemeAttributeName); - string expectedAttributeName = hasMapTheme - ? mapPointData.MapTheme.AttributeName - : string.Empty; - Assert.AreEqual(expectedAttributeName, properties.MapThemeAttributeName); + IEnumerable categoryThemes = mapPointData.MapTheme.CategoryThemes; + Assert.AreEqual(categoryThemes.Count(), properties.Categories.Length); + + CategoryThemeProperties categoryThemeProperties = properties.Categories.First(); + CategoryTheme categoryTheme = categoryThemes.First(); + Assert.AreSame(categoryTheme, categoryThemeProperties.Data); + StringAssert.StartsWith(mapPointData.MapTheme.AttributeName, categoryThemeProperties.Criterion); } [Test] @@ -311,7 +339,7 @@ // Assert // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(hasMapTheme ? 6 : 5, dynamicProperties.Count); + Assert.AreEqual(hasMapTheme ? 7 : 5, dynamicProperties.Count); if (hasMapTheme) { @@ -321,6 +349,13 @@ "Op basis van", "Toont de eigenschap op basis waarvan de kaartlaag is gecategoriseerd.", true); + + PropertyDescriptor categoriesAttribute = dynamicProperties[mapThemeCategoriesPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(categoriesAttribute, + "Stijl", + "Categorieën", + string.Empty, + true); } } @@ -435,9 +470,12 @@ // Call bool isMapThemeAttributeNameVisible = properties.DynamicVisibleValidationMethod( nameof(TestFeatureBasedMapDataProperties.MapThemeAttributeName)); + bool isMapThemeCategoriesVisible = properties.DynamicVisibleValidationMethod( + nameof(TestFeatureBasedMapDataProperties.Categories)); // Assert Assert.AreEqual(hasMapTheme, isMapThemeAttributeNameVisible); + Assert.AreEqual(hasMapTheme, isMapThemeCategoriesVisible); } [Test]