Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/BackgroundData.cs =================================================================== diff -u -r7a4f8ff71ae5f81177fe5ff9cd78fdc7f24c69f4 -r657e48b8886aa9641a3673f4fe9c4b81efc72260 --- Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/BackgroundData.cs (.../BackgroundData.cs) (revision 7a4f8ff71ae5f81177fe5ff9cd78fdc7f24c69f4) +++ Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/BackgroundData.cs (.../BackgroundData.cs) (revision 657e48b8886aa9641a3673f4fe9c4b81efc72260) @@ -19,25 +19,33 @@ // 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 Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.AssessmentSection { /// /// Class that holds information about configured background data. /// public class BackgroundData : Observable - { + private const int transparencyNumberOfDecimals = 2; + + private static readonly Range transparencyValidityRange = new Range(new RoundedDouble(transparencyNumberOfDecimals), + new RoundedDouble(transparencyNumberOfDecimals, 1)); + + private RoundedDouble transparency; + /// /// Creates a new . /// public BackgroundData() { IsVisible = true; - Transparency = new RoundedDouble(2); + transparency = new RoundedDouble(transparencyNumberOfDecimals); Parameters = new Dictionary(); } @@ -51,8 +59,28 @@ /// /// Gets or sets the transparency of the background. /// - public RoundedDouble Transparency { get; set; } + /// Thrown when setting a new value + /// that is not in the range [0.0, 1.0]. + public RoundedDouble Transparency + { + get + { + return transparency; + } + set + { + var newValue = value.ToPrecision(transparency.NumberOfDecimalPlaces); + if (!transparencyValidityRange.InRange(newValue)) + { + throw new ArgumentOutOfRangeException(nameof(value), + string.Format(Resources.BackgroundData_Transparency_Value_must_be_in_Range_0_, + transparencyValidityRange)); + } + transparency = newValue; + } + } + /// /// Gets or sets the type of the background map data. ///