Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs
===================================================================
diff -u -r18597db78286d0d3a7f267b3c1546491487aa902 -r2ce9847b42ca47fc9008c8c18f9158a4b83e0fb3
--- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision 18597db78286d0d3a7f267b3c1546491487aa902)
+++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision 2ce9847b42ca47fc9008c8c18f9158a4b83e0fb3)
@@ -177,7 +177,7 @@
foreshoreProfilesObserver = new Observer(() =>
{
PrefillComboBoxListItemsAtColumnLevel();
- UpdateColumns();
+ UpdateComboBoxColumns();
UpdateGenerateCalculationsButtonState();
})
{
@@ -221,9 +221,9 @@
#region Update combo box list items
- protected override void UpdateColumns()
+ protected override void UpdateComboBoxColumns()
{
- base.UpdateColumns();
+ base.UpdateComboBoxColumns();
UpdateForeshoreProfilesColumn();
}
Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/CalculationsView.cs
===================================================================
diff -u -rbe15aaeb0579324b4486a2816278c601bfea9523 -r2ce9847b42ca47fc9008c8c18f9158a4b83e0fb3
--- Riskeer/Common/src/Riskeer.Common.Forms/Views/CalculationsView.cs (.../CalculationsView.cs) (revision be15aaeb0579324b4486a2816278c601bfea9523)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Views/CalculationsView.cs (.../CalculationsView.cs) (revision 2ce9847b42ca47fc9008c8c18f9158a4b83e0fb3)
@@ -40,7 +40,7 @@
/// Base view for configuring calculations.
///
/// The type of calculation.
- /// /// The type of the calculation input.
+ /// The type of the calculation input.
/// The type of the calculation row.
/// The type of the failure mechanism.
public abstract partial class CalculationsView : UserControl, ISelectionProvider, IView
@@ -189,6 +189,9 @@
///
protected abstract void GenerateCalculations();
+ ///
+ /// Initializes the columns
+ ///
protected virtual void InitializeDataGridView()
{
DataGridViewControl.CurrentRowChanged += DataGridViewOnCurrentRowChangedHandler;
@@ -205,42 +208,71 @@
nameof(DataGridViewComboBoxItemWrapper.DisplayName));
}
- private void UpdateDataGridViewDataSource()
+ ///
+ /// Initializes the observers.
+ ///
+ protected virtual void InitializeObservers()
{
- // Skip changes coming from the view itself
- if (DataGridViewControl.IsCurrentCellInEditMode)
+ failureMechanismObserver = new Observer(UpdateSectionsListBox)
{
- DataGridViewControl.AutoResizeColumns();
- }
-
- if (!(listBox.SelectedItem is FailureMechanismSection failureMechanismSection))
+ Observable = FailureMechanism
+ };
+ hydraulicBoundaryLocationsObserver = new Observer(() =>
{
- DataGridViewControl.SetDataSource(null);
- return;
- }
+ PrefillComboBoxListItemsAtColumnLevel();
+ UpdateComboBoxColumns();
+ })
+ {
+ Observable = AssessmentSection.HydraulicBoundaryDatabase.Locations
+ };
- IEnumerable lineSegments = Math2D.ConvertPointsToLineSegments(failureMechanismSection.Points);
- IEnumerable calculations = calculationGroup
- .GetCalculations()
- .OfType()
- .Where(cs => IsCalculationIntersectionWithReferenceLineInSection(cs, lineSegments));
-
- PrefillComboBoxListItemsAtColumnLevel();
-
- List dataSource = calculations.Select(CreateRow).ToList();
- DataGridViewControl.SetDataSource(dataSource);
- DataGridViewControl.ClearCurrentCell();
-
- UpdateColumns();
+ // The concat is needed to observe the input of calculations in child groups.
+ inputObserver = new RecursiveObserver(UpdateDataGridViewDataSource, pcg => pcg.Children.Concat