Index: Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj
===================================================================
diff -u -r271bd5ffd4d61da4324eb50957f062b14c4c6958 -r344646a09ee37435dd7b82f80e69f62c0f1bd128
--- Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision 271bd5ffd4d61da4324eb50957f062b14c4c6958)
+++ Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision 344646a09ee37435dd7b82f80e69f62c0f1bd128)
@@ -41,6 +41,7 @@
+
Index: Core/Components/src/Core.Components.Charting/Data/ChartDataCollectionExtensions.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Data/ChartDataCollectionExtensions.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Data/ChartDataCollectionExtensions.cs (revision 344646a09ee37435dd7b82f80e69f62c0f1bd128)
@@ -0,0 +1,61 @@
+// 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.Collections.Generic;
+
+namespace Core.Components.Charting.Data
+{
+ ///
+ /// Exentions methods for .
+ ///
+ public static class ChartDataCollectionExtensions
+ {
+ ///
+ /// Gets all the recursively in the given .
+ ///
+ /// The collection to get all from.
+ /// An of .
+ /// Thrown when is null.
+ public static IEnumerable GetChartDataRecursively(this ChartDataCollection chartDataCollection)
+ {
+ if (chartDataCollection == null)
+ {
+ throw new ArgumentNullException(nameof(chartDataCollection));
+ }
+ var chartDataList = new List();
+
+ foreach (ChartData chartData in chartDataCollection.Collection)
+ {
+ var nestedChartDataCollection = chartData as ChartDataCollection;
+ if (nestedChartDataCollection != null)
+ {
+ chartDataList.AddRange(GetChartDataRecursively(nestedChartDataCollection));
+ continue;
+ }
+
+ chartDataList.Add(chartData);
+ }
+
+ return chartDataList;
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs
===================================================================
diff -u -r364dfcde1c00a33c19ab33f47373d862dae87067 -r344646a09ee37435dd7b82f80e69f62c0f1bd128
--- Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 364dfcde1c00a33c19ab33f47373d862dae87067)
+++ Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 344646a09ee37435dd7b82f80e69f62c0f1bd128)
@@ -157,6 +157,14 @@
}
}
+ protected override void Dispose(bool disposing)
+ {
+ plotView.Dispose();
+ chartDataCollectionObserver.Dispose();
+
+ base.Dispose(disposing);
+ }
+
///
/// Defines the area taken up by the visible map-data based on the provided map-data.
///
@@ -217,14 +225,6 @@
return envelope;
}
- protected override void Dispose(bool disposing)
- {
- plotView.Dispose();
- chartDataCollectionObserver.Dispose();
-
- base.Dispose(disposing);
- }
-
private void InitializePlotView()
{
plotView = new LinearPlotView
@@ -242,28 +242,9 @@
Controls.Add(plotView);
}
- private static IEnumerable GetChartDataRecursively(ChartDataCollection chartDataCollection)
- {
- var chartDataList = new List();
-
- foreach (ChartData chartData in chartDataCollection.Collection)
- {
- var nestedChartDataCollection = chartData as ChartDataCollection;
- if (nestedChartDataCollection != null)
- {
- chartDataList.AddRange(GetChartDataRecursively(nestedChartDataCollection));
- continue;
- }
-
- chartDataList.Add(chartData);
- }
-
- return chartDataList;
- }
-
private void HandleChartDataCollectionChange()
{
- List chartDataThatShouldBeDrawn = GetChartDataRecursively(Data).ToList();
+ List chartDataThatShouldBeDrawn = Data.GetChartDataRecursively().ToList();
Dictionary drawnChartDataLookup = drawnChartDataList.ToDictionary(dcd => dcd.ChartData, dcd => dcd);
DrawMissingChartDataOnCollectionChange(chartDataThatShouldBeDrawn, drawnChartDataLookup);
Index: Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj
===================================================================
diff -u -r271bd5ffd4d61da4324eb50957f062b14c4c6958 -r344646a09ee37435dd7b82f80e69f62c0f1bd128
--- Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 271bd5ffd4d61da4324eb50957f062b14c4c6958)
+++ Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 344646a09ee37435dd7b82f80e69f62c0f1bd128)
@@ -58,6 +58,7 @@
+
Index: Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionExtensionsTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionExtensionsTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionExtensionsTest.cs (revision 344646a09ee37435dd7b82f80e69f62c0f1bd128)
@@ -0,0 +1,71 @@
+// 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.Linq;
+using Core.Components.Charting.Data;
+using NUnit.Framework;
+
+namespace Core.Components.Charting.Test.Data
+{
+ [TestFixture]
+ public class ChartDataCollectionExtensionsTest
+ {
+ [Test]
+ public void GetFeatureBasedChartDataRecursively_ChartDataCollectionNull_ThrowArgumentNullException()
+ {
+ // Setup
+ ChartDataCollection collection = null;
+
+ // Call
+ TestDelegate test = () => collection.GetChartDataRecursively();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("chartDataCollection", exception.ParamName);
+ }
+
+ [Test]
+ public void GetFeatureBasedChartDataRecursively_CollectionWithNestedData_ReturnAllFeatureBasedChartData()
+ {
+ // Setup
+ var line = new ChartLineData("line");
+ var polygon = new ChartAreaData("polygon");
+ var nestedCollection = new ChartDataCollection("nested");
+ nestedCollection.Add(line);
+ nestedCollection.Add(polygon);
+
+ var collection = new ChartDataCollection("test");
+ var point = new ChartPointData("point");
+ collection.Add(point);
+ collection.Add(nestedCollection);
+
+ // Call
+ ChartData[] featureBasedChartDatas = collection.GetChartDataRecursively().ToArray();
+
+ // Assert
+ Assert.AreEqual(3, featureBasedChartDatas.Length);
+ Assert.IsInstanceOf(featureBasedChartDatas[0]);
+ Assert.IsInstanceOf(featureBasedChartDatas[1]);
+ Assert.IsInstanceOf(featureBasedChartDatas[2]);
+ }
+ }
+}
\ No newline at end of file