Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs =================================================================== diff -u -r6cea962d14f1602ada21ad7a7e3a797d426d3722 -rf419c811044695e9a3a7dd9729d9e25d3705a67a --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 6cea962d14f1602ada21ad7a7e3a797d426d3722) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision f419c811044695e9a3a7dd9729d9e25d3705a67a) @@ -25,9 +25,9 @@ using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionInwards.Data; -using Ringtoets.GrassCoverErosionInwards.Forms.Properties; using CoreCommonResources = Core.Common.Base.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -48,7 +48,7 @@ /// public GrassCoverErosionInwardsFailureMechanismResultView() { - DataGridViewControl.AddCellFormattingHandler(ShowAssessmentLayerTwoAErrors); + DataGridViewControl.AddCellFormattingHandler(ShowAssessmentLayerErrors); DataGridViewControl.AddCellFormattingHandler(DisableIrrelevantFieldsFormatting); // The concat is needed to observe the input of calculations in child groups. @@ -86,7 +86,7 @@ protected override void Dispose(bool disposing) { - DataGridViewControl.RemoveCellFormattingHandler(ShowAssessmentLayerTwoAErrors); + DataGridViewControl.RemoveCellFormattingHandler(ShowAssessmentLayerErrors); DataGridViewControl.RemoveCellFormattingHandler(DisableIrrelevantFieldsFormatting); calculationInputObserver.Dispose(); @@ -134,58 +134,24 @@ } } - private void ShowAssessmentLayerTwoAErrors(object sender, DataGridViewCellFormattingEventArgs e) + private void ShowAssessmentLayerErrors(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex != assessmentLayerTwoAIndex) { return; } - DataGridViewCell currentDataGridViewCell = DataGridViewControl.GetCell(e.RowIndex, e.ColumnIndex); - var resultRow = (GrassCoverErosionInwardsFailureMechanismSectionResultRow) GetDataAtRow(e.RowIndex); if (resultRow != null) { + DataGridViewCell currentDataGridViewCell = DataGridViewControl.GetCell(e.RowIndex, e.ColumnIndex); GrassCoverErosionInwardsCalculation normativeCalculation = resultRow.GetSectionResultCalculation(); - if (resultRow.AssessmentLayerOne) - { - currentDataGridViewCell.ErrorText = string.Empty; - return; - } - - if (normativeCalculation == null) - { - currentDataGridViewCell.ErrorText = Resources.GrassCoverErosionInwardsFailureMechanismResultView_Calculation_not_set; - return; - } - - CalculationScenarioStatus calculationScenarioStatus = GetCalculationStatus(normativeCalculation); - if (calculationScenarioStatus == CalculationScenarioStatus.NotCalculated) - { - currentDataGridViewCell.ErrorText = Resources.GrassCoverErosionInwardsFailureMechanismResultView_Calculation_not_calculated; - return; - } - if (calculationScenarioStatus == CalculationScenarioStatus.Failed) - { - currentDataGridViewCell.ErrorText = Resources.GrassCoverErosionInwardsFailureMechanismResultView_Calculation_not_successful; - return; - } - currentDataGridViewCell.ErrorText = string.Empty; + FailureMechanismSectionResultRowHelper.ShowAssessmentLayerTwoAErrors(currentDataGridViewCell, + resultRow.AssessmentLayerOne, + resultRow.AssessmentLayerTwoA, + normativeCalculation); } } - - private static CalculationScenarioStatus GetCalculationStatus(GrassCoverErosionInwardsCalculation calculation) - { - if (calculation.HasOutput) - { - if (double.IsNaN(calculation.Output.ProbabilityAssessmentOutput.Probability)) - { - return CalculationScenarioStatus.Failed; - } - return CalculationScenarioStatus.Done; - } - return CalculationScenarioStatus.NotCalculated; - } } } \ No newline at end of file