Index: Core/Components/src/Core.Components.GraphSharp.Forms/Converters/PointedTreeVertexTypeToStringConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.GraphSharp.Forms/Converters/PointedTreeVertexTypeToStringConverter.cs (revision 0) +++ Core/Components/src/Core.Components.GraphSharp.Forms/Converters/PointedTreeVertexTypeToStringConverter.cs (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -0,0 +1,58 @@ +// 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.Globalization; +using System.Windows.Data; +using Core.Components.GraphSharp.Data; + +namespace Core.Components.GraphSharp.Forms.Converters +{ + /// + /// Converter to change a instance to a string. + /// + public class PointedTreeVertexTypeToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (targetType != typeof(string) || value == null) + { + return null; + } + + switch ((PointedTreeVertexType) value) + { + case PointedTreeVertexType.Rectangle: + return "Rectangle"; + case PointedTreeVertexType.Diamond: + return "Diamond"; + default: + throw new InvalidEnumArgumentException(); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} Index: Core/Components/src/Core.Components.GraphSharp.Forms/Core.Components.GraphSharp.Forms.csproj =================================================================== diff -u -r95433bcf41f452154959a6884129265c6de295b7 -r6189fae3f21e2ee5eac80441472c2bcd5124c3da --- Core/Components/src/Core.Components.GraphSharp.Forms/Core.Components.GraphSharp.Forms.csproj (.../Core.Components.GraphSharp.Forms.csproj) (revision 95433bcf41f452154959a6884129265c6de295b7) +++ Core/Components/src/Core.Components.GraphSharp.Forms/Core.Components.GraphSharp.Forms.csproj (.../Core.Components.GraphSharp.Forms.csproj) (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -79,6 +79,7 @@ Properties\GlobalAssembly.cs + UserControl @@ -87,6 +88,11 @@ PointedTreeGraphControl.cs + + True + True + Resources.resx + @@ -115,7 +121,16 @@ PointedTreeGraphControl.cs + + ResXFileCodeGenerator + Resources.Designer.cs + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Templates\PointedTreeGraphTemplate.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file Index: Core/Components/src/Core.Components.GraphSharp.Forms/Templates/PointedTreeGraphTemplate.xaml =================================================================== diff -u --- Core/Components/src/Core.Components.GraphSharp.Forms/Templates/PointedTreeGraphTemplate.xaml (revision 0) +++ Core/Components/src/Core.Components.GraphSharp.Forms/Templates/PointedTreeGraphTemplate.xaml (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + \ No newline at end of file Index: Core/Components/src/Core.Components.GraphSharp.Forms/packages.config =================================================================== diff -u -red1fb371daab54fc0cd851a0a17d2fff9136028c -r6189fae3f21e2ee5eac80441472c2bcd5124c3da --- Core/Components/src/Core.Components.GraphSharp.Forms/packages.config (.../packages.config) (revision ed1fb371daab54fc0cd851a0a17d2fff9136028c) +++ Core/Components/src/Core.Components.GraphSharp.Forms/packages.config (.../packages.config) (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -20,7 +20,6 @@ Stichting Deltares and remain full property of Stichting Deltares at all times. All rights reserved. --> - Index: Core/Components/src/Core.Components.GraphSharp/Data/PointedTreeElementVertex.cs =================================================================== diff -u -r83a3d88b3df8452281d5f020060e8cfb2b6fb85e -r6189fae3f21e2ee5eac80441472c2bcd5124c3da --- Core/Components/src/Core.Components.GraphSharp/Data/PointedTreeElementVertex.cs (.../PointedTreeElementVertex.cs) (revision 83a3d88b3df8452281d5f020060e8cfb2b6fb85e) +++ Core/Components/src/Core.Components.GraphSharp/Data/PointedTreeElementVertex.cs (.../PointedTreeElementVertex.cs) (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -79,7 +79,7 @@ public Brush LineColor { get; } /// - /// Gets the line widht of the vertex. + /// Gets the line width of the vertex. /// public int LineWidth { get;} Index: Core/Components/test/Core.Components.GraphSharp.Forms.Test/Converters/PointedTreeVertexTypeToStringConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.GraphSharp.Forms.Test/Converters/PointedTreeVertexTypeToStringConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.GraphSharp.Forms.Test/Converters/PointedTreeVertexTypeToStringConverterTest.cs (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -0,0 +1,99 @@ +// 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.Globalization; +using System.Windows.Data; +using Core.Components.GraphSharp.Data; +using Core.Components.GraphSharp.Forms.Converters; +using NUnit.Framework; + +namespace Core.Components.GraphSharp.Forms.Test.Converters +{ + [TestFixture] + public class PointedTreeVertexTypeToStringConverterTest + { + [Test] + public void DefaultConcstructor_ExpectedValues() + { + // Call + var converter = new PointedTreeVertexTypeToStringConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void Convert_ValueNull_ReturnNull() + { + // Setup + var converter = new PointedTreeVertexTypeToStringConverter(); + + // Call + object convertedValue = converter.Convert(null, typeof(string), null, CultureInfo.InvariantCulture); + + // Assert + Assert.IsNull(convertedValue); + } + + [Test] + public void Convert_TargetTypeNotString_ReturnNull() + { + // Setup + var converter = new PointedTreeVertexTypeToStringConverter(); + + // Call + object convertedValue = converter.Convert(string.Empty, typeof(object), null, CultureInfo.InvariantCulture); + + // Assert + Assert.IsNull(convertedValue); + } + + [Test] + [TestCase(PointedTreeVertexType.Rectangle, "Rectangle")] + [TestCase(PointedTreeVertexType.Diamond, "Diamond")] + public void Convert_WithPointedTreeVertexType_ConvertToString(PointedTreeVertexType vertexType, string expectedString) + { + // Setup + var converter = new PointedTreeVertexTypeToStringConverter(); + + // Call + var actualString = converter.Convert(vertexType, typeof(string), null, CultureInfo.InvariantCulture) as string; + + // Assert + Assert.NotNull(actualString); + Assert.AreEqual(expectedString, actualString); + } + + [Test] + public void ConvertBack_ThrowNotImplementedException() + { + // Setup + var converter = new PointedTreeVertexTypeToStringConverter(); + + // Call + TestDelegate call = () => converter.ConvertBack(string.Empty, typeof(PointedTreeVertexType), null, CultureInfo.InvariantCulture); + + // Assert + Assert.Throws(call); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.GraphSharp.Forms.Test/Core.Components.GraphSharp.Forms.Test.csproj =================================================================== diff -u -r318d69038a31bc88dddd540784d5287f88d836e6 -r6189fae3f21e2ee5eac80441472c2bcd5124c3da --- Core/Components/test/Core.Components.GraphSharp.Forms.Test/Core.Components.GraphSharp.Forms.Test.csproj (.../Core.Components.GraphSharp.Forms.Test.csproj) (revision 318d69038a31bc88dddd540784d5287f88d836e6) +++ Core/Components/test/Core.Components.GraphSharp.Forms.Test/Core.Components.GraphSharp.Forms.Test.csproj (.../Core.Components.GraphSharp.Forms.Test.csproj) (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -84,6 +84,7 @@ Properties\GlobalAssembly.cs + Index: Core/Components/test/Core.Components.GraphSharp.Forms.Test/PointedTreeGraphControlTest.cs =================================================================== diff -u -r318d69038a31bc88dddd540784d5287f88d836e6 -r6189fae3f21e2ee5eac80441472c2bcd5124c3da --- Core/Components/test/Core.Components.GraphSharp.Forms.Test/PointedTreeGraphControlTest.cs (.../PointedTreeGraphControlTest.cs) (revision 318d69038a31bc88dddd540784d5287f88d836e6) +++ Core/Components/test/Core.Components.GraphSharp.Forms.Test/PointedTreeGraphControlTest.cs (.../PointedTreeGraphControlTest.cs) (revision 6189fae3f21e2ee5eac80441472c2bcd5124c3da) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Threading; +using System.Windows; using System.Windows.Forms; using System.Windows.Forms.Integration; using Core.Components.GraphSharp.Forms.Layout; @@ -49,6 +51,11 @@ var elementHost = graphControl.Controls[0] as ElementHost; var zoomControl = (ZoomControl) elementHost.Child; + + Assert.AreEqual(1, zoomControl.Resources.MergedDictionaries.Count); + ResourceDictionary templateDictionary = zoomControl.Resources.MergedDictionaries.First(); + Assert.AreEqual("/Core.Components.GraphSharp.Forms;component/Templates/PointedTreeGraphTemplate.xaml", templateDictionary.Source.AbsolutePath); + Assert.IsInstanceOf(zoomControl.Content); } }