Index: Core/Plugins/src/Core.Plugins.Map/Converters/DashStyleConverter.cs
===================================================================
diff -u
--- Core/Plugins/src/Core.Plugins.Map/Converters/DashStyleConverter.cs (revision 0)
+++ Core/Plugins/src/Core.Plugins.Map/Converters/DashStyleConverter.cs (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -0,0 +1,98 @@
+// Copyright (C) Stichting Deltares 2017. 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.Drawing2D;
+using System.Globalization;
+using Core.Common.Utils;
+using Core.Plugins.Map.Properties;
+
+namespace Core.Plugins.Map.Converters
+{
+ ///
+ /// A type converter to convert objects to and from various other representations.
+ ///
+ public class DashStyleConverter : EnumTypeConverter
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// A that represents the type of enumeration to associate with this dash style converter.
+ public DashStyleConverter(Type type) : base(type) {}
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (value is DashStyle)
+ {
+ switch ((DashStyle) value)
+ {
+ case DashStyle.Solid:
+ return Resources.DashStyle_Solid_DisplayName;
+ case DashStyle.Dash:
+ return Resources.DashStyle_Dash_DisplayName;
+ case DashStyle.Dot:
+ return Resources.DashStyle_Dot_DisplayName;
+ case DashStyle.DashDot:
+ return Resources.DashStyle_DashDot_DisplayName;
+ case DashStyle.DashDotDot:
+ return Resources.DashStyle_DashDotDot_DisplayName;
+ case DashStyle.Custom:
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(value), value, null);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var valueLiteral = value as string;
+ if (valueLiteral != null)
+ {
+ if (valueLiteral == Resources.DashStyle_Solid_DisplayName)
+ {
+ return DashStyle.Solid;
+ }
+ if (valueLiteral == Resources.DashStyle_Dash_DisplayName)
+ {
+ return DashStyle.Dash;
+ }
+ if (valueLiteral == Resources.DashStyle_Dot_DisplayName)
+ {
+ return DashStyle.Dot;
+ }
+ if (valueLiteral == Resources.DashStyle_DashDot_DisplayName)
+ {
+ return DashStyle.DashDot;
+ }
+ if (valueLiteral == Resources.DashStyle_DashDotDot_DisplayName)
+ {
+ return DashStyle.DashDotDot;
+ }
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj
===================================================================
diff -u -rbc95cdad1e44d37f5792bd526408db32c018c291 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj (.../Core.Plugins.Map.csproj) (revision bc95cdad1e44d37f5792bd526408db32c018c291)
+++ Core/Plugins/src/Core.Plugins.Map/Core.Plugins.Map.csproj (.../Core.Plugins.Map.csproj) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -69,6 +69,7 @@
Resources.resx
+
Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs
===================================================================
diff -u -r7b372ed3506cd00bcf09c6c026e2bf5783868f74 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7b372ed3506cd00bcf09c6c026e2bf5783868f74)
+++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -128,6 +128,51 @@
}
///
+ /// Looks up a localized string similar to Onderbroken.
+ ///
+ public static string DashStyle_Dash_DisplayName {
+ get {
+ return ResourceManager.GetString("DashStyle_Dash_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Streep-stip.
+ ///
+ public static string DashStyle_DashDot_DisplayName {
+ get {
+ return ResourceManager.GetString("DashStyle_DashDot_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Streep-stip-stip.
+ ///
+ public static string DashStyle_DashDotDot_DisplayName {
+ get {
+ return ResourceManager.GetString("DashStyle_DashDotDot_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Gestippeld.
+ ///
+ public static string DashStyle_Dot_DisplayName {
+ get {
+ return ResourceManager.GetString("DashStyle_Dot_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Doorgetrokken.
+ ///
+ public static string DashStyle_Solid_DisplayName {
+ get {
+ return ResourceManager.GetString("DashStyle_Solid_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Toont de eigenschap op basis waarvan labels worden weergegeven op deze kaartlaag..
///
public static string FeatureBasedMapdata_SelectedMetaDataAttribute_Description {
Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx
===================================================================
diff -u -r7b372ed3506cd00bcf09c6c026e2bf5783868f74 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 7b372ed3506cd00bcf09c6c026e2bf5783868f74)
+++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -316,4 +316,19 @@
Lijndikte
+
+ Streep-stip-stip
+
+
+ Streep-stip
+
+
+ Onderbroken
+
+
+ Gestippeld
+
+
+ Doorgetrokken
+
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs
===================================================================
diff -u -r76b76c41226d2981a674fb5a25b817931f2a1313 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs (.../MapLineDataProperties.cs) (revision 76b76c41226d2981a674fb5a25b817931f2a1313)
+++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs (.../MapLineDataProperties.cs) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -24,7 +24,6 @@
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using Core.Common.Gui.Attributes;
-using Core.Common.Utils;
using Core.Common.Utils.Attributes;
using Core.Components.Gis.Data;
using Core.Plugins.Map.Converters;
@@ -78,7 +77,7 @@
[ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))]
[ResourcesDisplayName(typeof(Resources), nameof(Resources.MapLineData_DashStyle_DisplayName))]
[ResourcesDescription(typeof(Resources), nameof(Resources.MapLineData_DashStyle_Description))]
- [TypeConverter(typeof(EnumTypeConverter))]
+ [TypeConverter(typeof(DashStyleConverter))]
public DashStyle DashStyle
{
get
Index: Core/Plugins/test/Core.Plugins.Map.Test/Converters/DashStyleConverterTest.cs
===================================================================
diff -u
--- Core/Plugins/test/Core.Plugins.Map.Test/Converters/DashStyleConverterTest.cs (revision 0)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Converters/DashStyleConverterTest.cs (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -0,0 +1,168 @@
+// Copyright (C) Stichting Deltares 2017. 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.Drawing2D;
+using System.Globalization;
+using Core.Common.Utils;
+using Core.Plugins.Map.Converters;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Core.Plugins.Map.Test.Converters
+{
+ [TestFixture]
+ public class DashStyleConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void ConvertTo_ValueNoDashStyle_ThrowNotSupportedException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ var originalValue = new object();
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ TestDelegate test = () => converter.ConvertTo(context, CultureInfo.InvariantCulture, originalValue, typeof(DashStyle));
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DashStyle.Solid, "Doorgetrokken")]
+ [TestCase(DashStyle.Dash, "Onderbroken")]
+ [TestCase(DashStyle.Dot, "Gestippeld")]
+ [TestCase(DashStyle.DashDot, "Streep-stip")]
+ [TestCase(DashStyle.DashDotDot, "Streep-stip-stip")]
+ public void ConvertTo_ValueValidDashStyle_ReturnStringValue(DashStyle originalValue, string expectedConvertedValue)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ object converterdValue = converter.ConvertTo(context, CultureInfo.InvariantCulture, originalValue, typeof(DashStyle));
+
+ // Assert
+ Assert.AreEqual(expectedConvertedValue, converterdValue);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ConvertTo_InvalidDashStyleValue_ThrowArgumentOutOfRangeException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ const DashStyle originalValue = (DashStyle) 100;
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ TestDelegate test = () => converter.ConvertTo(context, CultureInfo.InvariantCulture, originalValue, typeof(DashStyle));
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ConvertFrom_ValueNoString_ThrowNotSupportedException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ var originalValue = new object();
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ TestDelegate test = () => converter.ConvertFrom(context, CultureInfo.InvariantCulture, originalValue);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("Doorgetrokken", DashStyle.Solid)]
+ [TestCase("Onderbroken", DashStyle.Dash)]
+ [TestCase("Gestippeld", DashStyle.Dot)]
+ [TestCase("Streep-stip", DashStyle.DashDot)]
+ [TestCase("Streep-stip-stip", DashStyle.DashDotDot)]
+ public void ConvertFrom_ValidString_ReturnDashStyle(string stringValue, DashStyle expectedDashStyle)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ object converterdValue = converter.ConvertFrom(context, CultureInfo.InvariantCulture, stringValue);
+
+ // Assert
+ Assert.AreEqual(expectedDashStyle, converterdValue);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ConvertFrom_InvalidStringValue_ThrowFormatException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = mocks.Stub();
+ mocks.ReplayAll();
+
+ const string originalValue = "test";
+ var converter = new DashStyleConverter(typeof(DashStyle));
+
+ // Call
+ TestDelegate test = () => converter.ConvertFrom(context, CultureInfo.InvariantCulture, originalValue);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.Map.Test/Core.Plugins.Map.Test.csproj
===================================================================
diff -u -rbc95cdad1e44d37f5792bd526408db32c018c291 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/test/Core.Plugins.Map.Test/Core.Plugins.Map.Test.csproj (.../Core.Plugins.Map.Test.csproj) (revision bc95cdad1e44d37f5792bd526408db32c018c291)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Core.Plugins.Map.Test.csproj (.../Core.Plugins.Map.Test.csproj) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -83,6 +83,7 @@
Properties\GlobalAssembly.cs
+
Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs
===================================================================
diff -u -r76b76c41226d2981a674fb5a25b817931f2a1313 -r899cae178642faba04c628db05a792b657b6d979
--- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision 76b76c41226d2981a674fb5a25b817931f2a1313)
+++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision 899cae178642faba04c628db05a792b657b6d979)
@@ -92,6 +92,7 @@
"De dikte van de lijnen waarmee deze kaartlaag wordt weergegeven.");
PropertyDescriptor styleProperty = dynamicProperties[stylePropertyIndex];
+ Assert.IsInstanceOf(styleProperty.Converter);
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleProperty,
"Stijl",
"Lijnstijl",