Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs =================================================================== diff -u -r8b712b8935477a50d1a008769d6f0f3bc582128a -r0bd000e4797b7d6436792aca12b6e531c521d450 --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs (.../GrassCoverErosionInwardsCalculationRow.cs) (revision 8b712b8935477a50d1a008769d6f0f3bc582128a) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationRow.cs (.../GrassCoverErosionInwardsCalculationRow.cs) (revision 0bd000e4797b7d6436792aca12b6e531c521d450) @@ -60,8 +60,22 @@ IObservablePropertyChangeHandler handler) : base(calculationScenario, handler) { - ColumnStateDefinitions = new Dictionary(); - CreateColumnStateDefinitions(); + ColumnStateDefinitions = new Dictionary + { + { + useBreakWaterColumnIndex, new DataGridViewColumnStateDefinition() + }, + { + breakWaterTypeColumnIndex, new DataGridViewColumnStateDefinition() + }, + { + breakWaterHeightColumnIndex, new DataGridViewColumnStateDefinition() + }, + { + useForeshoreColumnIndex, new DataGridViewColumnStateDefinition() + } + }; + UpdateUseBreakWaterColumnStateDefinitions(); UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); UpdateUseForeshoreColumnStateDefinitions(); @@ -78,16 +92,20 @@ DikeProfile valueToSet = value?.WrappedObject; if (!ReferenceEquals(Calculation.InputParameters.DikeProfile, valueToSet)) { - PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.DikeProfile = valueToSet, PropertyChangeHandler); - UpdateUseBreakWaterColumnStateDefinitions(); - UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + Calculation.InputParameters.DikeProfile = valueToSet; + UpdateUseBreakWaterColumnStateDefinitions(); + UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + UpdateUseForeshoreColumnStateDefinitions(); + }, PropertyChangeHandler); DikeProfileChanged?.Invoke(this, EventArgs.Empty); } } } /// - /// Gets or sets whether break water of the should be used. + /// Gets or sets whether the break water of the should be used. /// public bool UseBreakWater { @@ -96,8 +114,11 @@ { if (!Calculation.InputParameters.UseBreakWater.Equals(value)) { - PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseBreakWater = value, PropertyChangeHandler); - UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + Calculation.InputParameters.UseBreakWater = value; + UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + }, PropertyChangeHandler); } } } @@ -133,7 +154,7 @@ } /// - /// Gets or sets whether foreshore profile of the should be used. + /// Gets or sets whether the foreshore profile of the should be used. /// public bool UseForeshoreGeometry { @@ -143,7 +164,6 @@ if (!Calculation.InputParameters.UseForeshore.Equals(value)) { PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseForeshore = value, PropertyChangeHandler); - UpdateUseForeshoreColumnStateDefinitions(); } } } @@ -206,17 +226,24 @@ set => Calculation.InputParameters.HydraulicBoundaryLocation = value; } - private void CreateColumnStateDefinitions() + private void UpdateUseBreakWaterColumnStateDefinitions() { - ColumnStateDefinitions.Add(useBreakWaterColumnIndex, new DataGridViewColumnStateDefinition()); - ColumnStateDefinitions.Add(breakWaterTypeColumnIndex, new DataGridViewColumnStateDefinition()); - ColumnStateDefinitions.Add(breakWaterHeightColumnIndex, new DataGridViewColumnStateDefinition()); - ColumnStateDefinitions.Add(useForeshoreColumnIndex, new DataGridViewColumnStateDefinition()); + DikeProfile dikeProfile = Calculation.InputParameters.DikeProfile; + + if (dikeProfile == null) + { + ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); + } + else + { + ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); + } } private void UpdateBreakWaterTypeAndHeightColumnStateDefinitions() { DikeProfile dikeProfile = Calculation.InputParameters.DikeProfile; + if (!UseBreakWater || dikeProfile == null) { ColumnStateHelper.DisableColumn(ColumnStateDefinitions[breakWaterTypeColumnIndex]); @@ -232,6 +259,7 @@ private void UpdateUseForeshoreColumnStateDefinitions() { DikeProfile dikeProfile = Calculation.InputParameters.DikeProfile; + if (dikeProfile == null || !dikeProfile.ForeshoreGeometry.Any()) { ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]); @@ -241,18 +269,5 @@ ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]); } } - - private void UpdateUseBreakWaterColumnStateDefinitions() - { - DikeProfile dikeProfile = Calculation.InputParameters.DikeProfile; - if (dikeProfile == null) - { - ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); - } - else - { - ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); - } - } } } \ No newline at end of file