Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/InputContextBase.cs =================================================================== diff -u -rae2a0c4541ca16857b307834e4ba8159e596ab28 -rcad219225ee11e816a86a0763d7b888a4d49d8a0 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/InputContextBase.cs (.../InputContextBase.cs) (revision ae2a0c4541ca16857b307834e4ba8159e596ab28) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/InputContextBase.cs (.../InputContextBase.cs) (revision cad219225ee11e816a86a0763d7b888a4d49d8a0) @@ -59,6 +59,6 @@ /// /// Gets the calculation item which the context belongs to. /// - public ICalculation Calculation { get; private set; } + public TCalculation Calculation { get; private set; } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs =================================================================== diff -u -rca23b1b155ca87c0aa4665fd919727570f31c781 -rcad219225ee11e816a86a0763d7b888a4d49d8a0 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs (.../HeightStructuresInputContext.cs) (revision ca23b1b155ca87c0aa4665fd919727570f31c781) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs (.../HeightStructuresInputContext.cs) (revision cad219225ee11e816a86a0763d7b888a4d49d8a0) @@ -30,7 +30,7 @@ /// Presentation object for all data required to configure an instance of /// in order to be able to configure height structures calculations. /// - public class HeightStructuresInputContext : FailureMechanismItemContextBase + public class HeightStructuresInputContext : InputContextBase { /// /// Creates a new instance of . @@ -42,11 +42,8 @@ public HeightStructuresInputContext(HeightStructuresCalculation calculation, HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) - : base(ValidateCalculation(calculation).InputParameters, failureMechanism, assessmentSection) { + : base(ValidateCalculation(calculation).InputParameters, calculation, failureMechanism, assessmentSection) {} - Calculation = calculation; - } - private static HeightStructuresCalculation ValidateCalculation(HeightStructuresCalculation calculation) { if (calculation == null) @@ -55,10 +52,5 @@ } return calculation; } - - /// - /// Gets the calculation item which the context belongs to. - /// - public HeightStructuresCalculation Calculation { get; private set; } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -rfd6db3bae09296e4da11ac9fb9e5dde9b31bc178 -rcad219225ee11e816a86a0763d7b888a4d49d8a0 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision fd6db3bae09296e4da11ac9fb9e5dde9b31bc178) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision cad219225ee11e816a86a0763d7b888a4d49d8a0) @@ -19,38 +19,28 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing.Design; using Core.Common.Base.Data; -using Core.Common.Base.Geometry; using Core.Common.Gui.Attributes; -using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.DikeProfiles; -using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HeightStructures.Forms.Properties; using Ringtoets.HeightStructures.Utils; -using Ringtoets.HydraRing.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.HeightStructures.Forms.PropertyClasses { /// /// ViewModel of for properties panel. /// - public class HeightStructuresInputContextProperties : ObjectProperties, - IHasStructureProperty, - IHasForeshoreProfileProperty, - IHasHydraulicBoundaryLocationProperty + public class HeightStructuresInputContextProperties : StructuresInputBaseProperties { - private const int heightStructurePropertyIndex = 1; - private const int heightStructureLocationPropertyIndex = 2; + private const int structurePropertyIndex = 1; + private const int structureLocationPropertyIndex = 2; private const int structureNormalOrientationPropertyIndex = 3; private const int flowWidthAtBottomProtectionPropertyIndex = 4; private const int widthFlowAperturesPropertyIndex = 5; @@ -67,158 +57,27 @@ private const int stormDurationPropertyIndex = 16; private const int deviationWaveDirectionPropertyIndex = 17; - #region Model factors - - [PropertyOrder(modelFactorSuperCriticalFlowPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_ModelFactorSuperCriticalFlow_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_ModelFactorSuperCriticalFlow_Description")] - public NormalDistributionProperties ModelFactorSuperCriticalFlow + public HeightStructuresInputContextProperties() : base(new ConstructionProperties { - get - { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData) - { - Data = data.WrappedData.ModelFactorSuperCriticalFlow - }; - } - } + StructurePropertyIndex = structurePropertyIndex, + StructureLocationPropertyIndex = structureLocationPropertyIndex, + StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, + FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, + WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, + StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, + AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, + CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, + FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, + ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, + UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, + UseForeshorePropertyIndex = useForeshorePropertyIndex, + ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, + HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, + StormDurationPropertyIndex = stormDurationPropertyIndex + }) {} - #endregion - - public IEnumerable GetAvailableForeshoreProfiles() - { - return data.FailureMechanism.ForeshoreProfiles; - } - - public IEnumerable GetAvailableHydraulicBoundaryLocations() - { - return data.AvailableHydraulicBoundaryLocations; - } - - public IEnumerable GetAvailableStructures() - { - return data.FailureMechanism.HeightStructures; - } - #region Schematization - [PropertyOrder(heightStructurePropertyIndex)] - [Editor(typeof(StructureEditor), typeof(UITypeEditor))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_Description")] - public HeightStructure Structure - { - get - { - return data.WrappedData.Structure; - } - set - { - data.WrappedData.Structure = value; - HeightStructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); - data.WrappedData.NotifyObservers(); - } - } - - [PropertyOrder(heightStructureLocationPropertyIndex)] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_Location_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_Location_Description")] - public Point2D HeightStructureLocation - { - get - { - return data.WrappedData.Structure == null ? null : - new Point2D( - new RoundedDouble(0, data.WrappedData.Structure.Location.X), - new RoundedDouble(0, data.WrappedData.Structure.Location.Y)); - } - } - - [PropertyOrder(structureNormalOrientationPropertyIndex)] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_StructureNormalOrientation_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_StructureNormalOrientation_Description")] - public RoundedDouble StructureNormalOrientation - { - get - { - return data.WrappedData.StructureNormalOrientation; - } - set - { - data.WrappedData.StructureNormalOrientation = value; - data.WrappedData.NotifyObservers(); - } - } - - [PropertyOrder(flowWidthAtBottomProtectionPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_FlowWidthAtBottomProtection_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_FlowWidthAtBottomProtection_Description")] - public LogNormalDistributionProperties FlowWidthAtBottomProtection - { - get - { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) - { - Data = data.WrappedData.FlowWidthAtBottomProtection - }; - } - } - - [PropertyOrder(widthFlowAperturesPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_WidthFlowApertures_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_WidthFlowApertures_Description")] - public VariationCoefficientNormalDistributionProperties WidthFlowApertures - { - get - { - return new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) - { - Data = data.WrappedData.WidthFlowApertures - }; - } - } - - [PropertyOrder(storageStructureAreaPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_StorageStructureArea_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_StorageStructureArea_Description")] - public VariationCoefficientLogNormalDistributionProperties StorageStructureArea - { - get - { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) - { - Data = data.WrappedData.StorageStructureArea - }; - } - } - - [PropertyOrder(allowedLevelIncreaseStoragePropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_AllowedLevelIncreaseStorage_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_AllowedLevelIncreaseStorage_Description")] - public LogNormalDistributionProperties AllowedLevelIncreaseStorage - { - get - { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) - { - Data = data.WrappedData.AllowedLevelIncreaseStorage - }; - } - } - [PropertyOrder(levelCrestStructurePropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] @@ -235,138 +94,10 @@ } } - [PropertyOrder(criticalOvertoppingDischargePropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_CriticalOvertoppingDischarge_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_CriticalOvertoppingDischarge_Description")] - public VariationCoefficientLogNormalDistributionProperties CriticalOvertoppingDischarge - { - get - { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) - { - Data = data.WrappedData.CriticalOvertoppingDischarge - }; - } - } - - [PropertyOrder(failureProbabilityStructureWithErosionPropertyIndex)] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_FailureProbabilityStructureWithErosion_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_FailureProbabilityStructureWithErosion_Description")] - public string FailureProbabilityStructureWithErosion - { - get - { - return ProbabilityFormattingHelper.Format(data.WrappedData.FailureProbabilityStructureWithErosion); - } - set - { - if (value == null) - { - throw new ArgumentNullException("value", RingtoetsCommonFormsResources.FailureProbabilityStructureWithErosion_Value_cannot_be_null); - } - try - { - data.WrappedData.FailureProbabilityStructureWithErosion = (RoundedDouble) double.Parse(value); - } - catch (OverflowException) - { - throw new ArgumentException(RingtoetsCommonFormsResources.FailureProbabilityStructureWithErosion_Value_too_large); - } - catch (FormatException) - { - throw new ArgumentException(RingtoetsCommonFormsResources.FailureProbabilityStructureWithErosion_Could_not_parse_string_to_double_value); - } - data.WrappedData.NotifyObservers(); - } - } - - [PropertyOrder(foreshoreProfilePropertyIndex)] - [Editor(typeof(ForeshoreProfileEditor), typeof(UITypeEditor))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_ForeshoreProfile_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_ForeshoreProfile_Description")] - public ForeshoreProfile ForeshoreProfile - { - get - { - return data.WrappedData.ForeshoreProfile; - } - set - { - data.WrappedData.ForeshoreProfile = value; - data.WrappedData.NotifyObservers(); - } - } - - [PropertyOrder(useBreakWaterPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "BreakWaterProperties_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "BreakWaterProperties_Description")] - public UseBreakWaterProperties UseBreakWater - { - get - { - return data.WrappedData.ForeshoreProfile == null ? - new UseBreakWaterProperties(null) : - new UseBreakWaterProperties(data.WrappedData); - } - } - - [PropertyOrder(useForeshorePropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "ForeshoreProperties_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "ForeshoreProperties_Description")] - public UseForeshoreProperties UseForeshore - { - get - { - return new UseForeshoreProperties(data.WrappedData); - } - } - #endregion #region Hydraulic data - [PropertyOrder(hydraulicBoundaryLocationPropertyIndex)] - [Editor(typeof(HydraulicBoundaryLocationEditor), typeof(UITypeEditor))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_Description")] - public HydraulicBoundaryLocation HydraulicBoundaryLocation - { - get - { - return data.WrappedData.HydraulicBoundaryLocation; - } - set - { - data.WrappedData.HydraulicBoundaryLocation = value; - data.WrappedData.NotifyObservers(); - } - } - - [PropertyOrder(stormDurationPropertyIndex)] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "Structure_StormDuration_DisplayName")] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "Structure_StormDuration_Description")] - public VariationCoefficientLogNormalDistributionProperties StormDuration - { - get - { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation, data.WrappedData) - { - Data = data.WrappedData.StormDuration - }; - } - } - [PropertyOrder(deviationWaveDirectionPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(Resources), "DeviationWaveDirection_DisplayName")] @@ -385,5 +116,20 @@ } #endregion + + public override IEnumerable GetAvailableForeshoreProfiles() + { + return data.FailureMechanism.ForeshoreProfiles; + } + + public override IEnumerable GetAvailableStructures() + { + return data.FailureMechanism.HeightStructures; + } + + protected override void AfterSettingStructure() + { + HeightStructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); + } } } \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -rcb4c5e6cd9a0478a8afe7d653bb7467b3c1a2b4e -rcad219225ee11e816a86a0763d7b888a4d49d8a0 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision cb4c5e6cd9a0478a8afe7d653bb7467b3c1a2b4e) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision cad219225ee11e816a86a0763d7b888a4d49d8a0) @@ -81,10 +81,7 @@ var properties = new HeightStructuresInputContextProperties(); // Assert - Assert.IsInstanceOf>(properties); - Assert.IsInstanceOf>(properties); - Assert.IsInstanceOf(properties); - Assert.IsInstanceOf(properties); + Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); } @@ -109,7 +106,7 @@ var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion); Assert.IsNull(properties.Structure); - Assert.IsNull(properties.HeightStructureLocation); + Assert.IsNull(properties.StructureLocation); Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data); Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation); Assert.AreSame(input.LevelCrestStructure, properties.LevelCrestStructure.Data); @@ -179,7 +176,7 @@ var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion); Assert.AreSame(input.Structure, properties.Structure); - Assert.AreEqual(expectedHeightStructureLocation, properties.HeightStructureLocation); + Assert.AreEqual(expectedHeightStructureLocation, properties.StructureLocation); Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data); Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation); Assert.AreSame(input.LevelCrestStructure, properties.LevelCrestStructure.Data);