Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/Views/HeightStructuresCalculationRow.cs =================================================================== diff -u -r4dbfc3443ef265507d760ae2446d525536213820 -ra445fb68da7b3e3c2feca278d69b9508638af02a --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/Views/HeightStructuresCalculationRow.cs (.../HeightStructuresCalculationRow.cs) (revision 4dbfc3443ef265507d760ae2446d525536213820) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/Views/HeightStructuresCalculationRow.cs (.../HeightStructuresCalculationRow.cs) (revision a445fb68da7b3e3c2feca278d69b9508638af02a) @@ -56,8 +56,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(); @@ -72,18 +86,22 @@ set { ForeshoreProfile valueToSet = value?.WrappedObject; + if (!ReferenceEquals(Calculation.InputParameters.ForeshoreProfile, valueToSet)) { - PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.ForeshoreProfile = valueToSet, PropertyChangeHandler); - UpdateUseBreakWaterColumnStateDefinitions(); - UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); - UpdateUseForeshoreColumnStateDefinitions(); + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + Calculation.InputParameters.ForeshoreProfile = valueToSet; + UpdateUseBreakWaterColumnStateDefinitions(); + UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + UpdateUseForeshoreColumnStateDefinitions(); + }, PropertyChangeHandler); } } } /// - /// 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 { @@ -92,8 +110,11 @@ { if (!Calculation.InputParameters.UseBreakWater.Equals(value)) { - PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseBreakWater = value, PropertyChangeHandler); - UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + Calculation.InputParameters.UseBreakWater = value; + UpdateBreakWaterTypeAndHeightColumnStateDefinitions(); + }, PropertyChangeHandler); } } } @@ -129,7 +150,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 { @@ -139,7 +160,6 @@ if (!Calculation.InputParameters.UseForeshore.Equals(value)) { PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseForeshore = value, PropertyChangeHandler); - UpdateUseForeshoreColumnStateDefinitions(); } } } @@ -202,18 +222,25 @@ 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()); + ForeshoreProfile foreShoreProfileGeometry = Calculation.InputParameters.ForeshoreProfile; + + if (foreShoreProfileGeometry == null) + { + ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); + } + else + { + ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); + } } private void UpdateBreakWaterTypeAndHeightColumnStateDefinitions() { ForeshoreProfile foreShoreProfileGeometry = Calculation.InputParameters.ForeshoreProfile; - if (!UseBreakWater || foreShoreProfileGeometry == null) + + if (foreShoreProfileGeometry == null || !UseBreakWater) { ColumnStateHelper.DisableColumn(ColumnStateDefinitions[breakWaterTypeColumnIndex]); ColumnStateHelper.DisableColumn(ColumnStateDefinitions[breakWaterHeightColumnIndex]); @@ -228,6 +255,7 @@ private void UpdateUseForeshoreColumnStateDefinitions() { ForeshoreProfile foreShoreProfileGeometry = Calculation.InputParameters.ForeshoreProfile; + if (foreShoreProfileGeometry == null || !foreShoreProfileGeometry.Geometry.Any()) { ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]); @@ -237,18 +265,5 @@ ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]); } } - - private void UpdateUseBreakWaterColumnStateDefinitions() - { - ForeshoreProfile foreShoreProfileGeometry = Calculation.InputParameters.ForeshoreProfile; - if (foreShoreProfileGeometry == null) - { - ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); - } - else - { - ColumnStateHelper.EnableColumn(ColumnStateDefinitions[useBreakWaterColumnIndex]); - } - } } } \ No newline at end of file