Index: Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs
===================================================================
diff -u -r937f4ce305957701b583772d392ac9957338199f -r912654844174f5787a10b53cae061302e14fe4f1
--- Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs (.../ChartDataCollection.cs) (revision 937f4ce305957701b583772d392ac9957338199f)
+++ Core/Components/src/Core.Components.Charting/Data/ChartDataCollection.cs (.../ChartDataCollection.cs) (revision 912654844174f5787a10b53cae061302e14fe4f1)
@@ -77,6 +77,30 @@
Replace(oldElement, newElement, List);
}
+ ///
+ /// Inserts the given element in the list of on the given position.
+ ///
+ /// The position to insert the element on.
+ /// The element to insert.
+ /// Thrown when is null.
+ public void Insert(int position, ChartData elementToInsert)
+ {
+ if (elementToInsert == null)
+ {
+ throw new ArgumentNullException("elementToInsert", "An element cannot be null when adding it to the collection.");
+ }
+ List.Insert(position, elementToInsert);
+ }
+
+ ///
+ /// Removes the given element from the list of .
+ ///
+ /// The element to remove.
+ public void Remove(ChartData elementToRemove)
+ {
+ List.Remove(elementToRemove);
+ }
+
private void Replace(ChartData oldElement, ChartData newElement, IList listToCheck)
{
if (newElement == null)
@@ -88,7 +112,7 @@
{
throw new ArgumentNullException("oldElement", "A null element cannot be replaced. Use Add instead.");
}
-
+
for (var i = 0; i < listToCheck.Count; i++)
{
if (listToCheck[i].Equals(oldElement))
@@ -108,14 +132,5 @@
}
}
}
-
- ///
- /// Removes the given element from the list of .
- ///
- /// The element to remove.
- public void Remove(ChartData elementToRemove)
- {
- List.Remove(elementToRemove);
- }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs
===================================================================
diff -u -r937f4ce305957701b583772d392ac9957338199f -r912654844174f5787a10b53cae061302e14fe4f1
--- Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs (.../ChartDataCollectionTest.cs) (revision 937f4ce305957701b583772d392ac9957338199f)
+++ Core/Components/test/Core.Components.Charting.Test/Data/ChartDataCollectionTest.cs (.../ChartDataCollectionTest.cs) (revision 912654844174f5787a10b53cae061302e14fe4f1)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Geometry;
using Core.Common.TestUtil;
@@ -97,8 +98,9 @@
data.Add(objectToAdd);
// Assert
- Assert.AreEqual(1, data.List.Count);
- Assert.AreSame(objectToAdd, data.List.First());
+ var chartData = data.List.ToList();
+ Assert.AreEqual(1, chartData.Count);
+ Assert.AreSame(objectToAdd, chartData.First());
}
[Test]
@@ -223,6 +225,41 @@
}
[Test]
+ public void Insert_NotNull_InsertsElementToCollectionAtGivenPosition()
+ {
+ // Setup
+ TestChartData chartData = new TestChartData("test");
+ var data = new ChartDataCollection(new List{ chartData }, "test");
+ var objectToAdd = new ChartLineData(Enumerable.Empty(), "test");
+
+ // Precondition
+ Assert.AreEqual(1, data.List.Count);
+ Assert.AreSame(chartData, data.List[0]);
+
+ // Call
+ data.Insert(0, objectToAdd);
+
+ // Assert
+ Assert.AreEqual(2, data.List.Count);
+ Assert.AreSame(objectToAdd, data.List[0]);
+ Assert.AreSame(chartData, data.List[1]);
+ }
+
+ [Test]
+ public void Insert_ElementNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var list = Enumerable.Empty().ToList();
+ var data = new ChartDataCollection(list, "test");
+
+ // Call
+ TestDelegate call = () => data.Insert(0, null);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "An element cannot be null when adding it to the collection.");
+ }
+
+ [Test]
public void Remove_ExistingElement_RemovesElement()
{
// Setup
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs
===================================================================
diff -u -r8ca6a4ce40d75a96784c6ce8839e06e0b11052da -r912654844174f5787a10b53cae061302e14fe4f1
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs (.../ChartDataCollectionConverterTest.cs) (revision 8ca6a4ce40d75a96784c6ce8839e06e0b11052da)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataCollectionConverterTest.cs (.../ChartDataCollectionConverterTest.cs) (revision 912654844174f5787a10b53cae061302e14fe4f1)
@@ -94,8 +94,8 @@
var areaData = new ChartAreaData(pointsArea, "test data");
var lineData = new ChartLineData(pointsLine, "test data");
- collectionData.List.Add(areaData);
- collectionData.List.Add(lineData);
+ collectionData.Add(areaData);
+ collectionData.Add(lineData);
// Call
var series = converter.Convert(collectionData);
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj
===================================================================
diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r912654844174f5787a10b53cae061302e14fe4f1
--- Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision 912654844174f5787a10b53cae061302e14fe4f1)
@@ -74,6 +74,7 @@
+
True
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs
===================================================================
diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -r912654844174f5787a10b53cae061302e14fe4f1
--- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision 912654844174f5787a10b53cae061302e14fe4f1)
@@ -19,13 +19,15 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Controls.Views;
using Core.Components.Charting.Data;
using Core.Components.OxyPlot.Forms;
+using Core.Plugins.OxyPlot.PresentationObjects;
using OxyPlotResources = Core.Plugins.OxyPlot.Properties.Resources;
using GuiResources = Core.Common.Gui.Properties.Resources;
@@ -61,108 +63,150 @@
private void RegisterTreeNodeInfos()
{
- treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
{
- Text = pointData => pointData.Name,
- Image = pointData => OxyPlotResources.PointsIcon,
- CanDrag = (pointData, parentData) => true,
- CanCheck = pointData => true,
- IsChecked = pointData => pointData.IsVisible,
- OnNodeChecked = PointBasedChartDataOnNodeChecked
+ Text = context => context.WrappedData.Name,
+ Image = GetImage,
+ ChildNodeObjects = ChartDataContextGetChildNodeObjects,
+ CanDrag = (context, o) => !(context.WrappedData is ChartMultipleAreaData),
+ CanCheck = context => !(context.WrappedData is ChartDataCollection),
+ IsChecked = context => context.WrappedData.IsVisible,
+ OnNodeChecked = ChartDataContextOnNodeChecked,
+ CanDrop = ChartDataContextCanDrop,
+ CanInsert = ChartDataContextCanInsert,
+ OnDrop = ChartDataContextOnDrop
});
- treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
{
- Text = lineData => lineData.Name,
- Image = lineData => OxyPlotResources.LineIcon,
- CanDrag = (lineData, parentData) => true,
- CanCheck = lineData => true,
- IsChecked = lineData => lineData.IsVisible,
- OnNodeChecked = PointBasedChartDataOnNodeChecked
+ Text = collection => collection.Name,
+ Image = collection => GuiResources.folder,
+ ChildNodeObjects = GetCollectionChildNodeObjects,
+ CanDrag = (multipleAreaData, parentData) => true,
+ CanDrop = ChartDataCollectionCanDrop,
+ CanInsert = ChartDataCollectionCanInsert,
+ OnDrop = ChartDataCollectionOnDrop
});
+ }
- treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ #region ChartDataContext
+
+ private Image GetImage(ChartDataContext context)
+ {
+ if (context.WrappedData is ChartPointData)
{
- Text = areaData => areaData.Name,
- Image = areaData => OxyPlotResources.AreaIcon,
- CanDrag = (areaData, parentData) => true,
- CanCheck = areaData => true,
- IsChecked = areaData => areaData.IsVisible,
- OnNodeChecked = PointBasedChartDataOnNodeChecked
- });
+ return OxyPlotResources.PointsIcon;
+ }
- treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ if (context.WrappedData is ChartLineData)
{
- Text = multipleAreaData => multipleAreaData.Name,
- Image = multipleAreaData => OxyPlotResources.AreaIcon,
- CanDrag = (multipleAreaData, parentData) => true,
- CanCheck = multipleAreaData => true,
- IsChecked = multipleAreaData => multipleAreaData.IsVisible,
- OnNodeChecked = ChartMultipleAreaDataOnNodeChecked
- });
+ return OxyPlotResources.LineIcon;
+ }
- treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
+ if (context.WrappedData is ChartAreaData || context.WrappedData is ChartMultipleAreaData)
{
- Text = collection => collection.Name,
- Image = collection => GuiResources.folder,
- ChildNodeObjects = collection => collection.List.Reverse().Cast