Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/FailureMechanismSectionResultRowHelper.cs =================================================================== diff -u -raa12e51508c8913061afe7cfd707bee0434be0ba -re328ec3e8da13dbceb282e09e103871f543bbe3f --- Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/FailureMechanismSectionResultRowHelper.cs (.../FailureMechanismSectionResultRowHelper.cs) (revision aa12e51508c8913061afe7cfd707bee0434be0ba) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/FailureMechanismSectionResultRowHelper.cs (.../FailureMechanismSectionResultRowHelper.cs) (revision e328ec3e8da13dbceb282e09e103871f543bbe3f) @@ -172,6 +172,18 @@ } /// + /// Helper method that determines whether the tailor made assessment + /// is . + /// + /// The tailor made assessment result to check. + /// true when the tailor made assessment + /// is , false otherwise. + public static bool TailorMadeAssessmentResultIsProbability(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType tailorMadeAssessmentResult) + { + return tailorMadeAssessmentResult == TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Probability; + } + + /// /// Helper method that sets the style of a based on a /// . /// Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/FailureMechanismSectionResultRowHelperTest.cs =================================================================== diff -u -raa12e51508c8913061afe7cfd707bee0434be0ba -re328ec3e8da13dbceb282e09e103871f543bbe3f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/FailureMechanismSectionResultRowHelperTest.cs (.../FailureMechanismSectionResultRowHelperTest.cs) (revision aa12e51508c8913061afe7cfd707bee0434be0ba) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/FailureMechanismSectionResultRowHelperTest.cs (.../FailureMechanismSectionResultRowHelperTest.cs) (revision e328ec3e8da13dbceb282e09e103871f543bbe3f) @@ -201,6 +201,22 @@ } [Test] + [TestCase(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.None, false)] + [TestCase(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.NotAssessed, false)] + [TestCase(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Probability, true)] + [TestCase(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Sufficient, false)] + [TestCase(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Insufficient, false)] + public void TailorMadeAssessmentResultIsProbability_WithTailorMadeAssessmentProbabilityAndDetailedCalculationResultType_ReturnsExpectedResult( + TailorMadeAssessmentProbabilityAndDetailedCalculationResultType tailorMadeAssessmentResult, bool expectedIsProbability) + { + // Call + bool isProbability = FailureMechanismSectionResultRowHelper.TailorMadeAssessmentResultIsProbability(tailorMadeAssessmentResult); + + // Assert + Assert.AreEqual(expectedIsProbability, isProbability); + } + + [Test] public void SetAssemblyCategoryGroupStyle_DataGridViewColumnStateDefinitionNull_ThrowsArgumentNullException() { // Call Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r5785cc13c0454eaabed7ede4dad8e885db7efd50 -re328ec3e8da13dbceb282e09e103871f543bbe3f --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 5785cc13c0454eaabed7ede4dad8e885db7efd50) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision e328ec3e8da13dbceb282e09e103871f543bbe3f) @@ -21,7 +21,6 @@ using System; using System.ComponentModel; -using System.Drawing; using Core.Common.Controls.DataGrid; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssessmentSection; @@ -380,112 +379,43 @@ { bool simpleAssessmentSufficient = FailureMechanismSectionResultRowHelper.SimpleAssessmentIsSufficient(SimpleAssessmentResult); - SetColumnState(simpleAssessmentResultIndex, UseManualAssemblyCategoryGroup); - SetColumnState(detailedAssessmentResultIndex, simpleAssessmentSufficient || UseManualAssemblyCategoryGroup); - SetColumnState(detailedAssessmentProbabilityIndex, simpleAssessmentSufficient || GetDetailedAssessmentResultIsNotProbability() || UseManualAssemblyCategoryGroup); - SetColumnState(tailorMadeAssessmentResultIndex, simpleAssessmentSufficient || UseManualAssemblyCategoryGroup); - SetColumnState(tailorMadeAssessmentProbabilityIndex, simpleAssessmentSufficient || GetTailorMadeAssessmentResultIsNotProbability() || UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[simpleAssessmentResultIndex], UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[detailedAssessmentResultIndex], + simpleAssessmentSufficient || UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[detailedAssessmentProbabilityIndex], + simpleAssessmentSufficient + || !FailureMechanismSectionResultRowHelper.DetailedAssessmentResultIsProbability(DetailedAssessmentResult) + || UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[tailorMadeAssessmentResultIndex], + simpleAssessmentSufficient || UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[tailorMadeAssessmentProbabilityIndex], + simpleAssessmentSufficient + || !FailureMechanismSectionResultRowHelper.TailorMadeAssessmentResultIsProbability(TailorMadeAssessmentResult) + || UseManualAssemblyCategoryGroup); if (UseManualAssemblyCategoryGroup) { - DisableColumn(simpleAssemblyCategoryGroupIndex); - DisableColumn(detailedAssemblyCategoryGroupIndex); - DisableColumn(tailorMadeAssemblyCategoryGroupIndex); - DisableColumn(combinedAssemblyCategoryGroupIndex); + FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex]); + FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[detailedAssemblyCategoryGroupIndex]); + FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex]); + FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex]); } else { - SetAssemblyCategoryGroupStyle(simpleAssemblyCategoryGroupIndex, SimpleAssemblyCategoryGroup); - SetAssemblyCategoryGroupStyle(detailedAssemblyCategoryGroupIndex, DetailedAssemblyCategoryGroup); - SetAssemblyCategoryGroupStyle(tailorMadeAssemblyCategoryGroupIndex, TailorMadeAssemblyCategoryGroup); - SetAssemblyCategoryGroupStyle(combinedAssemblyCategoryGroupIndex, CombinedAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex], + SimpleAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[detailedAssemblyCategoryGroupIndex], + DetailedAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex], + TailorMadeAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex], + CombinedAssemblyCategoryGroup); } - SetColumnState(manualAssemblyCategoryGroupIndex, !UseManualAssemblyCategoryGroup); + FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[manualAssemblyCategoryGroupIndex], !UseManualAssemblyCategoryGroup); } /// - /// Sets the style of the column state definition on the given . - /// - /// The index of the column state definition. - /// The category group to get the color for. - /// A . - /// Thrown when - /// is a valid value, but unsupported. - private void SetAssemblyCategoryGroupStyle(int index, FailureMechanismSectionAssemblyCategoryGroup assemblyCategoryGroup) - { - ColumnStateDefinitions[index].Style = new CellStyle( - Color.FromKnownColor(KnownColor.ControlText), - GetCategoryGroupColor(assemblyCategoryGroup)); - } - - /// - /// Gets the color based on the . - /// - /// The category group to get the color for. - /// A . - /// Thrown when - /// is a valid value, but unsupported. - private static Color GetCategoryGroupColor(FailureMechanismSectionAssemblyCategoryGroup categoryGroup) - { - switch (categoryGroup) - { - case FailureMechanismSectionAssemblyCategoryGroup.Iv: - return Color.FromArgb(0, 255, 0); - case FailureMechanismSectionAssemblyCategoryGroup.IIv: - return Color.FromArgb(118, 147, 60); - case FailureMechanismSectionAssemblyCategoryGroup.IIIv: - return Color.FromArgb(255, 255, 0); - case FailureMechanismSectionAssemblyCategoryGroup.IVv: - return Color.FromArgb(204, 192, 218); - case FailureMechanismSectionAssemblyCategoryGroup.Vv: - return Color.FromArgb(255, 153, 0); - case FailureMechanismSectionAssemblyCategoryGroup.VIv: - return Color.FromArgb(255, 0, 0); - case FailureMechanismSectionAssemblyCategoryGroup.VIIv: - case FailureMechanismSectionAssemblyCategoryGroup.None: - case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable: - return Color.FromArgb(255, 255, 255); - default: - throw new NotSupportedException(); - } - } - - private void SetColumnState(int columnIndex, bool shouldDisable) - { - if (shouldDisable) - { - DisableColumn(columnIndex); - } - else - { - EnableColumn(columnIndex); - } - } - - private void EnableColumn(int index) - { - ColumnStateDefinitions[index].ReadOnly = false; - ColumnStateDefinitions[index].Style = CellStyle.Enabled; - } - - private void DisableColumn(int index) - { - ColumnStateDefinitions[index].ReadOnly = true; - ColumnStateDefinitions[index].Style = CellStyle.Disabled; - } - - private bool GetDetailedAssessmentResultIsNotProbability() - { - return DetailedAssessmentResult != DetailedAssessmentResultType.Probability; - } - - private bool GetTailorMadeAssessmentResultIsNotProbability() - { - return TailorMadeAssessmentResult != TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Probability; - } - - /// /// Class holding the various construction parameters for . /// public class ConstructionProperties