Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs =================================================================== diff -u -r590e1aeba4a1e5a622c8e8d89270167907920b43 -r34635692bc7437564e0f99ae64cc49a7208d7fad --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs (.../GrassCoverSlipOffInwardsResultView.cs) (revision 590e1aeba4a1e5a622c8e8d89270167907920b43) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs (.../GrassCoverSlipOffInwardsResultView.cs) (revision 34635692bc7437564e0f99ae64cc49a7208d7fad) @@ -19,18 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; -using System.Linq; -using System.Windows.Forms; using Core.Common.Base; -using Core.Common.Util; -using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.Builders; using Ringtoets.Common.Forms.Views; -using Ringtoets.Common.Primitives; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultRows; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.Views.SectionResultViews { @@ -40,69 +34,82 @@ public class GrassCoverSlipOffInwardsResultView : FailureMechanismResultView { + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int tailorMadeAssessmentResultIndex = 3; + private const int simpleAssemblyCategoryGroupIndex = 4; + private const int detailedAssemblyCategoryGroupIndex = 5; + private const int tailorMadeAssemblyCategoryGroupIndex = 6; + private const int combinedAssemblyCategoryGroupIndex = 7; + private const int manualAssemblyCategoryGroupIndex = 9; + /// /// /// Creates a new instance of . /// - public GrassCoverSlipOffInwardsResultView( - IObservableEnumerable failureMechanismSectionResults, - GrassCoverSlipOffInwardsFailureMechanism failureMechanism) + public GrassCoverSlipOffInwardsResultView(IObservableEnumerable failureMechanismSectionResults, + GrassCoverSlipOffInwardsFailureMechanism failureMechanism) : base(failureMechanismSectionResults, failureMechanism) {} - protected override GrassCoverSlipOffInwardsSectionResultRow CreateFailureMechanismSectionResultRow(GrassCoverSlipOffInwardsFailureMechanismSectionResult sectionResult) + protected override GrassCoverSlipOffInwardsSectionResultRow CreateFailureMechanismSectionResultRow( + GrassCoverSlipOffInwardsFailureMechanismSectionResult sectionResult) { - return new GrassCoverSlipOffInwardsSectionResultRow(sectionResult); + return new GrassCoverSlipOffInwardsSectionResultRow( + sectionResult, + new GrassCoverSlipOffInwardsSectionResultRow.ConstructionProperties + { + SimpleAssessmentResultIndex = simpleAssessmentResultIndex, + DetailedAssessmentResultIndex = detailedAssessmentResultIndex, + TailorMadeAssessmentResultIndex = tailorMadeAssessmentResultIndex, + SimpleAssemblyCategoryGroupIndex = simpleAssemblyCategoryGroupIndex, + DetailedAssemblyCategoryGroupIndex = detailedAssemblyCategoryGroupIndex, + TailorMadeAssemblyCategoryGroupIndex = tailorMadeAssemblyCategoryGroupIndex, + CombinedAssemblyCategoryGroupIndex = combinedAssemblyCategoryGroupIndex, + ManualAssemblyCategoryGroupIndex = manualAssemblyCategoryGroupIndex + }); } - protected override void Dispose(bool disposing) + protected override void AddDataGridColumns() { - DataGridViewControl.CellFormatting -= OnCellFormatting; + FailureMechanismSectionResultViewColumnBuilder.AddSectionNameColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.Name)); - base.Dispose(disposing); - } + FailureMechanismSectionResultViewColumnBuilder.AddSimpleAssessmentResultColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.SimpleAssessmentResult)); - protected override void AddDataGridColumns() - { - DataGridViewControl.AddTextBoxColumn( - nameof(GrassCoverSlipOffInwardsSectionResultRow.Name), - RingtoetsCommonFormsResources.Section_DisplayName, - true); + FailureMechanismSectionResultViewColumnBuilder.AddDetailedAssessmentResultColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.DetailedAssessmentResult)); - EnumDisplayWrapper[] simpleAssessmentDataSource = - Enum.GetValues(typeof(SimpleAssessmentResultType)) - .OfType() - .Select(sa => new EnumDisplayWrapper(sa)) - .ToArray(); + FailureMechanismSectionResultViewColumnBuilder.AddTailorMadeAssessmentResultColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.TailorMadeAssessmentResult)); - DataGridViewControl.AddComboBoxColumn( - nameof(GrassCoverSlipOffInwardsSectionResultRow.SimpleAssessmentResult), - RingtoetsCommonFormsResources.FailureMechanismResultView_SimpleAssessmentResult_DisplayName, - simpleAssessmentDataSource, - nameof(EnumDisplayWrapper.Value), - nameof(EnumDisplayWrapper.DisplayName)); - } + FailureMechanismSectionResultViewColumnBuilder.AddSimpleAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.SimpleAssemblyCategoryGroup)); - protected override void BindEvents() - { - base.BindEvents(); + FailureMechanismSectionResultViewColumnBuilder.AddDetailedAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.DetailedAssemblyCategoryGroup)); - DataGridViewControl.CellFormatting += OnCellFormatting; - } + FailureMechanismSectionResultViewColumnBuilder.AddTailorMadeAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.TailorMadeAssemblyCategoryGroup)); - private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) - { - if (eventArgs.ColumnIndex > SimpleAssessmentColumnIndex) - { - SimpleAssessmentResultType simpleAssessmentResult = GetDataAtRow(eventArgs.RowIndex).SimpleAssessmentResult; - if (FailureMechanismSectionResultRowHelper.SimpleAssessmentIsSufficient(simpleAssessmentResult)) - { - DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - else - { - DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - } + FailureMechanismSectionResultViewColumnBuilder.AddCombinedAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.CombinedAssemblyCategoryGroup)); + + FailureMechanismSectionResultViewColumnBuilder.AddUseManualAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.UseManualAssemblyCategoryGroup)); + + FailureMechanismSectionResultViewColumnBuilder.AddManualAssemblyCategoryGroupColumn( + DataGridViewControl, + nameof(GrassCoverSlipOffInwardsSectionResultRow.ManualAssemblyCategoryGroup)); } } } \ No newline at end of file