Fisheye: Tag 9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67 refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs
===================================================================
diff -u -r4d30d1d25f7571ffaf029d0ad65b7dc315bdbf5c -r9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67
--- Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 4d30d1d25f7571ffaf029d0ad65b7dc315bdbf5c)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67)
@@ -23,8 +23,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
-using Core.Common.Base;
-using Core.Common.Controls.Views;
using Core.Common.Util.Extensions;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.IllustrationPoints;
@@ -36,129 +34,37 @@
/// This class is a view for presenting objects
/// (as part of the of a ).
///
- public partial class GeneralResultFaultTreeIllustrationPointView : UserControl, IView, ISelectionProvider
+ public class GeneralResultFaultTreeIllustrationPointView : GeneralResultIllustrationPointView
{
- private readonly Observer calculationObserver;
- private readonly Func> getGeneralResultFunc;
+ private IllustrationPointsFaultTreeControl illustrationPointsFaultTreeControl;
- private ICalculation data;
- private bool suspendIllustrationPointsControlEvents;
-
- public event EventHandler SelectionChanged;
-
///
/// Creates a new instance of .
///
+ /// The calculation to show the illustration points for.
/// A for obtaining the illustration point
/// data ( with objects)
/// that must be presented.
- /// Thrown when is null.
- public GeneralResultFaultTreeIllustrationPointView(Func> getGeneralResultFunc)
+ /// Thrown when any parameter is null.
+ /// Thrown when the top level fault tree illustration
+ /// contains an illustration point that is not of type
+ /// or .
+ public GeneralResultFaultTreeIllustrationPointView(ICalculation calculation, Func> getGeneralResultFunc)
+ : base(calculation, getGeneralResultFunc)
{
- InitializeComponent();
-
- if (getGeneralResultFunc == null)
- {
- throw new ArgumentNullException(nameof(getGeneralResultFunc));
- }
-
- this.getGeneralResultFunc = getGeneralResultFunc;
-
- calculationObserver = new Observer(UpdateControls);
-
- illustrationPointsControl.SelectionChanged += IllustrationPointsControlOnSelectionChanged;
- illustrationPointsFaultTreeControl.SelectionChanged += IllustrationPointsFaultTreeControlOnSelectionChanged;
- Name = "GeneralResultFaultTreeIllustrationPointViewName";
+ AddIllustrationPointsFaultTreeControl();
}
- public object Selection { get; private set; }
-
- public object Data
- {
- get => data;
- set
- {
- data = value as ICalculation;
-
- calculationObserver.Observable = data;
-
- UpdateControls();
- }
- }
-
- protected override void Dispose(bool disposing)
- {
- calculationObserver.Dispose();
-
- if (disposing)
- {
- components?.Dispose();
- }
-
- base.Dispose(disposing);
- }
-
- ///
- /// Updates the controls.
- ///
+ ///
/// Thrown when the top level fault tree illustration
/// contains an illustration point that is not of type
/// or .
- private void UpdateControls()
+ protected override IEnumerable GetIllustrationPointControlItems()
{
- suspendIllustrationPointsControlEvents = true;
- UpdateIllustrationPointsControl();
- suspendIllustrationPointsControlEvents = false;
+ GeneralResult generalResult = GetGeneralResultFunc();
- UpdateIllustrationPointsFaultTreeControl();
- ProvideIllustrationPointSelection();
- }
-
- private void IllustrationPointsFaultTreeControlOnSelectionChanged(object sender, EventArgs eventArgs)
- {
- var selection = illustrationPointsFaultTreeControl.Selection as IllustrationPointNode;
- TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint = illustrationPointsFaultTreeControl.Data;
- GeneralResult generalResult = getGeneralResultFunc();
-
- if (selection == null || topLevelFaultTreeIllustrationPoint == null || generalResult == null)
+ if (generalResult == null)
{
- return;
- }
-
- string closingSituation = generalResult.TopLevelIllustrationPoints.HasMultipleUniqueValues(p => p.ClosingSituation)
- ? topLevelFaultTreeIllustrationPoint.ClosingSituation
- : string.Empty;
-
- if (selection.Data is FaultTreeIllustrationPoint faultTreeIllustrationPoint)
- {
- Selection = new IllustrationPointContext(faultTreeIllustrationPoint,
- selection,
- topLevelFaultTreeIllustrationPoint.WindDirection.Name,
- closingSituation);
- }
-
- if (selection.Data is SubMechanismIllustrationPoint subMechanismIllustrationPoint)
- {
- Selection = new IllustrationPointContext(subMechanismIllustrationPoint,
- selection,
- topLevelFaultTreeIllustrationPoint.WindDirection.Name,
- closingSituation);
- }
-
- OnSelectionChanged();
- }
-
- private void UpdateIllustrationPointsControl()
- {
- illustrationPointsControl.Data = GetIllustrationPointControlItems();
- }
-
- private IEnumerable GetIllustrationPointControlItems()
- {
- GeneralResult generalResult = getGeneralResultFunc();
-
- if (data == null || generalResult == null)
- {
return Enumerable.Empty();
}
@@ -174,6 +80,33 @@
}).ToArray();
}
+ protected override void UpdateSpecificIllustrationPointsControl()
+ {
+ illustrationPointsFaultTreeControl.Data = (TopLevelFaultTreeIllustrationPoint) (IllustrationPointsControl.Selection as IllustrationPointControlItem)?.Source;
+ }
+
+ ///
+ /// Thrown when the top level fault tree illustration
+ /// contains an illustration point that is not of type
+ /// or .
+ protected override object GetSelectedTopLevelIllustrationPoint(IllustrationPointControlItem selection)
+ {
+ return new SelectedTopLevelFaultTreeIllustrationPoint(
+ (TopLevelFaultTreeIllustrationPoint) selection.Source,
+ GetIllustrationPointControlItems().Select(ipci => ipci.ClosingSituation));
+ }
+
+ private void AddIllustrationPointsFaultTreeControl()
+ {
+ illustrationPointsFaultTreeControl = new IllustrationPointsFaultTreeControl
+ {
+ Dock = DockStyle.Fill
+ };
+ illustrationPointsFaultTreeControl.SelectionChanged += IllustrationPointsFaultTreeControlOnSelectionChanged;
+
+ SplitContainer.Panel2.Controls.Add(illustrationPointsFaultTreeControl);
+ }
+
///
/// Returns the stochasts of the .
///
@@ -196,41 +129,40 @@
}
}
- private void UpdateIllustrationPointsFaultTreeControl()
+ private void IllustrationPointsFaultTreeControlOnSelectionChanged(object sender, EventArgs eventArgs)
{
- illustrationPointsFaultTreeControl.Data = (TopLevelFaultTreeIllustrationPoint) (illustrationPointsControl.Selection as IllustrationPointControlItem)?.Source;
- }
+ var selection = illustrationPointsFaultTreeControl.Selection as IllustrationPointNode;
+ TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint = illustrationPointsFaultTreeControl.Data;
+ GeneralResult generalResult = GetGeneralResultFunc();
- private void IllustrationPointsControlOnSelectionChanged(object sender, EventArgs e)
- {
- if (suspendIllustrationPointsControlEvents)
+ if (selection == null || topLevelFaultTreeIllustrationPoint == null || generalResult == null)
{
return;
}
- UpdateIllustrationPointsFaultTreeControl();
+ string closingSituation = generalResult.TopLevelIllustrationPoints.HasMultipleUniqueValues(p => p.ClosingSituation)
+ ? topLevelFaultTreeIllustrationPoint.ClosingSituation
+ : string.Empty;
- ProvideIllustrationPointSelection();
- }
+ switch (selection.Data)
+ {
+ case FaultTreeIllustrationPoint faultTreeIllustrationPoint:
+ Selection = new IllustrationPointContext(
+ faultTreeIllustrationPoint,
+ selection,
+ topLevelFaultTreeIllustrationPoint.WindDirection.Name,
+ closingSituation);
+ break;
+ case SubMechanismIllustrationPoint subMechanismIllustrationPoint:
+ Selection = new IllustrationPointContext(
+ subMechanismIllustrationPoint,
+ selection,
+ topLevelFaultTreeIllustrationPoint.WindDirection.Name,
+ closingSituation);
+ break;
+ }
- ///
- /// Sets the based on the selection of the .
- ///
- /// Thrown when the top level fault tree illustration
- /// contains an illustration point that is not of type
- /// or .
- private void ProvideIllustrationPointSelection()
- {
- Selection = illustrationPointsControl.Selection is IllustrationPointControlItem selection
- ? new SelectedTopLevelFaultTreeIllustrationPoint((TopLevelFaultTreeIllustrationPoint) selection.Source,
- GetIllustrationPointControlItems().Select(ipci => ipci.ClosingSituation))
- : null;
OnSelectionChanged();
}
-
- private void OnSelectionChanged()
- {
- SelectionChanged?.Invoke(this, new EventArgs());
- }
}
}
\ No newline at end of file
Fisheye: Tag 9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67 refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.resx'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.Designer.cs
===================================================================
diff -u -re9349e31606bb6b56eadd4cda8d345bfb056e22b -r9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67
--- Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.Designer.cs (.../GeneralResultIllustrationPointView.Designer.cs) (revision e9349e31606bb6b56eadd4cda8d345bfb056e22b)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.Designer.cs (.../GeneralResultIllustrationPointView.Designer.cs) (revision 9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67)
@@ -19,6 +19,8 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System.Windows.Forms;
+
namespace Riskeer.Common.Forms.Views
{
partial class GeneralResultIllustrationPointView
@@ -30,6 +32,8 @@
protected IllustrationPointsControl IllustrationPointsControl => illustrationPointsControl;
+ protected SplitContainer SplitContainer => splitContainer;
+
#region Component Designer generated code
///
Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.cs
===================================================================
diff -u -rd2c4c19fc70a5f47e08abef546e7aff4b056616e -r9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67
--- Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.cs (.../GeneralResultIllustrationPointView.cs) (revision d2c4c19fc70a5f47e08abef546e7aff4b056616e)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Views/GeneralResultIllustrationPointView.cs (.../GeneralResultIllustrationPointView.cs) (revision 9a4864f1f1d6d3fa70246f8d6f1a80f318e66e67)
@@ -37,7 +37,6 @@
public abstract partial class GeneralResultIllustrationPointView : UserControl, IView, ISelectionProvider
where TTopLevelIllustrationPoint : TopLevelIllustrationPointBase
{
- protected readonly Func> GetGeneralResultFunc;
private readonly Observer calculationObserver;
private ICalculation calculation;
@@ -69,30 +68,35 @@
this.calculation = calculation;
GetGeneralResultFunc = getGeneralResultFunc;
- calculationObserver = new Observer(() =>
+ calculationObserver = new Observer(UpdateControls)
{
- UpdateControls();
- ProvideIllustrationPointSelection();
- })
- {
Observable = calculation
};
IllustrationPointsControl.SelectionChanged += IllustrationPointsControlOnSelectionChanged;
Name = "GeneralResultIllustrationPointView";
-
- UpdateControls();
- ProvideIllustrationPointSelection();
}
- public object Selection { get; private set; }
+ public object Selection { get; protected set; }
public object Data
{
get => calculation;
set => calculation = value as ICalculation;
}
+ ///
+ /// Gets the for obtaining the .
+ ///
+ protected Func> GetGeneralResultFunc { get; }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ UpdateControls();
+ }
+
protected override void Dispose(bool disposing)
{
calculationObserver.Dispose();
@@ -104,25 +108,41 @@
base.Dispose(disposing);
}
-
- protected void UpdateControls()
- {
- suspendIllustrationPointsControlEvents = true;
- UpdateIllustrationPointsControl();
- suspendIllustrationPointsControlEvents = false;
- }
+ ///
+ /// Gets a collection of .
+ ///
+ /// A collection of .
protected abstract IEnumerable GetIllustrationPointControlItems();
+ ///
+ /// Updates specific illustration point controls
+ ///
protected abstract void UpdateSpecificIllustrationPointsControl();
+ ///
+ /// Gets the selected top level illustration point.
+ ///
+ /// The selection
+ /// to get the selected top level illustration point from.
+ /// The selected top level illustration point.
protected abstract object GetSelectedTopLevelIllustrationPoint(IllustrationPointControlItem selection);
- private void OnSelectionChanged()
+ protected void OnSelectionChanged()
{
SelectionChanged?.Invoke(this, new EventArgs());
}
+ private void UpdateControls()
+ {
+ suspendIllustrationPointsControlEvents = true;
+ UpdateIllustrationPointsControl();
+ suspendIllustrationPointsControlEvents = false;
+
+ UpdateSpecificIllustrationPointsControl();
+ ProvideIllustrationPointSelection();
+ }
+
private void UpdateIllustrationPointsControl()
{
IllustrationPointsControl.Data = GetIllustrationPointControlItems();