Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs =================================================================== diff -u -r0eef796eb9da995e56fd1e4a61296ec3c25dcfad -ra0500683a36518c9b3cd5bb74fee36b858dda96d --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 0eef796eb9da995e56fd1e4a61296ec3c25dcfad) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision a0500683a36518c9b3cd5bb74fee36b858dda96d) @@ -39,14 +39,15 @@ /// public class GrassCoverErosionInwardsFailureMechanismContextProperties : ObjectProperties { - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; - private const int lengthEffectPropertyIndex = 3; - private const int frunupModelFactorPropertyIndex = 4; - private const int fbFactorPropertyIndex = 5; - private const int fnFactorPropertyIndex = 6; - private const int fshallowModelFactorPropertyIndex = 7; + private const int isRelevantPropertyIndex = 3; + private const int lengthEffectPropertyIndex = 4; + private const int frunupModelFactorPropertyIndex = 5; + private const int fbFactorPropertyIndex = 6; + private const int fnFactorPropertyIndex = 7; + private const int fshallowModelFactorPropertyIndex = 8; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . @@ -55,7 +56,7 @@ /// Handler responsible for handling effects of a property change. /// Thrown when any input parameter is null. public GrassCoverErosionInwardsFailureMechanismContextProperties( - GrassCoverErosionInwardsFailureMechanismContext data, + GrassCoverErosionInwardsFailureMechanismContext data, IFailureMechanismPropertyChangeHandler handler) { if (data == null) @@ -72,6 +73,7 @@ #region Length effect parameters + [DynamicVisible] [PropertyOrder(lengthEffectPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_N_DisplayName))] @@ -95,6 +97,33 @@ #endregion + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (!data.WrappedData.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) + { + return false; + } + return true; + } + + private static void NotifyAffectedObjects(IEnumerable affectedObjects) + { + foreach (var affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); + } + } + + private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) + { + return nameof(LengthEffect).Equals(propertyName) + || nameof(FrunupModelFactor).Equals(propertyName) + || nameof(FbFactor).Equals(propertyName) + || nameof(FnFactor).Equals(propertyName) + || nameof(FshallowModelFactor).Equals(propertyName); + } + #region General [PropertyOrder(namePropertyIndex)] @@ -121,10 +150,23 @@ } } + [PropertyOrder(isRelevantPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_Description))] + public bool IsRelevant + { + get + { + return data.WrappedData.IsRelevant; + } + } + #endregion #region Model settings + [DynamicVisible] [PropertyOrder(frunupModelFactorPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))] @@ -138,6 +180,7 @@ } } + [DynamicVisible] [PropertyOrder(fbFactorPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))] @@ -151,6 +194,7 @@ } } + [DynamicVisible] [PropertyOrder(fnFactorPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))] @@ -164,6 +208,7 @@ } } + [DynamicVisible] [PropertyOrder(fshallowModelFactorPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))] @@ -178,13 +223,5 @@ } #endregion - - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (var affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } } } \ No newline at end of file