Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FaultTreeIllustrationPointProperties.cs =================================================================== diff -u -r9c8a4be86a9b3659738256e8f1c0542339d7b16a -ra49798da6ac2176d2e8b28ec6fec8a2494d8ee91 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FaultTreeIllustrationPointProperties.cs (.../FaultTreeIllustrationPointProperties.cs) (revision 9c8a4be86a9b3659738256e8f1c0542339d7b16a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FaultTreeIllustrationPointProperties.cs (.../FaultTreeIllustrationPointProperties.cs) (revision a49798da6ac2176d2e8b28ec6fec8a2494d8ee91) @@ -38,21 +38,28 @@ public class FaultTreeIllustrationPointProperties : IllustrationPointProperties { private readonly FaultTreeIllustrationPoint faultTreeIllustrationPoint; + private readonly IEnumerable childNodes; /// /// Creates a new instance of . /// - /// The data to use for the properties. + /// The fault tree illustration point to use for the properties. /// The child nodes that belongs to the . /// String containing the wind direction for this illustration point. /// String containing the name of the closing situation. If empty /// the property will not be visible. /// Thrown when any input parameter is null. - public FaultTreeIllustrationPointProperties(IllustrationPointBase illustrationPoint, IEnumerable childNodes, - string windDirection, string closingSituation) - : base(illustrationPoint, childNodes, windDirection, closingSituation) + public FaultTreeIllustrationPointProperties(FaultTreeIllustrationPoint illustrationPoint, IEnumerable childNodes, + string windDirection, string closingSituation) + : base(illustrationPoint, windDirection, closingSituation) { - faultTreeIllustrationPoint = (FaultTreeIllustrationPoint) data; + if (childNodes == null) + { + throw new ArgumentNullException(nameof(childNodes)); + } + + faultTreeIllustrationPoint = illustrationPoint; + this.childNodes = childNodes; } [PropertyOrder(4)] @@ -82,5 +89,50 @@ return faultTreeIllustrationPoint.Stochasts.ToArray(); } } + + [DynamicVisible] + [PropertyOrder(6)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_IllustrationPoints))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.IllustrationPointProperty_IllustrationPoints_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.IllustrationPointProperty_IllustrationPoints_Description))] + [TypeConverter(typeof(ExpandableArrayConverter))] + [KeyValueElement(nameof(WindDirection), "")] + public IllustrationPointProperties[] IllustrationPoints + { + get + { + var points = new List(); + foreach (IllustrationPointNode illustrationPointNode in childNodes) + { + var faultTreeIllustrationPointChild = illustrationPointNode.Data as FaultTreeIllustrationPoint; + if (faultTreeIllustrationPointChild != null) + { + points.Add(new FaultTreeIllustrationPointProperties(faultTreeIllustrationPointChild, + illustrationPointNode.Children, + WindDirection, ClosingSituation)); + continue; + } + + var subMechanismIllustrationPoint = illustrationPointNode.Data as SubMechanismIllustrationPoint; + if (subMechanismIllustrationPoint != null) + { + points.Add(new SubMechanismIllustrationPointProperties(subMechanismIllustrationPoint, + WindDirection, ClosingSituation)); + continue; + } + + // If type is not supported, throw exception (currently not possible, safeguard for future) + throw new NotSupportedException($"IllustrationPointNode of type {illustrationPointNode.Data.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); + } + return points.ToArray(); + } + } + + [DynamicVisibleValidationMethod] + public override bool IsDynamicVisible(string propertyName) + { + return propertyName.Equals(nameof(IllustrationPoints)) ? childNodes.Any() : base.IsDynamicVisible(propertyName); + } } } \ No newline at end of file