Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs =================================================================== diff -u -reef0b9286b0abef756736270c7edb3adcd8221d3 -r279475cece701c9d6e3b83c08b11a8b75e10665c --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision eef0b9286b0abef756736270c7edb3adcd8221d3) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 279475cece701c9d6e3b83c08b11a8b75e10665c) @@ -41,6 +41,7 @@ private readonly Func> getGeneralResultFunc; private ICalculation data; + private bool suspendAllEvents; public event EventHandler SelectionChanged; @@ -62,7 +63,14 @@ this.getGeneralResultFunc = getGeneralResultFunc; - calculationObserver = new Observer(UpdateIllustrationPointsControl); + calculationObserver = new Observer(() => + { + if (illustrationPointsControl.Data == null && data.HasOutput + || illustrationPointsControl.Data != null && !data.HasOutput) + { + UpdateControls(); + } + }); illustrationPointsControl.SelectionChanged += IllustrationPointsControlOnSelectionChanged; illustrationPointsFaultTreeControl.SelectionChanged += IllustrationPointsFaultTreeControlOnSelectionChanged; @@ -82,7 +90,7 @@ calculationObserver.Observable = data; - UpdateIllustrationPointsControl(); + UpdateControls(); } } @@ -98,8 +106,23 @@ base.Dispose(disposing); } + private void UpdateControls() + { + suspendAllEvents = true; + UpdateIllustrationPointsControl(); + UpdateIllustrationPointsFaultTreeControl(); + suspendAllEvents = false; + + ProvideIllustrationPointSelection(); + } + private void IllustrationPointsFaultTreeControlOnSelectionChanged(object sender, EventArgs eventArgs) { + if (suspendAllEvents) + { + return; + } + var selection = illustrationPointsFaultTreeControl.Selection as IllustrationPointNode; TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint = illustrationPointsFaultTreeControl.Data; @@ -128,7 +151,7 @@ private void UpdateIllustrationPointsControl() { - illustrationPointsControl.Data = GetIllustrationPointControlItems(); + illustrationPointsControl.Data = GetIllustrationPointControlItems()?.ToArray(); } private IEnumerable GetIllustrationPointControlItems() @@ -169,25 +192,28 @@ private void UpdateIllustrationPointsFaultTreeControl() { - illustrationPointsFaultTreeControl.Data = GetIllustrationPointsFaultTreeControlItems(); + illustrationPointsFaultTreeControl.Data = (TopLevelFaultTreeIllustrationPoint) (illustrationPointsControl.Selection as IllustrationPointControlItem)?.Source; } - private TopLevelFaultTreeIllustrationPoint GetIllustrationPointsFaultTreeControlItems() + private void IllustrationPointsControlOnSelectionChanged(object sender, EventArgs e) { - var selected = Selection as SelectedTopLevelFaultTreeIllustrationPoint; + if (suspendAllEvents) + { + return; + } - return selected?.TopLevelFaultTreeIllustrationPoint; + UpdateIllustrationPointsFaultTreeControl(); + + ProvideIllustrationPointSelection(); } - private void IllustrationPointsControlOnSelectionChanged(object sender, EventArgs e) + private void ProvideIllustrationPointSelection() { var selection = illustrationPointsControl.Selection as IllustrationPointControlItem; Selection = selection != null ? new SelectedTopLevelFaultTreeIllustrationPoint((TopLevelFaultTreeIllustrationPoint) selection.Source, GetIllustrationPointControlItems().Select(ipci => ipci.ClosingSituation)) : null; - - UpdateIllustrationPointsFaultTreeControl(); OnSelectionChanged(); }