Index: src/Deltares.DSoilModel.Forms/DSoilModelSelectionRedirector.cs
===================================================================
diff -u
--- src/Deltares.DSoilModel.Forms/DSoilModelSelectionRedirector.cs (revision 0)
+++ src/Deltares.DSoilModel.Forms/DSoilModelSelectionRedirector.cs (revision 244)
@@ -0,0 +1,68 @@
+using System;
+using Deltares.Geotechnics;
+using Deltares.Geotechnics.ConePenetrationTest;
+using Deltares.Standard;
+using Deltares.Standard.EventPublisher.Enum;
+
+namespace Deltares.DSoilModel.Forms
+{
+ public class DSoilModelSelectionRedirector : ISelectionRedirector
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DSoilModelSelectionRedirector()
+ {
+ RedirectingTypes = new[]
+ {
+ typeof (ConePenetrationTestLookup1D),
+ typeof (ConePenetrationTestLookup2D),
+ typeof (BoringLookup1D),
+ typeof (BoringLookup2D)
+ };
+ }
+
+ ///
+ /// Gets the redirected object.
+ ///
+ /// The source.
+ /// Type of the reaction.
+ ///
+ public object GetRedirectedObject(object source, ref PropertyEditorReactionType reactionType)
+ {
+ reactionType = PropertyEditorReactionType.Update;
+
+ // redirect selection of soil layer in geometry view to material of the layer so this is highlighted in the materials table
+ var lookupCpt1D = source as ConePenetrationTestLookup1D;
+ if (lookupCpt1D != null)
+ {
+ return lookupCpt1D.ConePenetrationTestData;
+ }
+
+ var lookupCpt2D = source as ConePenetrationTestLookup2D;
+ if (lookupCpt2D != null)
+ {
+ return lookupCpt2D.ConePenetrationTestData;
+ }
+
+ var lookupBoring1D = source as BoringLookup1D;
+ if (lookupBoring1D != null)
+ {
+ return lookupBoring1D.Boring;
+ }
+
+ var lookupBoring2D = source as BoringLookup2D;
+ if (lookupBoring2D != null)
+ {
+ return lookupBoring2D.Boring;
+ }
+
+ return source;
+ }
+
+ ///
+ /// All types handled by this selection redirector.
+ ///
+ public Type[] RedirectingTypes { get; private set; }
+ }
+}
Index: src/Deltares.DSoilModel.Forms/Deltares.DSoilModel.Forms.csproj
===================================================================
diff -u -r63 -r244
--- src/Deltares.DSoilModel.Forms/Deltares.DSoilModel.Forms.csproj (.../Deltares.DSoilModel.Forms.csproj) (revision 63)
+++ src/Deltares.DSoilModel.Forms/Deltares.DSoilModel.Forms.csproj (.../Deltares.DSoilModel.Forms.csproj) (revision 244)
@@ -217,6 +217,7 @@
+
UserControl
Index: src/Deltares.DSoilModel.Forms.Tests/DSoilModelSelectionRedirectorTests.cs
===================================================================
diff -u
--- src/Deltares.DSoilModel.Forms.Tests/DSoilModelSelectionRedirectorTests.cs (revision 0)
+++ src/Deltares.DSoilModel.Forms.Tests/DSoilModelSelectionRedirectorTests.cs (revision 244)
@@ -0,0 +1,45 @@
+using System;
+using System.Reflection;
+using Deltares.Geotechnics;
+using Deltares.Geotechnics.ConePenetrationTest;
+using Deltares.Standard.EventPublisher.Enum;
+using NUnit.Framework;
+
+namespace Deltares.DSoilModel.Forms.Tests
+{
+ [TestFixture]
+ class DSoilModelSelectionRedirectorTests
+ {
+ [Test]
+ public void SupportedTypesTest()
+ {
+ var redirector = new DSoilModelSelectionRedirector();
+ Assert.AreEqual(4, redirector.RedirectingTypes.Length);
+
+ Assert.Contains(typeof (ConePenetrationTestLookup1D), redirector.RedirectingTypes);
+ Assert.Contains(typeof (ConePenetrationTestLookup2D), redirector.RedirectingTypes);
+ Assert.Contains(typeof (BoringLookup1D), redirector.RedirectingTypes);
+ Assert.Contains(typeof (BoringLookup2D), redirector.RedirectingTypes);
+ }
+
+ [Test]
+ [TestCase(typeof(ConePenetrationTestLookup1D), "ConePenetrationTestData", typeof(ConePenetrationTestData))]
+ [TestCase(typeof(ConePenetrationTestLookup2D), "ConePenetrationTestData", typeof(ConePenetrationTestData))]
+ [TestCase(typeof(BoringLookup1D), "Boring", typeof(Boring))]
+ [TestCase(typeof(BoringLookup2D), "Boring", typeof(Boring))]
+ public void GetRedirectedObjectTest(Type inType, string propertyName, Type outType)
+ {
+ var redirector = new DSoilModelSelectionRedirector();
+ PropertyEditorReactionType reactionType = PropertyEditorReactionType.Ignore;
+
+ var inObject = Activator.CreateInstance(inType);
+ var property = inObject.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);
+ property.SetValue(inObject, Activator.CreateInstance(property.PropertyType), null);
+
+ var outObject = redirector.GetRedirectedObject(inObject, ref reactionType);
+
+ Assert.IsNotNull(outObject);
+ Assert.AreEqual(outType, outObject.GetType());
+ }
+ }
+}
Index: src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj
===================================================================
diff -u -r240 -r244
--- src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 240)
+++ src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 244)
@@ -68,6 +68,7 @@
+
Index: src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs
===================================================================
diff -u -r226 -r244
--- src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs (.../DSoilModelPlugin.cs) (revision 226)
+++ src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs (.../DSoilModelPlugin.cs) (revision 244)
@@ -233,6 +233,9 @@
DataEventPublisher.OnAfterChange += DataEventPublisherOnAfterChange;
DataEventPublisher.OnSelectionChanged += DataEventPublisherOnSelectionChanged;
+ var redirector = new DSoilModelSelectionRedirector();
+ DataEventPublisher.RegisterSelectionRedirector(redirector, redirector.RedirectingTypes);
+
mainForm.RegisterNewFileHandler(CreateNewFile);
mainForm.RegisterOpenFileHandler("soil", "Soilbase files (*.soil)|*.soil", DSoilModelIO.OpenSoilDatabase);