Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs
===================================================================
diff -u -rc225ac27cdfd5aec62bbbc783762f275cd15fdd2 -r8dbe77c4864b019630360007c972593b2e91a753
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs (.../GrassCoverErosionInwardsCalculationRow.cs) (revision c225ac27cdfd5aec62bbbc783762f275cd15fdd2)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs (.../GrassCoverErosionInwardsCalculationRow.cs) (revision 8dbe77c4864b019630360007c972593b2e91a753)
@@ -23,223 +23,179 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
using Riskeer.Common.Data.DikeProfiles;
using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Forms.ChangeHandlers;
using Riskeer.Common.Forms.Helpers;
-using Riskeer.Common.Forms.PresentationObjects;
using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Common.Forms.Views;
using Riskeer.GrassCoverErosionInwards.Data;
namespace Riskeer.GrassCoverErosionInwards.Forms.Views
{
///
/// This class represents a row in the .
///
- internal class GrassCoverErosionInwardsCalculationRow : IHasColumnStateDefinitions
+ public class GrassCoverErosionInwardsCalculationRow : CalculationRow, IHasColumnStateDefinitions
{
private const int breakWaterTypeColumnIndex = 4;
private const int breakWaterHeightColumnIndex = 5;
private const int useForeshoreColumnIndex = 6;
- private readonly IObservablePropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
///
- /// The this row contains.
+ /// The this row contains.
/// The handler responsible for handling effects of a property change.
/// Thrown when any parameter is null.
- public GrassCoverErosionInwardsCalculationRow(GrassCoverErosionInwardsCalculationScenario calculationScenario,
- IObservablePropertyChangeHandler handler)
+ internal GrassCoverErosionInwardsCalculationRow(GrassCoverErosionInwardsCalculationScenario calculationScenario,
+ IObservablePropertyChangeHandler handler) :
+ base(calculationScenario, handler)
{
- if (calculationScenario == null)
- {
- throw new ArgumentNullException(nameof(calculationScenario));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- CalculationScenario = calculationScenario;
- propertyChangeHandler = handler;
ColumnStateDefinitions = new Dictionary();
CreateColumnStateDefinitions();
UpdateUseBreakWaterColumnStateDefinitions();
UpdateUseForeshoreColumnStateDefinitions();
}
///
- /// Gets the this row contains.
+ /// Gets or sets the dike profile of the .
///
- public GrassCoverErosionInwardsCalculationScenario CalculationScenario { get; }
-
- ///
- /// Gets or sets the name of the .
- ///
- public string Name
- {
- get => CalculationScenario.Name;
- set
- {
- CalculationScenario.Name = value;
-
- CalculationScenario.NotifyObservers();
- }
- }
-
- ///
- /// Gets or sets the hydraulic boundary location of the .
- ///
- public DataGridViewComboBoxItemWrapper SelectableHydraulicBoundaryLocation
- {
- get
- {
- if (CalculationScenario.InputParameters.HydraulicBoundaryLocation == null)
- {
- return new DataGridViewComboBoxItemWrapper(null);
- }
-
- return new DataGridViewComboBoxItemWrapper(
- new SelectableHydraulicBoundaryLocation(CalculationScenario.InputParameters.HydraulicBoundaryLocation, null));
- }
- set
- {
- HydraulicBoundaryLocation valueToSet = value?.WrappedObject?.HydraulicBoundaryLocation;
- if (!ReferenceEquals(CalculationScenario.InputParameters.HydraulicBoundaryLocation, valueToSet))
- {
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.HydraulicBoundaryLocation = valueToSet, propertyChangeHandler);
- }
- }
- }
-
- ///
- /// Gets or sets the dike profile of the .
- ///
public DataGridViewComboBoxItemWrapper DikeProfile
{
- get => new DataGridViewComboBoxItemWrapper(CalculationScenario.InputParameters.DikeProfile);
+ get => new DataGridViewComboBoxItemWrapper(Calculation.InputParameters.DikeProfile);
set
{
DikeProfile valueToSet = value?.WrappedObject;
- if (!ReferenceEquals(CalculationScenario.InputParameters.DikeProfile, valueToSet))
+ if (!ReferenceEquals(Calculation.InputParameters.DikeProfile, valueToSet))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.DikeProfile = valueToSet, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.DikeProfile = valueToSet, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets whether break water of the should be used.
+ /// Gets or sets whether break water of the should be used.
///
public bool UseBreakWater
{
- get => CalculationScenario.InputParameters.UseBreakWater;
+ get => Calculation.InputParameters.UseBreakWater;
set
{
- if (!CalculationScenario.InputParameters.UseBreakWater.Equals(value))
+ if (!Calculation.InputParameters.UseBreakWater.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseBreakWater = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseBreakWater = value, PropertyChangeHandler);
UpdateUseBreakWaterColumnStateDefinitions();
}
}
}
///
- /// Gets or sets the break water type of the .
+ /// Gets or sets the break water type of the .
///
public BreakWaterType BreakWaterType
{
- get => CalculationScenario.InputParameters.BreakWater.Type;
+ get => Calculation.InputParameters.BreakWater.Type;
set
{
- if (!CalculationScenario.InputParameters.BreakWater.Type.Equals(value))
+ if (!Calculation.InputParameters.BreakWater.Type.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Type = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.BreakWater.Type = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the break water height of the .
+ /// Gets or sets the break water height of the .
///
public RoundedDouble BreakWaterHeight
{
- get => CalculationScenario.InputParameters.BreakWater.Height;
+ get => Calculation.InputParameters.BreakWater.Height;
set
{
- if (!CalculationScenario.InputParameters.BreakWater.Height.Equals(value))
+ if (!Calculation.InputParameters.BreakWater.Height.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Height = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.BreakWater.Height = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets whether foreshore profile of the should be used.
+ /// Gets or sets whether foreshore profile of the should be used.
///
public bool UseForeshoreGeometry
{
- get => CalculationScenario.InputParameters.UseForeshore;
+ get => Calculation.InputParameters.UseForeshore;
set
{
- if (!CalculationScenario.InputParameters.UseForeshore.Equals(value))
+ if (!Calculation.InputParameters.UseForeshore.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseForeshore = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseForeshore = value, PropertyChangeHandler);
UpdateUseForeshoreColumnStateDefinitions();
}
}
}
///
- /// Gets or sets the dike height of the .
+ /// Gets or sets the dike height of the .
///
public RoundedDouble DikeHeight
{
- get => CalculationScenario.InputParameters.DikeHeight;
+ get => Calculation.InputParameters.DikeHeight;
set
{
- if (!CalculationScenario.InputParameters.DikeHeight.Equals(value))
+ if (!Calculation.InputParameters.DikeHeight.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.DikeHeight = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.DikeHeight = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the mean critical flow rate of the .
+ /// Gets or sets the mean critical flow rate of the .
///
public RoundedDouble MeanCriticalFlowRate
{
- get => CalculationScenario.InputParameters.CriticalFlowRate.Mean;
+ get => Calculation.InputParameters.CriticalFlowRate.Mean;
set
{
- if (!CalculationScenario.InputParameters.CriticalFlowRate.Mean.Equals(value))
+ if (!Calculation.InputParameters.CriticalFlowRate.Mean.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.CriticalFlowRate.Mean = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.CriticalFlowRate.Mean = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the standard deviation critical flow rate of the .
+ /// Gets or sets the standard deviation critical flow rate of the .
///
public RoundedDouble StandardDeviationCriticalFlowRate
{
- get => CalculationScenario.InputParameters.CriticalFlowRate.StandardDeviation;
+ get => Calculation.InputParameters.CriticalFlowRate.StandardDeviation;
set
{
- if (!CalculationScenario.InputParameters.CriticalFlowRate.StandardDeviation.Equals(value))
+ if (!Calculation.InputParameters.CriticalFlowRate.StandardDeviation.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.CriticalFlowRate.StandardDeviation = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.CriticalFlowRate.StandardDeviation = value, PropertyChangeHandler);
}
}
}
public IDictionary ColumnStateDefinitions { get; }
+ public override Point2D GetCalculationLocation()
+ {
+ return Calculation.InputParameters.DikeProfile?.WorldReferencePoint;
+ }
+
+ protected override HydraulicBoundaryLocation HydraulicBoundaryLocation
+ {
+ get => Calculation.InputParameters.HydraulicBoundaryLocation;
+ set => Calculation.InputParameters.HydraulicBoundaryLocation = value;
+ }
+
private void CreateColumnStateDefinitions()
{
ColumnStateDefinitions.Add(breakWaterTypeColumnIndex, new DataGridViewColumnStateDefinition());
@@ -263,7 +219,7 @@
private void UpdateUseForeshoreColumnStateDefinitions()
{
- DikeProfile dikeProfileForeshoreGeometry = CalculationScenario.InputParameters.DikeProfile;
+ DikeProfile dikeProfileForeshoreGeometry = Calculation.InputParameters.DikeProfile;
if (dikeProfileForeshoreGeometry == null || !dikeProfileForeshoreGeometry.ForeshoreGeometry.Any())
{
ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]);
Fisheye: Tag 8dbe77c4864b019630360007c972593b2e91a753 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs
===================================================================
diff -u -rc237d392efd465a39343760f0b7409cd6861b18a -r8dbe77c4864b019630360007c972593b2e91a753
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs (.../GrassCoverErosionInwardsCalculationsView.cs) (revision c237d392efd465a39343760f0b7409cd6861b18a)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs (.../GrassCoverErosionInwardsCalculationsView.cs) (revision 8dbe77c4864b019630360007c972593b2e91a753)
@@ -26,16 +26,13 @@
using Core.Common.Base;
using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
-using Core.Common.Controls.Views;
using Core.Common.Util;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.DikeProfiles;
-using Riskeer.Common.Data.FailureMechanism;
-using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Forms.ChangeHandlers;
using Riskeer.Common.Forms.Helpers;
-using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Common.Forms.Views;
using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects;
using Riskeer.GrassCoverErosionInwards.Forms.Properties;
@@ -46,23 +43,12 @@
///
/// This class is a view for configuring grass cover erosion inwards calculations.
///
- public partial class GrassCoverErosionInwardsCalculationsView : UserControl, ISelectionProvider, IView
+ public class GrassCoverErosionInwardsCalculationsView : CalculationsView
{
- private const int selectableHydraulicBoundaryLocationColumnIndex = 1;
private const int selectableDikeProfileColumnIndex = 2;
- private readonly IAssessmentSection assessmentSection;
- private readonly GrassCoverErosionInwardsFailureMechanism failureMechanism;
- private Observer failureMechanismObserver;
- private Observer hydraulicBoundaryLocationsObserver;
- private Observer dikeProfilesObserver;
- private RecursiveObserver inputObserver;
- private RecursiveObserver calculationScenarioObserver;
- private RecursiveObserver calculationGroupObserver;
- private CalculationGroup calculationGroup;
+ private readonly Observer dikeProfilesObserver;
- public event EventHandler SelectionChanged;
-
///
/// Creates a new instance of .
///
@@ -71,298 +57,166 @@
/// The assessment section.
/// Thrown when any parameter is null.
public GrassCoverErosionInwardsCalculationsView(CalculationGroup data, GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ : base(data, failureMechanism, assessmentSection)
{
- if (data == null)
+ dikeProfilesObserver = new Observer(() =>
{
- throw new ArgumentNullException(nameof(data));
- }
-
- if (failureMechanism == null)
+ PrefillComboBoxListItemsAtColumnLevel();
+ UpdateColumns();
+ UpdateGenerateCalculationsButtonState();
+ })
{
- throw new ArgumentNullException(nameof(failureMechanism));
- }
+ Observable = FailureMechanism.DikeProfiles
+ };
+ }
- if (assessmentSection == null)
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ DataGridViewControl.CellFormatting += HandleCellStyling;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- throw new ArgumentNullException(nameof(assessmentSection));
+ dikeProfilesObserver.Dispose();
}
- this.failureMechanism = failureMechanism;
- this.assessmentSection = assessmentSection;
- calculationGroup = data;
+ base.Dispose(disposing);
+ }
- InitializeObservers();
+ protected override object CreateSelectedItemFromCurrentRow(GrassCoverErosionInwardsCalculationRow currentRow)
+ {
+ return new GrassCoverErosionInwardsInputContext(
+ currentRow.Calculation.InputParameters,
+ currentRow.Calculation,
+ FailureMechanism,
+ AssessmentSection);
+ }
- InitializeComponent();
- InitializeListBox();
- InitializeDataGridView();
-
- UpdateSectionsListBox();
- UpdateDataGridViewDataSource();
- UpdateSelectableHydraulicBoundaryLocationsColumn();
- UpdateDikeProfilesColumn();
- UpdateGenerateCalculationsButtonState();
+ protected override IEnumerable GetReferenceLocations()
+ {
+ return FailureMechanism.DikeProfiles.Select(dp => dp.WorldReferencePoint);
}
- public object Selection => CreateSelectedItemFromCurrentRow();
-
- public object Data
+ protected override bool IsCalculationIntersectionWithReferenceLineInSection(GrassCoverErosionInwardsCalculationScenario calculation, IEnumerable lineSegments)
{
- get => calculationGroup;
- set => calculationGroup = value as CalculationGroup;
+ return calculation.IsDikeProfileIntersectionWithReferenceLineInSection(lineSegments);
}
- protected override void OnLoad(EventArgs e)
+ protected override GrassCoverErosionInwardsCalculationRow CreateRow(GrassCoverErosionInwardsCalculationScenario calculation)
{
- // Necessary to correctly load the content of the dropdown lists of the comboboxes...
- UpdateDataGridViewDataSource();
+ return new GrassCoverErosionInwardsCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, calculation.InputParameters));
+ }
- base.OnLoad(e);
-
- dataGridViewControl.CellFormatting += HandleCellStyling;
+ protected override bool CanGenerateCalculations()
+ {
+ return FailureMechanism.DikeProfiles.Any();
}
- protected override void Dispose(bool disposing)
+ protected override void GenerateCalculations()
{
- if (disposing)
+ var calculationGroup = (CalculationGroup) Data;
+ using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(Parent, FailureMechanism.DikeProfiles))
{
- failureMechanismObserver.Dispose();
- inputObserver.Dispose();
- calculationScenarioObserver.Dispose();
- calculationGroupObserver.Dispose();
+ dialog.ShowDialog();
- hydraulicBoundaryLocationsObserver.Dispose();
- dikeProfilesObserver.Dispose();
-
- components?.Dispose();
+ if (dialog.SelectedItems.Any())
+ {
+ GrassCoverErosionInwardsCalculationConfigurationHelper.GenerateCalculations(calculationGroup, dialog.SelectedItems);
+ calculationGroup.NotifyObservers();
+ }
}
-
- base.Dispose(disposing);
}
- private void InitializeDataGridView()
+ protected override void InitializeDataGridView()
{
- dataGridViewControl.CurrentRowChanged += DataGridViewOnCurrentRowChangedHandler;
+ base.InitializeDataGridView();
- dataGridViewControl.AddTextBoxColumn(
- nameof(GrassCoverErosionInwardsCalculationRow.Name),
- RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName);
-
- dataGridViewControl.AddComboBoxColumn>(
- nameof(GrassCoverErosionInwardsCalculationRow.SelectableHydraulicBoundaryLocation),
- RiskeerCommonFormsResources.HydraulicBoundaryLocation_DisplayName,
- null,
- nameof(DataGridViewComboBoxItemWrapper.This),
- nameof(DataGridViewComboBoxItemWrapper.DisplayName));
-
- dataGridViewControl.AddComboBoxColumn>(
+ DataGridViewControl.AddComboBoxColumn>(
nameof(GrassCoverErosionInwardsCalculationRow.DikeProfile),
Resources.DikeProfile_DisplayName,
null,
nameof(DataGridViewComboBoxItemWrapper.This),
nameof(DataGridViewComboBoxItemWrapper.DisplayName));
- dataGridViewControl.AddCheckBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.UseBreakWater),
+ DataGridViewControl.AddCheckBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.UseBreakWater),
RiskeerCommonFormsResources.Use_BreakWater_DisplayName);
- dataGridViewControl.AddComboBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.BreakWaterType),
+ DataGridViewControl.AddComboBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.BreakWaterType),
RiskeerCommonFormsResources.CalculationsView_BreakWaterType_DisplayName,
EnumDisplayWrapperHelper.GetEnumTypes(),
nameof(EnumDisplayWrapper.Value),
nameof(EnumDisplayWrapper.DisplayName));
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(GrassCoverErosionInwardsCalculationRow.BreakWaterHeight),
RiskeerCommonFormsResources.CalculationsView_BreakWaterHeight_DisplayName);
- dataGridViewControl.AddCheckBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.UseForeshoreGeometry),
+ DataGridViewControl.AddCheckBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.UseForeshoreGeometry),
RiskeerCommonFormsResources.Use_Foreshore_DisplayName);
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(GrassCoverErosionInwardsCalculationRow.DikeHeight),
RiskeerCommonFormsResources.DikeHeight_DisplayName);
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(GrassCoverErosionInwardsCalculationRow.MeanCriticalFlowRate),
Resources.Mean_Critical_FlowRate_DisplayName);
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(GrassCoverErosionInwardsCalculationRow.StandardDeviationCriticalFlowRate),
Resources.StandardDeviation_Critical_FlowRate_DisplayName);
}
- private void InitializeListBox()
- {
- listBox.DisplayMember = nameof(FailureMechanismSection.Name);
- listBox.SelectedValueChanged += ListBoxOnSelectedValueChanged;
- }
+ #region Prefill combo box list items
- private void UpdateGenerateCalculationsButtonState()
+ protected override void PrefillComboBoxListItemsAtColumnLevel()
{
- buttonGenerateCalculations.Enabled = failureMechanism.DikeProfiles.Any();
- }
+ base.PrefillComboBoxListItemsAtColumnLevel();
- private GrassCoverErosionInwardsInputContext CreateSelectedItemFromCurrentRow()
- {
- DataGridViewRow currentRow = dataGridViewControl.CurrentRow;
+ // Need to prefill for all possible data in order to guarantee 'combo box' columns
+ // do not generate errors when their cell value is not present in the list of available
+ // items.
+ var selectableDikeProfileColumn = (DataGridViewComboBoxColumn) DataGridViewControl.GetColumnFromIndex(selectableDikeProfileColumnIndex);
- var calculationRow = (GrassCoverErosionInwardsCalculationRow) currentRow?.DataBoundItem;
-
- GrassCoverErosionInwardsInputContext selection = null;
- if (calculationRow != null)
+ using (new SuspendDataGridViewColumnResizes(selectableDikeProfileColumn))
{
- selection = new GrassCoverErosionInwardsInputContext(
- calculationRow.CalculationScenario.InputParameters,
- calculationRow.CalculationScenario,
- failureMechanism,
- assessmentSection);
+ SetItemsOnObjectCollection(selectableDikeProfileColumn.Items,
+ GetDikeProfileDataSource(FailureMechanism.DikeProfiles));
}
-
- return selection;
}
- private static void SetItemsOnObjectCollection(DataGridViewComboBoxCell.ObjectCollection objectCollection, object[] comboBoxItems)
- {
- objectCollection.Clear();
- objectCollection.AddRange(comboBoxItems);
- }
+ #endregion
- private static DataGridViewComboBoxItemWrapper[] GetSelectableHydraulicBoundaryLocationsDataSource(
- IEnumerable selectableHydraulicBoundaryLocations = null)
- {
- var dataGridViewComboBoxItemWrappers = new List>
- {
- new DataGridViewComboBoxItemWrapper(null)
- };
+ #region Event handling
- if (selectableHydraulicBoundaryLocations != null)
- {
- dataGridViewComboBoxItemWrappers.AddRange(selectableHydraulicBoundaryLocations.Select(hbl => new DataGridViewComboBoxItemWrapper(hbl)));
- }
-
- return dataGridViewComboBoxItemWrappers.ToArray();
- }
-
- private void InitializeObservers()
+ private void HandleCellStyling(object sender, DataGridViewCellFormattingEventArgs e)
{
- failureMechanismObserver = new Observer(OnFailureMechanismUpdate)
- {
- Observable = failureMechanism
- };
- hydraulicBoundaryLocationsObserver = new Observer(UpdateSelectableHydraulicBoundaryLocationsColumn)
- {
- Observable = assessmentSection.HydraulicBoundaryDatabase.Locations
- };
- dikeProfilesObserver = new Observer(() =>
- {
- UpdateDikeProfilesColumn();
- UpdateGenerateCalculationsButtonState();
- })
- {
- Observable = failureMechanism.DikeProfiles
- };
-
- // The concat is needed to observe the input of calculations in child groups.
- inputObserver = new RecursiveObserver(UpdateDataGridViewDataSource, pcg => pcg.Children.Concat