Index: Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj =================================================================== diff -u -ra60c62d19bd689b7fd98dd6735393af54f5d2586 -rc7fcffe365d541dea0534be466c97f8ea70dc9c3 --- Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj (.../Core.Plugins.Map.csproj) (revision a60c62d19bd689b7fd98dd6735393af54f5d2586) +++ Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj (.../Core.Plugins.Map.csproj) (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -1,4 +1,4 @@ - + {610E0A9C-1997-4C43-A10E-39D4C66ADA93} @@ -49,6 +49,7 @@ + Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs =================================================================== diff -u -r8247c76fe477394608aeaa6b04d06df54f052cd5 -rc7fcffe365d541dea0534be466c97f8ea70dc9c3 --- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8247c76fe477394608aeaa6b04d06df54f052cd5) +++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -137,15 +137,6 @@ } /// - /// Looks up a localized string similar to De kleur waarmee deze categorie wordt weergegeven.. - /// - public static string CategoryThemeProperties_Color_Description { - get { - return ResourceManager.GetString("CategoryThemeProperties_Color_Description", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Het criterium van deze categorie.. /// public static string CategoryThemeProperties_Criterion_Description { @@ -310,6 +301,33 @@ } /// + /// Looks up a localized string similar to De kleur van de lijnen waarmee deze categorie wordt weergegeven.. + /// + public static string LineCategoryTheme_Color_Description { + get { + return ResourceManager.GetString("LineCategoryTheme_Color_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De stijl van de lijnen waarmee deze categorie wordt weergegeven.. + /// + public static string LineCategoryTheme_DashStyle_Description { + get { + return ResourceManager.GetString("LineCategoryTheme_DashStyle_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De dikte van de lijnen waarmee deze categorie wordt weergegeven.. + /// + public static string LineCategoryTheme_Width_Description { + get { + return ResourceManager.GetString("LineCategoryTheme_Width_Description", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap LineIcon { Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx =================================================================== diff -u -r8247c76fe477394608aeaa6b04d06df54f052cd5 -rc7fcffe365d541dea0534be466c97f8ea70dc9c3 --- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 8247c76fe477394608aeaa6b04d06df54f052cd5) +++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -331,9 +331,6 @@ De dikte van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven. - - De kleur waarmee deze categorie wordt weergegeven. - Het criterium van deze categorie. @@ -367,4 +364,13 @@ Categorieën + + De kleur van de lijnen waarmee deze categorie wordt weergegeven. + + + De stijl van de lijnen waarmee deze categorie wordt weergegeven. + + + De dikte van de lijnen waarmee deze categorie wordt weergegeven. + \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/LineCategoryThemeProperties.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/LineCategoryThemeProperties.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/LineCategoryThemeProperties.cs (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -0,0 +1,72 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using Core.Common.Gui.Attributes; +using Core.Common.Util.Attributes; +using Core.Components.Gis.Data; +using Core.Components.Gis.Style; +using Core.Components.Gis.Theme; +using Core.Plugins.Map.Properties; + +namespace Core.Plugins.Map.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class LineCategoryThemeProperties : CategoryThemeProperties + { + private readonly MapLineData mapData; + + /// + /// Creates a new instance of . + /// + /// The name of the attribute on which + /// is based on. + /// The theme to create the property info panel for. + /// The the belongs to. + /// Thrown when any parameter is null. + public LineCategoryThemeProperties(string attributeName, LineCategoryTheme categoryTheme, MapLineData mapData) + : base(attributeName, categoryTheme) + { + this.mapData = mapData; + } + + [PropertyOrder(2)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_Color_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.LineCategoryTheme_Color_Description))] + public Color Color { get; set; } + + [PropertyOrder(3)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_StrokeThickness_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.LineCategoryTheme_Width_Description))] + public int Width { get; set; } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapLineData_DashStyle_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.LineCategoryTheme_DashStyle_Description))] + public LineDashStyle DashStyle { get; set; } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/CategoryThemePropertiesTest.cs =================================================================== diff -u -rbbc00f2af5f96980c85a2e04a204affdceff0181 -rc7fcffe365d541dea0534be466c97f8ea70dc9c3 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/CategoryThemePropertiesTest.cs (.../CategoryThemePropertiesTest.cs) (revision bbc00f2af5f96980c85a2e04a204affdceff0181) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/CategoryThemePropertiesTest.cs (.../CategoryThemePropertiesTest.cs) (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -21,7 +21,6 @@ using System; using System.ComponentModel; -using System.Drawing; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using Core.Components.Gis.TestUtil; Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/LineCategoryThemePropertiesTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/LineCategoryThemePropertiesTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/LineCategoryThemePropertiesTest.cs (revision c7fcffe365d541dea0534be466c97f8ea70dc9c3) @@ -0,0 +1,175 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using System.Drawing; +using Core.Common.Base; +using Core.Common.Gui.Converters; +using Core.Common.TestUtil; +using Core.Common.Util; +using Core.Components.Gis.Data; +using Core.Components.Gis.Style; +using Core.Components.Gis.TestUtil; +using Core.Components.Gis.Theme; +using Core.Plugins.Map.PropertyClasses; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.Map.Test.PropertyClasses +{ + [TestFixture] + public class LineCategoryThemePropertiesTest + { + private const int colorPropertyIndex = 1; + private const int lineWidthPropertyIndex = 2; + private const int lineStylePropertyIndex = 3; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var categoryLineTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), + new LineStyle()); + + // Call + var properties = new LineCategoryThemeProperties(string.Empty, categoryLineTheme, new MapLineData("Name")); + + // Assert + Assert.IsInstanceOf(properties); + + TestHelper.AssertTypeConverter( + nameof(LineCategoryThemeProperties.Color)); + TestHelper.AssertTypeConverter( + nameof(LineCategoryThemeProperties.DashStyle)); + } + + [Test] + public void Constructor_Always_ReturnExpectedPropertyValues() + { + // Setup + const string attributeName = "AttributeName"; + var mapLineData = new MapLineData("Name"); + ValueCriterion valueCriterion = ValueCriterionTestFactory.CreateValueCriterion(); + var categoryLineTheme = new LineCategoryTheme(valueCriterion, new LineStyle()); + + var properties = new LineCategoryThemeProperties(attributeName, categoryLineTheme, mapLineData); + + // Assert + Assert.AreSame(categoryLineTheme, properties.Data); + + Assert.AreEqual(categoryLineTheme.Style.Color, properties.Color); + Assert.AreEqual(categoryLineTheme.Style.Width, properties.Width); + Assert.AreEqual(categoryLineTheme.Style.DashStyle, properties.DashStyle); + + string expectedValue = GetExpectedFormatExpression(valueCriterion, attributeName); + Assert.AreEqual(expectedValue, properties.Criterion); + } + + [Test] + public void Constructor_WithValidArguments_PropertiesHaveExpectedAttributeValues() + { + // Setup + var categoryLineTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), + new LineStyle()); + + // Call + var properties = new LineCategoryThemeProperties(string.Empty, categoryLineTheme, new MapLineData("Name")); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(4, dynamicProperties.Count); + const string styleCategory = "Stijl"; + + PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, + styleCategory, + "Kleur", + "De kleur van de lijnen waarmee deze categorie wordt weergegeven.", + true); + + PropertyDescriptor lineWidthProperty = dynamicProperties[lineWidthPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lineWidthProperty, + styleCategory, + "Lijndikte", + "De dikte van de lijnen waarmee deze categorie wordt weergegeven.", + true); + + PropertyDescriptor lineStyleProperty = dynamicProperties[lineStylePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lineStyleProperty, + styleCategory, + "Lijnstijl", + "De stijl van de lijnen waarmee deze categorie wordt weergegeven.", + true); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + var random = new Random(21); + + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()).Repeat.Times(3); + mocks.ReplayAll(); + + var mapData = new MapLineData("Name"); + mapData.Attach(observer); + + var categoryLineTheme = new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(), + new LineStyle()); + + var properties = new LineCategoryThemeProperties(string.Empty, categoryLineTheme, mapData); + + int width = random.Next(1, 48); + Color color = Color.FromKnownColor(random.NextEnumValue()); + var dashStyle = random.NextEnumValue(); + + // Call + properties.Width = width; + properties.Color = color; + properties.DashStyle = dashStyle; + + // Assert + LineStyle actualLineStyle = categoryLineTheme.Style; + Assert.AreEqual(width, actualLineStyle.Width); + Assert.AreEqual(color, actualLineStyle.Color); + Assert.AreEqual(dashStyle, actualLineStyle.DashStyle); + + mocks.VerifyAll(); + } + + private static string GetExpectedFormatExpression(ValueCriterion valueCriterion, string attributeName) + { + string valueCriterionValue = valueCriterion.Value; + switch (valueCriterion.ValueOperator) + { + case ValueCriterionOperator.EqualValue: + return $"{attributeName} = {valueCriterionValue}"; + case ValueCriterionOperator.UnequalValue: + return $"{attributeName} ≠ {valueCriterionValue}"; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file