Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs =================================================================== diff -u -r4003f622384a87e09a4c49ced0b53bddd1e487a0 -r3a79a9260f7434ff776602cc53a2b8c6a9f8633e --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision 4003f622384a87e09a4c49ced0b53bddd1e487a0) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision 3a79a9260f7434ff776602cc53a2b8c6a9f8633e) @@ -26,7 +26,6 @@ using Core.Common.Base.Data; using Core.Common.Util.Attributes; using Core.Gui.Attributes; -using Core.Gui.PropertyBag; using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionInwards.Data; using Riskeer.GrassCoverErosionInwards.Forms.Properties; @@ -37,7 +36,7 @@ /// /// Calculation related ViewModel of for properties panel. /// - public class GrassCoverErosionInwardsCalculationsProperties : ObjectProperties + public class GrassCoverErosionInwardsCalculationsProperties : GrassCoverErosionInwardsFailureMechanismProperties { private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; @@ -58,8 +57,15 @@ /// Thrown when any input parameter is null. public GrassCoverErosionInwardsCalculationsProperties( GrassCoverErosionInwardsFailureMechanism data, - IFailureMechanismPropertyChangeHandler handler) + IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex, + NPropertyIndex = nPropertyIndex + }, handler ) + { if (data == null) { throw new ArgumentNullException(nameof(data)); @@ -74,31 +80,6 @@ propertyChangeHandler = handler; } - #region Length effect parameters - - [PropertyOrder(nPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] - public RoundedDouble N - { - get - { - return data.GeneralInput.N; - } - set - { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (f, v) => f.GeneralInput.N = v); - - NotifyAffectedObjects(affectedObjects); - } - } - - #endregion - private static void NotifyAffectedObjects(IEnumerable affectedObjects) { foreach (IObservable affectedObject in affectedObjects) @@ -109,47 +90,11 @@ #region General - [PropertyOrder(namePropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_Description))] - public string Name - { - get - { - return data.Name; - } - } - - [PropertyOrder(codePropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_Description))] - public string Code - { - get - { - return data.Code; - } - } - - [PropertyOrder(groupPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Group_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Group_Description))] - public int Group - { - get - { - return data.Group; - } - } - [PropertyOrder(contributionPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] - public double Contribution + public override double Contribution { get { @@ -214,5 +159,30 @@ } #endregion + + #region Length effect parameters + + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] + public override RoundedDouble N + { + get + { + return data.GeneralInput.N; + } + set + { + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( + data, + value, + (f, v) => f.GeneralInput.N = v); + + NotifyAffectedObjects(affectedObjects); + } + } + + #endregion } } \ No newline at end of file Fisheye: Tag 12974d5032777e3a29fe5566ebe16e7b80012290 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (revision 3a79a9260f7434ff776602cc53a2b8c6a9f8633e) @@ -0,0 +1,161 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.Common.Forms.PropertyClasses; +using Riskeer.GrassCoverErosionInwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionInwards.Forms.PropertyClasses +{ + /// + /// Failure path related ViewModel of for properties panel. + /// + public class GrassCoverErosionInwardsFailurePathProperties : GrassCoverErosionInwardsFailureMechanismProperties + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int groupPropertyIndex = 3; + private const int contributionPropertyIndex = 4; + private const int isRelevantPropertyIndex = 5; + private const int nPropertyIndex = 6; + + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Handler responsible for handling effects of a property change. + /// Thrown when any input parameter is null. + public GrassCoverErosionInwardsFailurePathProperties( + GrassCoverErosionInwardsFailureMechanism data, + IFailureMechanismPropertyChangeHandler handler) : + base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex, + NPropertyIndex = nPropertyIndex + }, handler) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + + Data = data; + propertyChangeHandler = handler; + } + + #region Length effect parameters + + [DynamicVisible] + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] + public override RoundedDouble N + { + get + { + return data.GeneralInput.N; + } + set + { + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( + data, + value, + (f, v) => f.GeneralInput.N = v); + + NotifyAffectedObjects(affectedObjects); + } + } + + #endregion + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (!data.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) + { + return false; + } + + return true; + } + + private static void NotifyAffectedObjects(IEnumerable affectedObjects) + { + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); + } + } + + private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) + { + return nameof(Contribution).Equals(propertyName) + || nameof(N).Equals(propertyName); + } + + #region General + + [DynamicVisible] + [PropertyOrder(contributionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] + public override double Contribution + { + get + { + return data.Contribution; + } + } + + [PropertyOrder(isRelevantPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_Description))] + public bool IsRelevant + { + get + { + return data.IsRelevant; + } + } + + #endregion + + } +} \ No newline at end of file