Index: Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs (.../ChartPointStyle.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs (.../ChartPointStyle.cs) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -46,28 +46,28 @@ } /// - /// Gets the point color. + /// Gets or sets the point color. /// - public Color Color { get; private set; } + public Color Color { get; set; } /// - /// Gets the point stroke color. + /// Gets or sets the point stroke color. /// - public Color StrokeColor { get; private set; } + public Color StrokeColor { get; set; } /// - /// Gets the point size. + /// Gets or sets the point size. /// - public double Size { get; private set; } + public int Size { get; set; } /// - /// Gets the point stroke thickness. + /// Gets or sets the point stroke thickness. /// - public int StrokeThickness { get; private set; } + public int StrokeThickness { get; set; } /// - /// Gets the point symbol. + /// Gets or sets the point symbol. /// - public ChartPointSymbol Symbol { get; private set; } + public ChartPointSymbol Symbol { get; set; } } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.Designer.cs =================================================================== diff -u -rb4535eabcb8d131b00bde746e21ef201b1ba4e80 -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b4535eabcb8d131b00bde746e21ef201b1ba4e80) +++ Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -101,6 +101,42 @@ } /// + /// Looks up a localized string similar to Stijl. + /// + public static string Categories_Styling { + get { + return ResourceManager.GetString("Categories_Styling", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kleur. + /// + public static string ChartData_Color_DisplayName { + get { + return ResourceManager.GetString("ChartData_Color_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lijnkleur. + /// + public static string ChartData_StrokeColor_DisplayName { + get { + return ResourceManager.GetString("ChartData_StrokeColor_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lijndikte. + /// + public static string ChartData_StrokeThickness_DisplayName { + get { + return ResourceManager.GetString("ChartData_StrokeThickness_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Geeft aan of de gegevensreeks wordt weergegeven.. /// public static string ChartDataProperties_IsVisible_Description { @@ -248,6 +284,69 @@ } /// + /// Looks up a localized string similar to De kleur van de symbolen waarmee deze gegevensreeks wordt weergegeven.. + /// + public static string ChartPointData_Color_Description { + get { + return ResourceManager.GetString("ChartPointData_Color_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De grootte van de symbolen waarmee deze gegevensreeks wordt weergegeven.. + /// + public static string ChartPointData_Size_Description { + get { + return ResourceManager.GetString("ChartPointData_Size_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Grootte. + /// + public static string ChartPointData_Size_DisplayName { + get { + return ResourceManager.GetString("ChartPointData_Size_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De kleur van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven.. + /// + public static string ChartPointData_StrokeColor_Description { + get { + return ResourceManager.GetString("ChartPointData_StrokeColor_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De dikte van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven.. + /// + public static string ChartPointData_StrokeThickness_Description { + get { + return ResourceManager.GetString("ChartPointData_StrokeThickness_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Het symbool waarmee deze gegevensreeks wordt weergegeven.. + /// + public static string ChartPointData_Symbol_Description { + get { + return ResourceManager.GetString("ChartPointData_Symbol_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Symbool. + /// + public static string ChartPointData_Symbol_DisplayName { + get { + return ResourceManager.GetString("ChartPointData_Symbol_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Grafiek. /// public static string General_Chart { Index: Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.resx =================================================================== diff -u -rb4535eabcb8d131b00bde746e21ef201b1ba4e80 -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.resx (.../Resources.resx) (revision b4535eabcb8d131b00bde746e21ef201b1ba4e80) +++ Core/Plugins/src/Core.Plugins.Chart/Properties/Resources.resx (.../Resources.resx) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -223,4 +223,37 @@ Vlakken + + Stijl + + + Kleur + + + Lijnkleur + + + Lijndikte + + + De kleur van de symbolen waarmee deze gegevensreeks wordt weergegeven. + + + De grootte van de symbolen waarmee deze gegevensreeks wordt weergegeven. + + + Grootte + + + De kleur van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven. + + + De dikte van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven. + + + Het symbool waarmee deze gegevensreeks wordt weergegeven. + + + Symbool + \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.Chart/PropertyClasses/ChartPointDataProperties.cs =================================================================== diff -u -rb4535eabcb8d131b00bde746e21ef201b1ba4e80 -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Plugins/src/Core.Plugins.Chart/PropertyClasses/ChartPointDataProperties.cs (.../ChartPointDataProperties.cs) (revision b4535eabcb8d131b00bde746e21ef201b1ba4e80) +++ Core/Plugins/src/Core.Plugins.Chart/PropertyClasses/ChartPointDataProperties.cs (.../ChartPointDataProperties.cs) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -19,7 +19,16 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; +using Core.Common.Gui.UITypeEditors; +using Core.Common.Utils; +using Core.Common.Utils.Attributes; using Core.Components.Charting.Data; +using Core.Components.Charting.Styles; using Core.Plugins.Chart.Properties; namespace Core.Plugins.Chart.PropertyClasses @@ -29,6 +38,96 @@ /// public class ChartPointDataProperties : ChartDataProperties { + [PropertyOrder(3)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ChartData_Color_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ChartPointData_Color_Description))] + [Editor(typeof(ColorEditor), typeof(UITypeEditor))] + [TypeConverter(typeof(ColorTypeConverter))] + public Color Color + { + get + { + return data.Style.Color; + } + set + { + data.Style.Color = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ChartData_StrokeColor_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ChartPointData_StrokeColor_Description))] + [Editor(typeof(ColorEditor), typeof(UITypeEditor))] + [TypeConverter(typeof(ColorTypeConverter))] + public Color StrokeColor + { + get + { + return data.Style.StrokeColor; + } + set + { + data.Style.StrokeColor = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(5)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ChartData_StrokeThickness_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ChartPointData_StrokeThickness_Description))] + public int StrokeThickness + { + get + { + return data.Style.StrokeThickness; + } + set + { + data.Style.StrokeThickness = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(6)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ChartPointData_Size_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ChartPointData_Size_Description))] + public int Size + { + get + { + return data.Style.Size; + } + set + { + data.Style.Size = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(7)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ChartPointData_Symbol_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ChartPointData_Symbol_Description))] + [TypeConverter(typeof(EnumTypeConverter))] + public ChartPointSymbol Symbol + { + get + { + return data.Style.Symbol; + } + set + { + data.Style.Symbol = value; + data.NotifyObservers(); + } + } + public override string Type { get Index: Core/Plugins/test/Core.Plugins.Chart.Test/PropertyClasses/ChartPointDataPropertiesTest.cs =================================================================== diff -u -rb4535eabcb8d131b00bde746e21ef201b1ba4e80 -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Plugins/test/Core.Plugins.Chart.Test/PropertyClasses/ChartPointDataPropertiesTest.cs (.../ChartPointDataPropertiesTest.cs) (revision b4535eabcb8d131b00bde746e21ef201b1ba4e80) +++ Core/Plugins/test/Core.Plugins.Chart.Test/PropertyClasses/ChartPointDataPropertiesTest.cs (.../ChartPointDataPropertiesTest.cs) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -19,15 +19,29 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.ComponentModel; +using System.Drawing; +using Core.Common.Base; +using Core.Common.Gui.Converters; +using Core.Common.TestUtil; +using Core.Common.Utils; using Core.Components.Charting.Data; +using Core.Components.Charting.Styles; using Core.Plugins.Chart.PropertyClasses; using NUnit.Framework; +using Rhino.Mocks; namespace Core.Plugins.Chart.Test.PropertyClasses { [TestFixture] public class ChartPointDataPropertiesTest { + private const int colorPropertyIndex = 3; + private const int strokeColorPropertyIndex = 4; + private const int strokeThicknessPropertyIndex = 5; + private const int sizePropertyIndex = 6; + private const int symbolPropertyIndex = 7; + [Test] public void Constructor_ExpectedValues() { @@ -39,5 +53,120 @@ Assert.IsNull(properties.Data); Assert.AreEqual("Punten", properties.Type); } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + { + // Setup + var chartPointData = new ChartPointData("Test"); + + // Call + var properties = new ChartPointDataProperties + { + Data = chartPointData + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(8, dynamicProperties.Count); + + PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex]; + Assert.IsInstanceOf(colorProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, + "Stijl", + "Kleur", + "De kleur van de symbolen waarmee deze gegevensreeks wordt weergegeven."); + + PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex]; + Assert.IsInstanceOf(colorProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, + "Stijl", + "Lijnkleur", + "De kleur van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven."); + + PropertyDescriptor strokeThicknessProperty = dynamicProperties[strokeThicknessPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeThicknessProperty, + "Stijl", + "Lijndikte", + "De dikte van de lijn van de symbolen waarmee deze gegevensreeks wordt weergegeven."); + + PropertyDescriptor sizeProperty = dynamicProperties[sizePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sizeProperty, + "Stijl", + "Grootte", + "De grootte van de symbolen waarmee deze gegevensreeks wordt weergegeven."); + + PropertyDescriptor symbolProperty = dynamicProperties[symbolPropertyIndex]; + Assert.IsInstanceOf(symbolProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(symbolProperty, + "Stijl", + "Symbool", + "Het symbool waarmee deze gegevensreeks wordt weergegeven."); + } + + [Test] + public void Data_SetNewChartPointDataInstance_ReturnCorrectPropertyValues() + { + // Setup + Color color = Color.Aqua; + Color strokeColor = Color.Crimson; + const int size = 4; + const int strokeThickness = 2; + const ChartPointSymbol symbol = ChartPointSymbol.Circle; + + var chartPointData = new ChartPointData("Test", new ChartPointStyle(color, size, strokeColor, strokeThickness, symbol)); + var properties = new ChartPointDataProperties(); + + // Call + properties.Data = chartPointData; + + // Assert + Assert.AreEqual(color, properties.Color); + Assert.AreEqual(strokeColor, properties.StrokeColor); + Assert.AreEqual(strokeThickness, properties.StrokeThickness); + Assert.AreEqual(size, properties.Size); + Assert.AreEqual(symbol, properties.Symbol); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + const int numberOfChangedProperties = 5; + var mocks = new MockRepository(); + var observerMock = mocks.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + mocks.ReplayAll(); + + var chartPointData = new ChartPointData("Test", new ChartPointStyle(Color.AliceBlue, 3, Color.Fuchsia, 1, ChartPointSymbol.Circle)); + + chartPointData.Attach(observerMock); + + var properties = new ChartPointDataProperties + { + Data = chartPointData + }; + + Color newColor = Color.Blue; + Color newStrokeColor = Color.Aquamarine; + const int newSize = 6; + const ChartPointSymbol newSymbol = ChartPointSymbol.Diamond; + const int newStrokeThickness = 4; + + // Call + properties.Color = newColor; + properties.Size = newSize; + properties.Symbol = newSymbol; + properties.StrokeColor = newStrokeColor; + properties.StrokeThickness = newStrokeThickness; + + // Assert + Assert.AreEqual(newColor, chartPointData.Style.Color); + Assert.AreEqual(newSize, chartPointData.Style.Size); + Assert.AreEqual(newSymbol, chartPointData.Style.Symbol); + Assert.AreEqual(newStrokeColor, chartPointData.Style.StrokeColor); + Assert.AreEqual(newStrokeThickness, chartPointData.Style.StrokeThickness); + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs =================================================================== diff -u -rb2cfd1d6f0d22011df44df97e970c9aa74e6ca58 -r1d6e305abb72304f556ba1c2da718de350ca62eb --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision b2cfd1d6f0d22011df44df97e970c9aa74e6ca58) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision 1d6e305abb72304f556ba1c2da718de350ca62eb) @@ -30,7 +30,6 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; -using Core.Plugins.Map.Converters; using Core.Plugins.Map.PropertyClasses; using NUnit.Framework; using Rhino.Mocks;