Index: Core/Components/src/Core.Components.PointedTree/Core.Components.PointedTree.csproj
===================================================================
diff -u -r40514f2e47eded8cd37dad8d7e17829e77565d92 -r95d9fe65a46c2fbd58388014f903ab9dd4d9e25c
--- Core/Components/src/Core.Components.PointedTree/Core.Components.PointedTree.csproj (.../Core.Components.PointedTree.csproj) (revision 40514f2e47eded8cd37dad8d7e17829e77565d92)
+++ Core/Components/src/Core.Components.PointedTree/Core.Components.PointedTree.csproj (.../Core.Components.PointedTree.csproj) (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -47,6 +47,7 @@
+
True
Index: Core/Components/src/Core.Components.PointedTree/Data/GraphNodeContentXmlDefinitions.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.PointedTree/Data/GraphNodeContentXmlDefinitions.cs (revision 0)
+++ Core/Components/src/Core.Components.PointedTree/Data/GraphNodeContentXmlDefinitions.cs (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -0,0 +1,39 @@
+// 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.
+
+namespace Core.Components.PointedTree.Data
+{
+ ///
+ /// Defines the element names of .
+ ///
+ public static class GraphNodeContentXmlDefinitions
+ {
+ ///
+ /// Gets the name of the root element.
+ ///
+ public const string RootElement = "text";
+
+ ///
+ /// Gets the bold element.
+ ///
+ public const string BoldElement = "bold";
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.PointedTree.Test/Core.Components.PointedTree.Test.csproj
===================================================================
diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r95d9fe65a46c2fbd58388014f903ab9dd4d9e25c
--- Core/Components/test/Core.Components.PointedTree.Test/Core.Components.PointedTree.Test.csproj (.../Core.Components.PointedTree.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6)
+++ Core/Components/test/Core.Components.PointedTree.Test/Core.Components.PointedTree.Test.csproj (.../Core.Components.PointedTree.Test.csproj) (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -53,6 +53,7 @@
+
Index: Core/Components/test/Core.Components.PointedTree.Test/Data/GraphNodeContentXmlDefinitionsTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.PointedTree.Test/Data/GraphNodeContentXmlDefinitionsTest.cs (revision 0)
+++ Core/Components/test/Core.Components.PointedTree.Test/Data/GraphNodeContentXmlDefinitionsTest.cs (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -0,0 +1,37 @@
+// 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 Core.Components.PointedTree.Data;
+using NUnit.Framework;
+
+namespace Core.Components.PointedTree.Test.Data
+{
+ [TestFixture]
+ public class GraphNodeContentXmlDefinitionsTest
+ {
+ [Test]
+ public void Constants_ExpectedValues()
+ {
+ Assert.AreEqual("text", GraphNodeContentXmlDefinitions.RootElement);
+ Assert.AreEqual("bold", GraphNodeContentXmlDefinitions.BoldElement);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -0,0 +1,139 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Xml;
+using Core.Components.PointedTree.Data;
+
+namespace Ringtoets.Common.Forms.Factories
+{
+ ///
+ /// Factory for creating based on information used as input.
+ ///
+ public static class RingtoetsGraphNodeFactory
+ {
+ private static readonly XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
+ {
+ OmitXmlDeclaration = true
+ };
+
+ ///
+ /// Create with default styling for an end node.
+ ///
+ /// The title to set for this node.
+ /// The content to set for this node.
+ /// The created .
+ public static GraphNode CreateEndGraphNode(string title, string content)
+ {
+ return new GraphNode(GetGraphNodeContentXml(title, content),
+ new GraphNode[0],
+ true,
+ new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1));
+ }
+
+ ///
+ /// Create with default styling for a composite node.
+ ///
+ /// The title to set for this node.
+ /// The content to set for this node.
+ /// The child nodes of this node.
+ /// The created .
+ /// Thrown when is
+ /// null.
+ public static GraphNode CreateCompositeGraphNode(string title, string content, IEnumerable childNodes)
+ {
+ if (childNodes == null)
+ {
+ throw new ArgumentNullException(nameof(childNodes));
+ }
+ return new GraphNode(GetGraphNodeContentXml(title, content),
+ childNodes.ToArray(),
+ true,
+ new GraphNodeStyle(GraphNodeShape.Rectangle, Color.LightSkyBlue, Color.Black, 1));
+ }
+
+ ///
+ /// Create with default styling for a connecting node.
+ ///
+ /// The title to set for this node.
+ /// The child nodes of this node.
+ /// The created .
+ /// Thrown when is
+ /// null.
+ public static GraphNode CreateConnectingGraphNode(string title, IEnumerable childNodes)
+ {
+ if (childNodes == null)
+ {
+ throw new ArgumentNullException(nameof(childNodes));
+ }
+ return new GraphNode(GetGraphNodeContentXml(title),
+ childNodes.ToArray(),
+ false,
+ new GraphNodeStyle(GraphNodeShape.Rectangle, Color.BlanchedAlmond, Color.Black, 1));
+ }
+
+ private static string GetGraphNodeContentXml(string content)
+ {
+ var builder = new StringBuilder();
+ using (XmlWriter writer = XmlWriter.Create(builder, xmlWriterSettings))
+ {
+ writer.WriteStartDocument();
+ writer.WriteStartElement(GraphNodeContentXmlDefinitions.RootElement);
+
+ writer.WriteString(content);
+
+ writer.WriteEndElement();
+ writer.WriteEndDocument();
+
+ writer.Flush();
+ writer.Close();
+ }
+
+ return builder.ToString();
+ }
+
+ private static string GetGraphNodeContentXml(string title, string content)
+ {
+ var builder = new StringBuilder();
+ using (XmlWriter writer = XmlWriter.Create(builder, xmlWriterSettings))
+ {
+ writer.WriteStartDocument();
+ writer.WriteStartElement(GraphNodeContentXmlDefinitions.RootElement);
+
+ writer.WriteElementString(GraphNodeContentXmlDefinitions.BoldElement, title);
+ writer.WriteString(Environment.NewLine);
+ writer.WriteString(content);
+
+ writer.WriteEndElement();
+ writer.WriteEndDocument();
+
+ writer.Flush();
+ writer.Close();
+ }
+
+ return builder.ToString();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r515adad18359253ba49f28454f2c2e9bb5cd2e92 -r95d9fe65a46c2fbd58388014f903ab9dd4d9e25c
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 515adad18359253ba49f28454f2c2e9bb5cd2e92)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -56,6 +56,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -0,0 +1,150 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.Drawing;
+using System.Linq;
+using Core.Components.PointedTree.Data;
+using NUnit.Framework;
+using Ringtoets.Common.Forms.Factories;
+
+namespace Ringtoets.Common.Forms.Test.Factories
+{
+ [TestFixture]
+ public class RingtoetsGraphNodeFactoryTest
+ {
+ [Test]
+ public void CreateEndGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling()
+ {
+ // Setup
+ const string title = "title";
+ const string content = "content";
+
+ // Call
+ GraphNode node = RingtoetsGraphNodeFactory.CreateEndGraphNode(title, content);
+
+ // Assert
+ string expectedContent = $"{title}{Environment.NewLine}{content}";
+ Assert.AreEqual(expectedContent, node.Content);
+ Assert.IsTrue(node.IsSelectable);
+
+ var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1);
+ AssertEqualStyle(expectedStyle, node.Style);
+
+ CollectionAssert.IsEmpty(node.ChildNodes);
+ }
+
+ [Test]
+ public void CreateCompositeGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling()
+ {
+ // Setup
+ const string title = "compositeTitle";
+ const string content = "compositeContent";
+
+ GraphNode childNode = new TestGraphNode();
+
+ // Call
+ GraphNode node = RingtoetsGraphNodeFactory.CreateCompositeGraphNode(title, content, new[]
+ {
+ childNode
+ });
+
+ // Assert
+ string expectedContent = $"{title}{Environment.NewLine}{content}";
+ Assert.AreEqual(expectedContent, node.Content);
+ Assert.IsTrue(node.IsSelectable);
+
+ var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.LightSkyBlue, Color.Black, 1);
+ AssertEqualStyle(expectedStyle, node.Style);
+
+ Assert.AreEqual(1, node.ChildNodes.Count());
+ Assert.AreSame(childNode, node.ChildNodes.First());
+ }
+
+ [Test]
+ public void CreateCompositeGraphNode_ChildNodesNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsGraphNodeFactory.CreateCompositeGraphNode("title",
+ "content",
+ null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("childNodes", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateConnectingGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling()
+ {
+ // Setup
+ const string title = "title";
+ GraphNode childNode = new TestGraphNode();
+
+ // Call
+ GraphNode node = RingtoetsGraphNodeFactory.CreateConnectingGraphNode(title, new[]
+ {
+ childNode
+ });
+
+ // Assert
+ string expectedContent = $"{title}";
+ Assert.AreEqual(expectedContent, node.Content);
+ Assert.IsFalse(node.IsSelectable);
+
+ var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.BlanchedAlmond, Color.Black, 1);
+ AssertEqualStyle(expectedStyle, node.Style);
+
+ Assert.AreEqual(1, node.ChildNodes.Count());
+ Assert.AreSame(childNode, node.ChildNodes.First());
+ }
+
+ [Test]
+ public void CreateConnectingGraphNode_ChildNodesNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsGraphNodeFactory.CreateConnectingGraphNode("title",
+ null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("childNodes", exception.ParamName);
+ }
+
+ private static void AssertEqualStyle(GraphNodeStyle expected, GraphNodeStyle actual)
+ {
+ Assert.AreEqual(expected.FillColor, actual.FillColor);
+ Assert.AreEqual(expected.LineColor, actual.LineColor);
+ Assert.AreEqual(expected.LineWidth, actual.LineWidth);
+ Assert.AreEqual(expected.Shape, actual.Shape);
+ }
+
+ private class TestGraphNode : GraphNode
+ {
+ public TestGraphNode() : base("content", new GraphNode[0], false, new TestGraphNodeStyle()) {}
+ }
+
+ private class TestGraphNodeStyle : GraphNodeStyle
+ {
+ public TestGraphNodeStyle() : base(GraphNodeShape.None, Color.Empty, Color.Empty, 1) {}
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -r515adad18359253ba49f28454f2c2e9bb5cd2e92 -r95d9fe65a46c2fbd58388014f903ab9dd4d9e25c
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 515adad18359253ba49f28454f2c2e9bb5cd2e92)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 95d9fe65a46c2fbd58388014f903ab9dd4d9e25c)
@@ -69,6 +69,7 @@
+
@@ -202,6 +203,10 @@
{DADAA0A5-288C-49CB-9F08-337F16832C86}
Core.Components.OxyPlot.Forms
+
+ {AD3B1634-C435-4618-9971-2EA0817F5DE2}
+ Core.Components.PointedTree
+
{72109e33-6518-4632-accf-6cbf2a312711}
Core.Components.Stack.Forms