Index: Core/Components/src/Core.Components.GraphSharp.Forms/PointedTreeGraphControl.cs =================================================================== diff -u -r6dd9d30bf2f7b740320718ceea5513f39741fa95 -r1fb18822ebf5a2e3dae6eb2dc3c4687e4d1d0e62 --- Core/Components/src/Core.Components.GraphSharp.Forms/PointedTreeGraphControl.cs (.../PointedTreeGraphControl.cs) (revision 6dd9d30bf2f7b740320718ceea5513f39741fa95) +++ Core/Components/src/Core.Components.GraphSharp.Forms/PointedTreeGraphControl.cs (.../PointedTreeGraphControl.cs) (revision 1fb18822ebf5a2e3dae6eb2dc3c4687e4d1d0e62) @@ -24,6 +24,7 @@ using System.Windows.Forms; using System.Windows.Media; using Core.Common.Utils.Extensions; +using Core.Components.GraphSharp.Converters; using Core.Components.GraphSharp.Data; using Core.Components.GraphSharp.Forms.Layout; using Core.Components.PointedTree.Data; @@ -95,18 +96,7 @@ private void DrawNode(GraphNode node, PointedTreeElementVertex parentVertex = null) { - var vertex = new PointedTreeElementVertex(node.Title, - new SolidColorBrush(Color.FromArgb(node.Style.FillColor.A, - node.Style.FillColor.R, - node.Style.FillColor.G, - node.Style.FillColor.B)), - new SolidColorBrush(Color.FromArgb(node.Style.LineColor.A, - node.Style.LineColor.R, - node.Style.LineColor.G, - node.Style.LineColor.B)), - node.Style.LineWidth, - PointedTreeVertexType.Rectangle, - node.IsSelectable); + PointedTreeElementVertex vertex = GraphNodeConverter.Convert(node); graph.AddVertex(vertex); Index: Core/Components/src/Core.Components.GraphSharp/Converters/GraphNodeConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.GraphSharp/Converters/GraphNodeConverter.cs (revision 0) +++ Core/Components/src/Core.Components.GraphSharp/Converters/GraphNodeConverter.cs (revision 1fb18822ebf5a2e3dae6eb2dc3c4687e4d1d0e62) @@ -0,0 +1,85 @@ +// 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.ComponentModel; +using System.Windows.Media; +using Core.Components.GraphSharp.Data; +using Core.Components.PointedTree.Data; + +namespace Core.Components.GraphSharp.Converters +{ + /// + /// Converter to change a to . + /// + public static class GraphNodeConverter + { + /// + /// Converts a to a . + /// + /// The graph node to convert. + /// The created . + /// Thrown when + /// is null. + public static PointedTreeElementVertex Convert(GraphNode graphNode) + { + if (graphNode == null) + { + throw new ArgumentNullException(nameof(graphNode)); + } + + GraphNodeStyle style = graphNode.Style; + + return new PointedTreeElementVertex( + graphNode.Title, + ConvertColor(style.FillColor), + ConvertColor(style.LineColor), + style.LineWidth, + ConvertType(style.Shape), + graphNode.IsSelectable); + } + + private static SolidColorBrush ConvertColor(System.Drawing.Color color) + { + return new SolidColorBrush( + Color.FromArgb( + color.A, + color.R, + color.G, + color.B)); + } + + private static PointedTreeVertexType ConvertType(GraphNodeShape shape) + { + switch(shape) + { + case GraphNodeShape.Rectangle: + return PointedTreeVertexType.Rectangle; + case GraphNodeShape.Diamond: + return PointedTreeVertexType.Diamond; + default: + throw new InvalidEnumArgumentException(nameof(shape), + (int) shape, + typeof(GraphNodeShape)); + } + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.GraphSharp/Core.Components.GraphSharp.csproj =================================================================== diff -u -r83a3d88b3df8452281d5f020060e8cfb2b6fb85e -r1fb18822ebf5a2e3dae6eb2dc3c4687e4d1d0e62 --- Core/Components/src/Core.Components.GraphSharp/Core.Components.GraphSharp.csproj (.../Core.Components.GraphSharp.csproj) (revision 83a3d88b3df8452281d5f020060e8cfb2b6fb85e) +++ Core/Components/src/Core.Components.GraphSharp/Core.Components.GraphSharp.csproj (.../Core.Components.GraphSharp.csproj) (revision 1fb18822ebf5a2e3dae6eb2dc3c4687e4d1d0e62) @@ -61,6 +61,7 @@ + ..\..\..\..\packages\WPFExtensions.1.0.0\lib\WPFExtensions.dll @@ -71,6 +72,7 @@ Properties\GlobalAssembly.cs + @@ -83,6 +85,14 @@ + + + + {ad3b1634-c435-4618-9971-2ea0817f5de2} + Core.Components.PointedTree + False + +