Index: Core/Components/src/Core.Components.Gis/Data/MapPointData.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Components.Gis.Features; using Core.Components.Gis.Style; @@ -38,12 +39,32 @@ /// The name of the . /// Thrown when is /// null or only whitespace. - public MapPointData(string name) : base(name) {} + public MapPointData(string name) + : this(name, new PointStyle(Color.Black, 2, PointSymbol.Square)) {} /// + /// Creates a new instance of . + /// + /// The name of the . + /// + /// Thrown when is + /// null or only whitespace. + /// Thrown when + /// is null. + public MapPointData(string name, PointStyle style) : base(name) + { + if (style == null) + { + throw new ArgumentNullException(nameof(style)); + } + + Style = style; + } + + /// /// Gets or sets the style of the points. /// - public PointStyle Style { get; set; } + public PointStyle Style { get; private set; } /// /// This method validates newly set features. Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPointDataConverterTest.cs (.../MapPointDataConverterTest.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -158,10 +158,7 @@ var converter = new MapPointDataConverter(); var mapPointLayer = new MapPointLayer(); Color expectedColor = Color.FromKnownColor(color); - var mapPointData = new MapPointData("test") - { - Style = new PointStyle(expectedColor, width, pointStyle) - }; + var mapPointData = new MapPointData("test", new PointStyle(expectedColor, width, pointStyle)); // Call converter.ConvertLayerProperties(mapPointData, mapPointLayer); Index: Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPointDataLayerTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPointDataLayerTest.cs (.../MapPointDataLayerTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPointDataLayerTest.cs (.../MapPointDataLayerTest.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -55,7 +55,7 @@ public void Constructor_MapPointDataWithTestProperties_MapPointDataLayerCreatedAccordingly() { // Setup - var mapPointData = new MapPointData("Test name"); + var mapPointData = new MapPointData("Test name", new PointStyle(Color.AliceBlue, 4, PointSymbol.Circle)); SetMapPointDataTestProperties(mapPointData); @@ -73,7 +73,7 @@ public void Update_MapPointDataWithTestProperties_MapPointDataLayerUpdatedAccordingly() { // Setup - var mapPointData = new MapPointData("Test name"); + var mapPointData = new MapPointData("Test name", new PointStyle(Color.AliceBlue, 4, PointSymbol.Circle)); var mapPointDataLayer = new MapPointDataLayer(mapPointData); SetMapPointDataTestProperties(mapPointData); @@ -142,7 +142,6 @@ mapPointData.IsVisible = false; mapPointData.ShowLabels = true; mapPointData.SelectedMetaDataAttribute = "Name"; - mapPointData.Style = new PointStyle(Color.AliceBlue, 2, PointSymbol.Circle); mapPointData.Features = new[] { CreateTestMapFeature() @@ -156,12 +155,12 @@ Assert.IsTrue(mapPointDataLayer.ShowLabels); Assert.IsNotNull(mapPointDataLayer.LabelLayer); - Assert.AreEqual(string.Format("[{0}]", "2"), mapPointDataLayer.LabelLayer.Symbology.Categories[0].Expression); + Assert.AreEqual($"[{"2"}]", mapPointDataLayer.LabelLayer.Symbology.Categories[0].Expression); var firstSymbol = (SimpleSymbol) mapPointDataLayer.Symbolizer.Symbols[0]; Assert.AreEqual(Color.AliceBlue, firstSymbol.Color); - Assert.AreEqual(2, firstSymbol.Size.Width); - Assert.AreEqual(2, firstSymbol.Size.Height); + Assert.AreEqual(4, firstSymbol.Size.Width); + Assert.AreEqual(4, firstSymbol.Size.Height); Assert.AreEqual(PointShape.Ellipse, firstSymbol.PointShape); Assert.AreEqual(1, mapPointDataLayer.DataSet.Features.Count); @@ -179,7 +178,7 @@ var firstSymbol = (SimpleSymbol) mapPointDataLayer.Symbolizer.Symbols[0]; Assert.AreEqual(4, firstSymbol.Size.Width); Assert.AreEqual(4, firstSymbol.Size.Height); - Assert.AreEqual(PointShape.Rectangle, firstSymbol.PointShape); + Assert.AreEqual(PointShape.Ellipse, firstSymbol.PointShape); Assert.AreEqual(0, mapPointDataLayer.DataSet.Features.Count); } Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -21,12 +21,14 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using Core.Components.Gis.Data; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; using NUnit.Framework; namespace Core.Components.Gis.Test.Data @@ -44,6 +46,9 @@ Assert.AreEqual("test data", data.Name); Assert.IsEmpty(data.Features); Assert.IsInstanceOf(data); + Assert.AreEqual(Color.Black, data.Style.Color); + Assert.AreEqual(2, data.Style.Size); + Assert.AreEqual(PointSymbol.Square, data.Style.Symbol); } [Test] @@ -61,6 +66,33 @@ } [Test] + public void Constructor_StyleNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new MapPointData("test", null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("style", exception.ParamName); + } + + [Test] + public void Constructor_WithStyle_ExpectedValues() + { + // Setup + var style = new PointStyle(Color.Aqua, 3, PointSymbol.Circle); + + // Call + var data = new MapPointData("test data", style); + + // Assert + Assert.AreEqual("test data", data.Name); + Assert.IsEmpty(data.Features); + Assert.IsInstanceOf(data); + Assert.AreSame(style, data.Style); + } + + [Test] public void Features_SetValidNewValue_GetsNewValue() { // Setup Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs =================================================================== diff -u -rbc95cdad1e44d37f5792bd526408db32c018c291 -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs (.../MapPointDataProperties.cs) (revision bc95cdad1e44d37f5792bd526408db32c018c291) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs (.../MapPointDataProperties.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -46,15 +46,12 @@ { get { - return data.Style?.Color ?? Color.Transparent; + return data.Style.Color; } set { - if (data.Style != null) - { - data.Style.Color = value; - data.NotifyObservers(); - } + data.Style.Color = value; + data.NotifyObservers(); } } @@ -66,9 +63,10 @@ { get { - return data.Style?.Color.ToString() ?? string.Empty; + return data.Style.Color.ToString(); } } + [PropertyOrder(7)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapPointData_StrokeThickness_DisplayName))] @@ -77,9 +75,10 @@ { get { - return data.Style?.Size ?? 0; + return data.Style.Size; } } + [PropertyOrder(8)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapPointData_Size_DisplayName))] @@ -88,7 +87,7 @@ { get { - return data.Style?.Size ?? 0; + return data.Style.Size; } } @@ -100,7 +99,7 @@ { get { - return data.Style?.Symbol.ToString() ?? string.Empty; + return data.Style.Symbol.ToString(); } } Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs =================================================================== diff -u -rbc95cdad1e44d37f5792bd526408db32c018c291 -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision bc95cdad1e44d37f5792bd526408db32c018c291) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -117,17 +117,14 @@ } [Test] - public void Data_SetNewMapPointDataInstanceWithStyle_ReturnCorrectPropertyValues() + public void Data_SetNewMapPointDataInstance_ReturnCorrectPropertyValues() { // Setup Color color = Color.Aqua; const int size = 4; const PointSymbol symbol = PointSymbol.Circle; - var mapPointData = new MapPointData("Test") - { - Style = new PointStyle(color, size, symbol) - }; + var mapPointData = new MapPointData("Test", new PointStyle(color, size, symbol)); var properties = new MapPointDataProperties(); // Call @@ -146,29 +143,6 @@ } [Test] - public void Data_SetNewMapPointDataInstanceWithoutStyle_ReturnCorrectPropertyValues() - { - // Setup - var mapPointData = new MapPointData("Test"); - var properties = new MapPointDataProperties(); - - // Call - properties.Data = mapPointData; - - // Assert - Assert.AreEqual(mapPointData.ShowLabels, properties.ShowLabels); - Assert.AreEqual(string.Empty, properties.SelectedMetaDataAttribute.MetaDataAttribute); - Assert.AreEqual(mapPointData.MetaData, properties.GetAvailableMetaDataAttributes()); - - Assert.AreEqual(Color.Transparent, properties.Color); - Assert.AreEqual(string.Empty, properties.StrokeColor); - Assert.AreEqual(0, properties.StrokeThickness); - Assert.AreEqual(0, properties.Size); - Assert.AreEqual(string.Empty, properties.Symbol); - } - - - [Test] public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup @@ -178,10 +152,7 @@ observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); mocks.ReplayAll(); - var mapPointData = new MapPointData("Test") - { - Style = new PointStyle(Color.AliceBlue, 3, PointSymbol.Circle) - }; + var mapPointData = new MapPointData("Test", new PointStyle(Color.AliceBlue, 3, PointSymbol.Circle)); mapPointData.Attach(observerMock); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs =================================================================== diff -u -rf1f94637a6b45b394493bf16a078b317c02d329b -r7fc5e21f72a83b37ad5e4daca553fca84fe140ab --- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs (.../RingtoetsMapDataFactory.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs (.../RingtoetsMapDataFactory.cs) (revision 7fc5e21f72a83b37ad5e4daca553fca84fe140ab) @@ -63,9 +63,9 @@ /// The created . public static MapPointData CreateHydraulicBoundaryLocationsMapData() { - return new MapPointData(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName) + return new MapPointData(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, + new PointStyle(Color.DarkBlue, smallPointSize, PointSymbol.Circle)) { - Style = new PointStyle(Color.DarkBlue, smallPointSize, PointSymbol.Circle), ShowLabels = true, SelectedMetaDataAttribute = Resources.MetaData_Name }; @@ -92,10 +92,8 @@ { string mapDataName = $"{Resources.FailureMechanism_Sections_DisplayName} ({Resources.FailureMechanismSections_StartPoints_DisplayName})"; - return new MapPointData(mapDataName) - { - Style = new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle) - }; + return new MapPointData(mapDataName, + new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle)); } /// @@ -106,10 +104,8 @@ { string mapDataName = $"{Resources.FailureMechanism_Sections_DisplayName} ({Resources.FailureMechanismSections_EndPoints_DisplayName})"; - return new MapPointData(mapDataName) - { - Style = new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle) - }; + return new MapPointData(mapDataName, + new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle)); } /// @@ -144,9 +140,9 @@ /// The created . public static MapPointData CreateStructuresMapData() { - return new MapPointData(Resources.StructuresCollection_DisplayName) + return new MapPointData(Resources.StructuresCollection_DisplayName, + new PointStyle(Color.DarkSeaGreen, largePointSize, PointSymbol.Square)) { - Style = new PointStyle(Color.DarkSeaGreen, largePointSize, PointSymbol.Square), SelectedMetaDataAttribute = Resources.MetaData_Name }; }