Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs =================================================================== diff -u -r4fe18530ce01d02e59d52bf8b334710236466abe -rc28810d9b3079290aeef62b6b9c0eb9fd6b49ac4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 4fe18530ce01d02e59d52bf8b334710236466abe) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision c28810d9b3079290aeef62b6b9c0eb9fd6b49ac4) @@ -26,6 +26,7 @@ using Core.Common.Base; using Core.Common.Controls.DataGrid; using Core.Common.Controls.Views; +using Core.Common.Util.Extensions; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Common.Forms.Views @@ -46,7 +47,8 @@ private readonly Observer failureMechanismSectionResultObserver; private readonly IObservableEnumerable failureMechanismSectionResults; private readonly RecursiveObserver, TSectionResult> failureMechanismSectionResultsObserver; - protected IEnumerable SectionResultRows; + private IEnumerable sectionResultRows; + private bool rowUpdating; /// /// Creates a new instance of . @@ -93,14 +95,6 @@ protected DataGridViewControl DataGridViewControl { get; private set; } - /// - /// Updates the section result rows whenever a section result is notified. - /// - protected virtual void UpdateSectionResultRows() - { - DataGridViewControl.RefreshDataGridView(); - } - protected override void OnLoad(EventArgs e) { base.OnLoad(e); @@ -126,6 +120,12 @@ DataGridViewControl.CellFormatting -= HandleCellStyling; + sectionResultRows?.ForEachElementDo(row => + { + row.RowUpdated -= RowUpdated; + row.RowUpdateDone -= RowUpdateDone; + }); + if (disposing) { components?.Dispose(); @@ -140,12 +140,24 @@ protected void UpdateDataGridViewDataSource() { DataGridViewControl.EndEdit(); - SectionResultRows = failureMechanismSectionResults + + sectionResultRows?.ForEachElementDo(row => + { + row.RowUpdated -= RowUpdated; + row.RowUpdateDone -= RowUpdateDone; + }); + + sectionResultRows = failureMechanismSectionResults .Select(CreateFailureMechanismSectionResultRow) .Where(sr => sr != null) .ToList(); - DataGridViewControl.SetDataSource(SectionResultRows); - UpdateSectionResultRows(); + DataGridViewControl.SetDataSource(sectionResultRows); + + foreach (TSectionResultRow sectionResultRow in sectionResultRows) + { + sectionResultRow.RowUpdated += RowUpdated; + sectionResultRow.RowUpdateDone += RowUpdateDone; + } } /// @@ -171,6 +183,17 @@ DataGridViewControl.CellFormatting += HandleCellStyling; } + private void RowUpdateDone(object sender, EventArgs eventArgs) + { + rowUpdating = false; + } + + private void RowUpdated(object sender, EventArgs eventArgs) + { + rowUpdating = true; + DataGridViewControl.RefreshDataGridView(); + } + private void HandleCellStyling(object sender, DataGridViewCellFormattingEventArgs e) { TSectionResultRow row = GetDataAtRow(e.RowIndex); @@ -186,5 +209,16 @@ cell.Style.ForeColor = columnStateDefinition.Style.TextColor; } } + + private void UpdateSectionResultRows() + { + if (rowUpdating) + { + return; + } + + sectionResultRows.ForEachElementDo(row => row.Update()); + DataGridViewControl.RefreshDataGridView(); + } } } \ No newline at end of file