Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsControl.cs =================================================================== diff -u -r8ba742d2139563c9571e32f074c7c4b3077f45ee -r1be704f7fb39169579e4a15ca74161314347730b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsControl.cs (.../IllustrationPointsControl.cs) (revision 8ba742d2139563c9571e32f074c7c4b3077f45ee) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsControl.cs (.../IllustrationPointsControl.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) @@ -19,24 +19,29 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Windows.Forms; +using Core.Common.Controls.Views; using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; namespace Ringtoets.Common.Forms.Views { /// /// Control to show illustration points. /// - public partial class IllustrationPointsControl : UserControl + public partial class IllustrationPointsControl : UserControl, ISelectionProvider { private GeneralResultSubMechanismIllustrationPoint data; + public event EventHandler SelectionChanged; + /// /// Creates a new instance of . /// public IllustrationPointsControl() { InitializeComponent(); + InitializeEventHandlers(); } /// @@ -61,5 +66,28 @@ illustrationPointsTableControl.Data = data; } } + + public object Selection + { + get + { + return illustrationPointsTableControl.Selection; + } + } + + private void InitializeEventHandlers() + { + illustrationPointsTableControl.SelectionChanged += IllustrationPointsTableControlOnSelectionChanged; + } + + private void IllustrationPointsTableControlOnSelectionChanged(object sender, EventArgs e) + { + OnSelectionChanged(e); + } + + private void OnSelectionChanged(EventArgs e) + { + SelectionChanged?.Invoke(this, e); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs =================================================================== diff -u -r29c0d37342d76d0bc06b1696aeaf56a316f86a19 -r1be704f7fb39169579e4a15ca74161314347730b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision 29c0d37342d76d0bc06b1696aeaf56a316f86a19) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) @@ -24,6 +24,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Views; +using Core.Common.Utils.Events; using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; using Ringtoets.Common.Forms.Properties; @@ -92,7 +93,7 @@ private void DataGridViewOnCurrentCellChangedHandler(object sender, EventArgs e) { - OnSelectionChanged(); + OnSelectionChanged(e); } private void UpdateClosingStructureVisibility() @@ -134,9 +135,9 @@ .ToList(); } - private void OnSelectionChanged() + private void OnSelectionChanged(EventArgs e) { - SelectionChanged?.Invoke(this, EventArgs.Empty); + SelectionChanged?.Invoke(this, e); } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.Designer.cs =================================================================== diff -u -r5514a08de8ea4dae19d6495b41e0817d3f5ef95b -r1be704f7fb39169579e4a15ca74161314347730b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.Designer.cs (.../LocationsView.Designer.cs) (revision 5514a08de8ea4dae19d6495b41e0817d3f5ef95b) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.Designer.cs (.../LocationsView.Designer.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) @@ -30,6 +30,19 @@ /// private System.ComponentModel.IContainer components = null; + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + #region Component Designer generated code /// Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs =================================================================== diff -u -r67e77262b9f0f183db81f8c95d7b12aa5fcdb8e9 -r1be704f7fb39169579e4a15ca74161314347730b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 67e77262b9f0f183db81f8c95d7b12aa5fcdb8e9) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) @@ -66,16 +66,6 @@ InitializeDataGridView(); } - protected override void Dispose(bool disposing) - { - if (disposing) - { - components?.Dispose(); - } - - base.Dispose(disposing); - } - /// /// Updates the data source of the data table based on the . /// Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs =================================================================== diff -u -r25c883f721fff09f5fbd3ec5c6cc280e17fe1343 -r1be704f7fb39169579e4a15ca74161314347730b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 25c883f721fff09f5fbd3ec5c6cc280e17fe1343) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) @@ -19,11 +19,16 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using NUnit.Framework; using Ringtoets.Common.Forms.Views; using System.Windows.Forms; +using Core.Common.Controls.Views; +using NUnit.Extensions.Forms; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +//using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints; namespace Ringtoets.Common.Forms.Test.Views { @@ -38,6 +43,7 @@ // Assert Assert.IsInstanceOf(control); + Assert.IsInstanceOf(control); Assert.IsNull(control.Data); Assert.AreEqual(1, control.Controls.Count); @@ -78,5 +84,63 @@ Assert.AreSame(data, tableControl.Data); } } + + [Test] + public void GivenFullyConfiguredControl_WhenSelectingCellInRow_ThenSelectionChangedFired() + { + // Given + using (var form = new Form()) + { + var control = new IllustrationPointsControl(); + + form.Controls.Add(control); + form.Show(); + + control.Data = new TestGeneralResultSubMechanismIllustrationPoint(); + + var selectionChangedCount = 0; + control.SelectionChanged += (sender, args) => selectionChangedCount++; + + var tableControl = (IllustrationPointsTableControl) control.Controls.Find("IllustrationPointsTableControl", true).Single(); + + // When + EventHelper.RaiseEvent(tableControl, "SelectionChanged"); + + // Then + Assert.AreEqual(1, selectionChangedCount); + } + } + + [Test] + public void Selection_Always_SameAsTableControlSelection() + { + // Call + using (var form = new Form()) + { + var control = new IllustrationPointsControl(); + + form.Controls.Add(control); + form.Show(); + + control.Data = new GeneralResultSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + new[] + { + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Regular", + new SubMechanismIllustrationPoint("Point 1", Enumerable.Empty(), + Enumerable.Empty(), 0.9)) + }); + + var tableControl = (IllustrationPointsTableControl) control.Controls.Find("IllustrationPointsTableControl", true).Single(); + var dataGridView = (DataGridView) tableControl.Controls.Find("dataGridView", true).Single(); + DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; + selectedLocationRow.Cells[0].Value = true; + + // Assert + Assert.AreSame(tableControl.Selection, control.Selection); + } + } } } \ No newline at end of file