Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -r2b62d771a30ac4a3a59b52efc9df88afbc6663b2 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 2b62d771a30ac4a3a59b52efc9df88afbc6663b2) @@ -19,11 +19,18 @@ // 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.Linq; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; using Ringtoets.Integration.Forms.PresentationObjects; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -35,42 +42,173 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public abstract class HydraulicBoundaryLocationProperties : ObjectProperties { + private readonly Dictionary propertyIndexLookup; + + protected HydraulicBoundaryLocationProperties(ConstructionProperties propertyIndexes) + { + propertyIndexLookup = new Dictionary + { + { + nameof(Id), propertyIndexes.IdIndex + }, + { + nameof(Name), propertyIndexes.NameIndex + }, + { + nameof(Location), propertyIndexes.LocationIndex + }, + { + nameof(GoverningWindDirection), propertyIndexes.GoverningWindDirectionIndex + }, + { + nameof(AlphaValues), propertyIndexes.StochastsIndex + }, + { + nameof(Durations), propertyIndexes.DurationsIndex + }, + { + nameof(IllustrationPoints), propertyIndexes.IllustrationPointsIndex + } + }; + } + + public class ConstructionProperties + { + public int IdIndex { get; set; } = 1; + public int NameIndex { get; set; } = 2; + public int LocationIndex { get; set; } = 3; + public int GoverningWindDirectionIndex { get; set; } = 4; + public int StochastsIndex { get; set; } = 5; + public int DurationsIndex { get; set; } = 6; + public int IllustrationPointsIndex { get; set; } = 7; + } + + [DynamicPropertyOrderEvaluationMethod] + public int DynamicPropertyOrderEvaluationMethod(string propertyName) + { + int propertyIndex; + + propertyIndexLookup.TryGetValue(propertyName, out propertyIndex); + + return propertyIndex; + } + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + bool hasGeneralIllustrationPointsResult = GetGeneralIllustrationPointsResult() != null; + if (propertyName == nameof(GoverningWindDirection) + || propertyName == nameof(AlphaValues) + || propertyName == nameof(Durations) + || propertyName == nameof(IllustrationPoints)) + { + return hasGeneralIllustrationPointsResult; + } + + return true; + } + + [DynamicPropertyOrder] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Id_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Id_Description))] - public virtual long Id + public long Id { get { return data.HydraulicBoundaryLocation.Id; } } + [DynamicPropertyOrder] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Name_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Name_Description))] - public virtual string Name + public string Name { get { return data.HydraulicBoundaryLocation.Name; } } + [DynamicPropertyOrder] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Coordinates_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Coordinates_Description))] - public virtual Point2D Location + public Point2D Location { get { return data.HydraulicBoundaryLocation.Location; } } + [DynamicPropertyOrder] + [DynamicVisible] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_IllustrationPoints))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_GoverningWindDirection_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_GoverningWindDirection_Description))] + public string GoverningWindDirection + { + get + { + return GetGeneralIllustrationPointsResult().GoverningWindDirection.Name; + } + } + + [DynamicPropertyOrder] + [DynamicVisible] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_IllustrationPoints))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_Description))] + [TypeConverter(typeof(KeyValueExpandableArrayConverter))] + public KeyValueExpandableArrayElement[] AlphaValues + { + get + { + return GetGeneralIllustrationPointsResult().Stochasts.Select(s => new KeyValueExpandableArrayElement(s.Name, s.Alpha)).ToArray(); + } + } + + [DynamicPropertyOrder] + [DynamicVisible] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_IllustrationPoints))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_Description))] + [TypeConverter(typeof(KeyValueExpandableArrayConverter))] + public KeyValueExpandableArrayElement[] Durations + { + get + { + return GetGeneralIllustrationPointsResult().Stochasts.Select(s => new KeyValueExpandableArrayElement(s.Name, s.Duration)).ToArray(); + } + } + + [DynamicPropertyOrder] + [DynamicVisible] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_IllustrationPoints))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_IllustrationPoints_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_IllustrationPoints_Description))] + [TypeConverter(typeof(ExpandableArrayConverter))] + public IEnumerable IllustrationPoints + { + get + { + return GetGeneralIllustrationPointsResult().WindDirectionClosingSituationIllustrationPoints; + } + } + + /// + /// Gets the general illustration points result. + /// + /// The general illustration points if it has obtained as part of the calculation, null + /// otherwise. + protected abstract GeneralResult GetGeneralIllustrationPointsResult(); + public override string ToString() { - return string.Format("{0} {1}", Name, Location); + return $"{Name} {Location}"; } } } \ No newline at end of file