Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Riskeer.StabilityPointStructures.Forms.csproj
===================================================================
diff -u -rd363f5b55e823f5e4956e954950a616cb2468991 -r85f99d0f373b5ccc84747cd1db01c6039cb58053
--- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Riskeer.StabilityPointStructures.Forms.csproj (.../Riskeer.StabilityPointStructures.Forms.csproj) (revision d363f5b55e823f5e4956e954950a616cb2468991)
+++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Riskeer.StabilityPointStructures.Forms.csproj (.../Riskeer.StabilityPointStructures.Forms.csproj) (revision 85f99d0f373b5ccc84747cd1db01c6039cb58053)
@@ -31,9 +31,7 @@
True
Resources.resx
-
- UserControl
-
+
Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationRow.cs
===================================================================
diff -u -r19cb5416755b464820d056fa7e4576e1c2ada4d6 -r85f99d0f373b5ccc84747cd1db01c6039cb58053
--- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationRow.cs (.../StabilityPointStructuresCalculationRow.cs) (revision 19cb5416755b464820d056fa7e4576e1c2ada4d6)
+++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationRow.cs (.../StabilityPointStructuresCalculationRow.cs) (revision 85f99d0f373b5ccc84747cd1db01c6039cb58053)
@@ -23,22 +23,23 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
using Riskeer.Common.Data.DikeProfiles;
using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Data.Structures;
using Riskeer.Common.Forms.ChangeHandlers;
using Riskeer.Common.Forms.Helpers;
-using Riskeer.Common.Forms.PresentationObjects;
using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Common.Forms.Views;
using Riskeer.StabilityPointStructures.Data;
namespace Riskeer.StabilityPointStructures.Forms.Views
{
///
/// This class represents a row in the .
///
- internal class StabilityPointStructuresCalculationRow : IHasColumnStateDefinitions
+ public class StabilityPointStructuresCalculationRow : CalculationRow>, IHasColumnStateDefinitions
{
private const int breakWaterTypeColumnIndex = 4;
private const int breakWaterHeightColumnIndex = 5;
@@ -47,29 +48,17 @@
private const int constructiveStrengthQuadraticLoadModelColumnIndex = 9;
private const int stabilityLinearLoadModelColumnIndex = 10;
private const int stabilityQuadraticLoadModelColumnIndex = 11;
- private readonly IObservablePropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
///
- /// The this row contains.
+ /// The this row contains.
/// The handler responsible for handling effects of a property change.
/// Thrown when any parameter is null.
- public StabilityPointStructuresCalculationRow(StructuresCalculationScenario calculationScenario,
- IObservablePropertyChangeHandler handler)
+ internal StabilityPointStructuresCalculationRow(StructuresCalculationScenario calculationScenario,
+ IObservablePropertyChangeHandler handler)
+ : base(calculationScenario, handler)
{
- if (calculationScenario == null)
- {
- throw new ArgumentNullException(nameof(calculationScenario));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- CalculationScenario = calculationScenario;
- propertyChangeHandler = handler;
ColumnStateDefinitions = new Dictionary();
CreateColumnStateDefinitions();
UpdateUseBreakWaterColumnStateDefinitions();
@@ -78,220 +67,187 @@
}
///
- /// Gets the this row contains.
+ /// Gets or sets the foreshore profile of the .
///
- public StructuresCalculationScenario CalculationScenario { get; }
-
- ///
- /// Gets or sets the name of the .
- ///
- public string Name
- {
- get => CalculationScenario.Name;
- set
- {
- CalculationScenario.Name = value;
-
- CalculationScenario.NotifyObservers();
- }
- }
-
- ///
- /// Gets or sets the hydraulic boundary location of the .
- ///
- public DataGridViewComboBoxItemWrapper SelectableHydraulicBoundaryLocation
- {
- get
- {
- if (CalculationScenario.InputParameters.HydraulicBoundaryLocation == null)
- {
- return new DataGridViewComboBoxItemWrapper(null);
- }
-
- return new DataGridViewComboBoxItemWrapper(
- new SelectableHydraulicBoundaryLocation(CalculationScenario.InputParameters.HydraulicBoundaryLocation, null));
- }
- set
- {
- HydraulicBoundaryLocation valueToSet = value?.WrappedObject?.HydraulicBoundaryLocation;
- if (!ReferenceEquals(CalculationScenario.InputParameters.HydraulicBoundaryLocation, valueToSet))
- {
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.HydraulicBoundaryLocation = valueToSet, propertyChangeHandler);
- }
- }
- }
-
- ///
- /// Gets or sets the foreshore profile of the .
- ///
public DataGridViewComboBoxItemWrapper ForeshoreProfile
{
- get => new DataGridViewComboBoxItemWrapper(CalculationScenario.InputParameters.ForeshoreProfile);
+ get => new DataGridViewComboBoxItemWrapper(Calculation.InputParameters.ForeshoreProfile);
set
{
ForeshoreProfile valueToSet = value?.WrappedObject;
- if (!ReferenceEquals(CalculationScenario.InputParameters.ForeshoreProfile, valueToSet))
+ if (!ReferenceEquals(Calculation.InputParameters.ForeshoreProfile, valueToSet))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.ForeshoreProfile = valueToSet, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.ForeshoreProfile = valueToSet, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets whether break water of the should be used.
+ /// Gets or sets whether break water of the should be used.
///
public bool UseBreakWater
{
- get => CalculationScenario.InputParameters.UseBreakWater;
+ get => Calculation.InputParameters.UseBreakWater;
set
{
- if (!CalculationScenario.InputParameters.UseBreakWater.Equals(value))
+ if (!Calculation.InputParameters.UseBreakWater.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseBreakWater = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseBreakWater = value, PropertyChangeHandler);
UpdateUseBreakWaterColumnStateDefinitions();
}
}
}
///
- /// Gets or sets the break water type of the .
+ /// Gets or sets the break water type of the .
///
public BreakWaterType BreakWaterType
{
- get => CalculationScenario.InputParameters.BreakWater.Type;
+ get => Calculation.InputParameters.BreakWater.Type;
set
{
- if (!CalculationScenario.InputParameters.BreakWater.Type.Equals(value))
+ if (!Calculation.InputParameters.BreakWater.Type.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Type = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.BreakWater.Type = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the break water height of the .
+ /// Gets or sets the break water height of the .
///
public RoundedDouble BreakWaterHeight
{
- get => CalculationScenario.InputParameters.BreakWater.Height;
+ get => Calculation.InputParameters.BreakWater.Height;
set
{
- if (!CalculationScenario.InputParameters.BreakWater.Height.Equals(value))
+ if (!Calculation.InputParameters.BreakWater.Height.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.BreakWater.Height = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.BreakWater.Height = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets whether foreshore profile of the should be used.
+ /// Gets or sets whether foreshore profile of the should be used.
///
public bool UseForeshoreGeometry
{
- get => CalculationScenario.InputParameters.UseForeshore;
+ get => Calculation.InputParameters.UseForeshore;
set
{
- if (!CalculationScenario.InputParameters.UseForeshore.Equals(value))
+ if (!Calculation.InputParameters.UseForeshore.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.UseForeshore = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.UseForeshore = value, PropertyChangeHandler);
UpdateUseForeshoreColumnStateDefinitions();
}
}
}
///
- /// Gets or sets the load schematization type of the .
+ /// Gets or sets the load schematization type of the .
///
public LoadSchematizationType LoadSchematizationType
{
- get => CalculationScenario.InputParameters.LoadSchematizationType;
+ get => Calculation.InputParameters.LoadSchematizationType;
set
{
- if (!CalculationScenario.InputParameters.LoadSchematizationType.Equals(value))
+ if (!Calculation.InputParameters.LoadSchematizationType.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.LoadSchematizationType = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.LoadSchematizationType = value, PropertyChangeHandler);
UpdateLoadSchematizationColumnStateDefinitions();
}
}
}
///
- /// Gets or sets the constructive strength linear load model of the .
+ /// Gets or sets the constructive strength linear load model of the .
///
public RoundedDouble ConstructiveStrengthLinearLoadModel
{
- get => CalculationScenario.InputParameters.ConstructiveStrengthLinearLoadModel.Mean;
+ get => Calculation.InputParameters.ConstructiveStrengthLinearLoadModel.Mean;
set
{
- if (!CalculationScenario.InputParameters.ConstructiveStrengthLinearLoadModel.Mean.Equals(value))
+ if (!Calculation.InputParameters.ConstructiveStrengthLinearLoadModel.Mean.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.ConstructiveStrengthLinearLoadModel.Mean = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.ConstructiveStrengthLinearLoadModel.Mean = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the constructive strength quadratic load model of the .
+ /// Gets or sets the constructive strength quadratic load model of the .
///
public RoundedDouble ConstructiveStrengthQuadraticLoadModel
{
- get => CalculationScenario.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean;
+ get => Calculation.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean;
set
{
- if (!CalculationScenario.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean.Equals(value))
+ if (!Calculation.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.ConstructiveStrengthQuadraticLoadModel.Mean = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the stability of the linear load model of the .
+ /// Gets or sets the stability of the linear load model of the .
///
public RoundedDouble StabilityLinearLoadModel
{
- get => CalculationScenario.InputParameters.StabilityLinearLoadModel.Mean;
+ get => Calculation.InputParameters.StabilityLinearLoadModel.Mean;
set
{
- if (!CalculationScenario.InputParameters.StabilityLinearLoadModel.Mean.Equals(value))
+ if (!Calculation.InputParameters.StabilityLinearLoadModel.Mean.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.StabilityLinearLoadModel.Mean = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.StabilityLinearLoadModel.Mean = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the stability of the quadratic load model of the .
+ /// Gets or sets the stability of the quadratic load model of the .
///
public RoundedDouble StabilityQuadraticLoadModel
{
- get => CalculationScenario.InputParameters.StabilityQuadraticLoadModel.Mean;
+ get => Calculation.InputParameters.StabilityQuadraticLoadModel.Mean;
set
{
- if (!CalculationScenario.InputParameters.StabilityQuadraticLoadModel.Mean.Equals(value))
+ if (!Calculation.InputParameters.StabilityQuadraticLoadModel.Mean.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.StabilityQuadraticLoadModel.Mean = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.StabilityQuadraticLoadModel.Mean = value, PropertyChangeHandler);
}
}
}
///
- /// Gets or sets the evaluation level of the .
+ /// Gets or sets the evaluation level of the .
///
public RoundedDouble EvaluationLevel
{
- get => CalculationScenario.InputParameters.EvaluationLevel;
+ get => Calculation.InputParameters.EvaluationLevel;
set
{
- if (!CalculationScenario.InputParameters.EvaluationLevel.Equals(value))
+ if (!Calculation.InputParameters.EvaluationLevel.Equals(value))
{
- PropertyChangeHelper.ChangePropertyAndNotify(() => CalculationScenario.InputParameters.EvaluationLevel = value, propertyChangeHandler);
+ PropertyChangeHelper.ChangePropertyAndNotify(() => Calculation.InputParameters.EvaluationLevel = value, PropertyChangeHandler);
}
}
}
public IDictionary ColumnStateDefinitions { get; }
+ public override Point2D GetCalculationLocation()
+ {
+ return Calculation.InputParameters.Structure?.Location;
+ }
+
+ protected override HydraulicBoundaryLocation HydraulicBoundaryLocation
+ {
+ get => Calculation.InputParameters.HydraulicBoundaryLocation;
+ set => Calculation.InputParameters.HydraulicBoundaryLocation = value;
+ }
+
private void CreateColumnStateDefinitions()
{
ColumnStateDefinitions.Add(breakWaterTypeColumnIndex, new DataGridViewColumnStateDefinition());
@@ -319,7 +275,7 @@
private void UpdateUseForeshoreColumnStateDefinitions()
{
- ForeshoreProfile foreShoreProfileGeometry = CalculationScenario.InputParameters.ForeshoreProfile;
+ ForeshoreProfile foreShoreProfileGeometry = Calculation.InputParameters.ForeshoreProfile;
if (foreShoreProfileGeometry == null || !foreShoreProfileGeometry.Geometry.Any())
{
ColumnStateHelper.DisableColumn(ColumnStateDefinitions[useForeshoreColumnIndex]);
Fisheye: Tag 85f99d0f373b5ccc84747cd1db01c6039cb58053 refers to a dead (removed) revision in file `Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationsView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationsView.cs
===================================================================
diff -u -r3076354fa3a2bf2f027075f61ca660bffb576a45 -r85f99d0f373b5ccc84747cd1db01c6039cb58053
--- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationsView.cs (.../StabilityPointStructuresCalculationsView.cs) (revision 3076354fa3a2bf2f027075f61ca660bffb576a45)
+++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Views/StabilityPointStructuresCalculationsView.cs (.../StabilityPointStructuresCalculationsView.cs) (revision 85f99d0f373b5ccc84747cd1db01c6039cb58053)
@@ -26,18 +26,15 @@
using Core.Common.Base;
using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
-using Core.Common.Controls.Views;
using Core.Common.Util;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.DikeProfiles;
-using Riskeer.Common.Data.FailureMechanism;
-using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Data.Structures;
using Riskeer.Common.Forms;
using Riskeer.Common.Forms.ChangeHandlers;
using Riskeer.Common.Forms.Helpers;
-using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Common.Forms.Views;
using Riskeer.StabilityPointStructures.Data;
using Riskeer.StabilityPointStructures.Forms.PresentationObjects;
using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
@@ -47,23 +44,11 @@
///
/// This class is a view for configuring closing structures calculations.
///
- public partial class StabilityPointStructuresCalculationsView : UserControl, ISelectionProvider, IView
+ public class StabilityPointStructuresCalculationsView : CalculationsView, StabilityPointStructuresInput, StabilityPointStructuresCalculationRow, StabilityPointStructuresFailureMechanism>
{
- private const int selectableHydraulicBoundaryLocationColumnIndex = 1;
- private const int selectableForeshoreProfileColumnIndex = 2;
- private readonly IAssessmentSection assessmentSection;
- private readonly StabilityPointStructuresFailureMechanism failureMechanism;
- private Observer failureMechanismObserver;
- private Observer hydraulicBoundaryLocationsObserver;
- private Observer stabilityPointStructuresObserver;
- private RecursiveObserver inputObserver;
- private RecursiveObserver> calculationScenarioObserver;
- private RecursiveObserver calculationGroupObserver;
+ private const int foreshoreProfileColumnIndex = 2;
+ private readonly Observer stabilityPointStructuresObserver;
- private CalculationGroup calculationGroup;
-
- public event EventHandler SelectionChanged;
-
///
/// Creates a new instance of .
///
@@ -72,308 +57,175 @@
/// The assessment section.
/// Thrown when any parameter is null.
public StabilityPointStructuresCalculationsView(CalculationGroup data, StabilityPointStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ : base(data, failureMechanism, assessmentSection)
{
- if (data == null)
+ stabilityPointStructuresObserver = new Observer(UpdateGenerateCalculationsButtonState)
{
- throw new ArgumentNullException(nameof(data));
- }
+ Observable = FailureMechanism.StabilityPointStructures
+ };
+ }
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
- if (assessmentSection == null)
+ DataGridViewControl.CellFormatting += HandleCellStyling;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
{
- throw new ArgumentNullException(nameof(assessmentSection));
+ stabilityPointStructuresObserver.Dispose();
}
- this.failureMechanism = failureMechanism;
- this.assessmentSection = assessmentSection;
- calculationGroup = data;
+ base.Dispose(disposing);
+ }
- InitializeObservers();
+ protected override object CreateSelectedItemFromCurrentRow(StabilityPointStructuresCalculationRow currentRow)
+ {
+ return new StabilityPointStructuresInputContext(
+ currentRow.Calculation.InputParameters,
+ currentRow.Calculation,
+ FailureMechanism,
+ AssessmentSection);
+ }
- InitializeComponent();
- InitializeListBox();
- InitializeDataGridView();
-
- UpdateSectionsListBox();
- UpdateDataGridViewDataSource();
- UpdateSelectableHydraulicBoundaryLocationsColumn();
- UpdateForeshoreProfilesColumn();
- UpdateGenerateCalculationsButtonState();
+ protected override IEnumerable GetReferenceLocations()
+ {
+ return FailureMechanism.StabilityPointStructures.Select(sps => sps.Location);
}
- public object Selection => CreateSelectedItemFromCurrentRow();
-
- public object Data
+ protected override bool IsCalculationIntersectionWithReferenceLineInSection(StructuresCalculationScenario calculation, IEnumerable lineSegments)
{
- get => calculationGroup;
- set => calculationGroup = value as CalculationGroup;
+ return calculation.IsStructureIntersectionWithReferenceLineInSection(lineSegments);
}
- protected override void OnLoad(EventArgs e)
+ protected override StabilityPointStructuresCalculationRow CreateRow(StructuresCalculationScenario calculation)
{
- // Necessary to correctly load the content of the dropdown lists of the comboboxes...
- UpdateDataGridViewDataSource();
+ return new StabilityPointStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, calculation.InputParameters));
+ }
- base.OnLoad(e);
-
- dataGridViewControl.CellFormatting += HandleCellStyling;
+ protected override bool CanGenerateCalculations()
+ {
+ return FailureMechanism.StabilityPointStructures.Any();
}
- protected override void Dispose(bool disposing)
+ protected override void GenerateCalculations()
{
- if (disposing)
+ var calculationGroup = (CalculationGroup) Data;
+ using (var dialog = new StructureSelectionDialog(Parent, FailureMechanism.StabilityPointStructures))
{
- failureMechanismObserver.Dispose();
- inputObserver.Dispose();
- calculationScenarioObserver.Dispose();
- calculationGroupObserver.Dispose();
+ dialog.ShowDialog();
- hydraulicBoundaryLocationsObserver.Dispose();
- stabilityPointStructuresObserver.Dispose();
-
- components?.Dispose();
+ if (dialog.SelectedItems.Any())
+ {
+ StructureCalculationConfigurationHelper.GenerateCalculations(calculationGroup, dialog.SelectedItems.Cast());
+ calculationGroup.NotifyObservers();
+ }
}
-
- base.Dispose(disposing);
}
- private void InitializeDataGridView()
+ protected override void InitializeDataGridView()
{
- dataGridViewControl.CurrentRowChanged += DataGridViewOnCurrentRowChangedHandler;
+ base.InitializeDataGridView();
- dataGridViewControl.AddTextBoxColumn(
- nameof(StabilityPointStructuresCalculationRow.Name),
- RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName);
-
- dataGridViewControl.AddComboBoxColumn>(
- nameof(StabilityPointStructuresCalculationRow.SelectableHydraulicBoundaryLocation),
- RiskeerCommonFormsResources.HydraulicBoundaryLocation_DisplayName,
- null,
- nameof(DataGridViewComboBoxItemWrapper.This),
- nameof(DataGridViewComboBoxItemWrapper.DisplayName));
-
- dataGridViewControl.AddComboBoxColumn>(
+ DataGridViewControl.AddComboBoxColumn>(
nameof(StabilityPointStructuresCalculationRow.ForeshoreProfile),
RiskeerCommonFormsResources.Structure_ForeshoreProfile_DisplayName,
null,
nameof(DataGridViewComboBoxItemWrapper.This),
nameof(DataGridViewComboBoxItemWrapper.DisplayName));
- dataGridViewControl.AddCheckBoxColumn(nameof(StabilityPointStructuresCalculationRow.UseBreakWater),
+ DataGridViewControl.AddCheckBoxColumn(nameof(StabilityPointStructuresCalculationRow.UseBreakWater),
RiskeerCommonFormsResources.Use_BreakWater_DisplayName);
- dataGridViewControl.AddComboBoxColumn(nameof(StabilityPointStructuresCalculationRow.BreakWaterType),
+ DataGridViewControl.AddComboBoxColumn(nameof(StabilityPointStructuresCalculationRow.BreakWaterType),
RiskeerCommonFormsResources.CalculationsView_BreakWaterType_DisplayName,
EnumDisplayWrapperHelper.GetEnumTypes(),
nameof(EnumDisplayWrapper.Value),
nameof(EnumDisplayWrapper.DisplayName));
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.BreakWaterHeight),
RiskeerCommonFormsResources.CalculationsView_BreakWaterHeight_DisplayName);
- dataGridViewControl.AddCheckBoxColumn(nameof(StabilityPointStructuresCalculationRow.UseForeshoreGeometry),
+ DataGridViewControl.AddCheckBoxColumn(nameof(StabilityPointStructuresCalculationRow.UseForeshoreGeometry),
RiskeerCommonFormsResources.Use_Foreshore_DisplayName);
- dataGridViewControl.AddComboBoxColumn(nameof(StabilityPointStructuresCalculationRow.LoadSchematizationType),
+ DataGridViewControl.AddComboBoxColumn(nameof(StabilityPointStructuresCalculationRow.LoadSchematizationType),
RiskeerCommonFormsResources.LoadSchematizationType_DisplayName,
EnumDisplayWrapperHelper.GetEnumTypes(),
nameof(EnumDisplayWrapper.Value),
nameof(EnumDisplayWrapper.DisplayName));
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.ConstructiveStrengthLinearLoadModel),
$"{RiskeerCommonFormsResources.NormalDistribution_Mean_DisplayName}\r\n{RiskeerCommonFormsResources.ConstructiveStrength_Linear_LoadModel_DisplayName}");
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.ConstructiveStrengthQuadraticLoadModel),
$"{RiskeerCommonFormsResources.NormalDistribution_Mean_DisplayName}\r\n{RiskeerCommonFormsResources.ConstructiveStrength_Quadratic_LoadModel_DisplayName}");
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.StabilityLinearLoadModel),
$"{RiskeerCommonFormsResources.NormalDistribution_Mean_DisplayName}\r\n{RiskeerCommonFormsResources.Stability_Linear_LoadModel_DisplayName}");
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.StabilityQuadraticLoadModel),
$"{RiskeerCommonFormsResources.NormalDistribution_Mean_DisplayName}\r\n{RiskeerCommonFormsResources.Stability_Quadratic_LoadModel_DisplayName}");
- dataGridViewControl.AddTextBoxColumn(
+ DataGridViewControl.AddTextBoxColumn(
nameof(StabilityPointStructuresCalculationRow.EvaluationLevel),
RiskeerCommonFormsResources.Evaluation_Level_DisplayName);
}
- private void InitializeListBox()
- {
- listBox.DisplayMember = nameof(FailureMechanismSection.Name);
- listBox.SelectedValueChanged += ListBoxOnSelectedValueChanged;
- }
+ #region Prefill combo box list items
- private void UpdateGenerateCalculationsButtonState()
+ protected override void PrefillComboBoxListItemsAtColumnLevel()
{
- buttonGenerateCalculations.Enabled = failureMechanism.StabilityPointStructures.Any();
- }
+ base.PrefillComboBoxListItemsAtColumnLevel();
- private StabilityPointStructuresInputContext CreateSelectedItemFromCurrentRow()
- {
- DataGridViewRow currentRow = dataGridViewControl.CurrentRow;
+ // Need to prefill for all possible data in order to guarantee 'combo box' columns
+ // do not generate errors when their cell value is not present in the list of available
+ // items.
+ var foreshoreProfiles = (DataGridViewComboBoxColumn) DataGridViewControl.GetColumnFromIndex(foreshoreProfileColumnIndex);
- var calculationRow = (StabilityPointStructuresCalculationRow) currentRow?.DataBoundItem;
-
- StabilityPointStructuresInputContext selection = null;
- if (calculationRow != null)
+ using (new SuspendDataGridViewColumnResizes(foreshoreProfiles))
{
- selection = new StabilityPointStructuresInputContext(
- calculationRow.CalculationScenario.InputParameters,
- calculationRow.CalculationScenario,
- failureMechanism,
- assessmentSection);
+ SetItemsOnObjectCollection(foreshoreProfiles.Items,
+ GetForeshoreProfileDataSource(FailureMechanism.ForeshoreProfiles));
}
-
- return selection;
}
- private static void SetItemsOnObjectCollection(DataGridViewComboBoxCell.ObjectCollection objectCollection, object[] comboBoxItems)
- {
- objectCollection.Clear();
- objectCollection.AddRange(comboBoxItems);
- }
+ #endregion
- private static DataGridViewComboBoxItemWrapper[] GetSelectableHydraulicBoundaryLocationsDataSource(
- IEnumerable selectableHydraulicBoundaryLocations = null)
- {
- var dataGridViewComboBoxItemWrappers = new List>
- {
- new DataGridViewComboBoxItemWrapper(null)
- };
+ #region Event handling
- if (selectableHydraulicBoundaryLocations != null)
- {
- dataGridViewComboBoxItemWrappers.AddRange(selectableHydraulicBoundaryLocations.Select(hbl => new DataGridViewComboBoxItemWrapper(hbl)));
- }
-
- return dataGridViewComboBoxItemWrappers.ToArray();
- }
-
- private void InitializeObservers()
+ private void HandleCellStyling(object sender, DataGridViewCellFormattingEventArgs e)
{
- failureMechanismObserver = new Observer(OnFailureMechanismUpdate)
- {
- Observable = failureMechanism
- };
- hydraulicBoundaryLocationsObserver = new Observer(UpdateSelectableHydraulicBoundaryLocationsColumn)
- {
- Observable = assessmentSection.HydraulicBoundaryDatabase.Locations
- };
- stabilityPointStructuresObserver = new Observer(UpdateGenerateCalculationsButtonState)
- {
- Observable = failureMechanism.StabilityPointStructures
- };
-
- // The concat is needed to observe the input of calculations in child groups.
- inputObserver = new RecursiveObserver(UpdateDataGridViewDataSource, pcg => pcg.Children.Concat