using System.ComponentModel; using System.Xml.Serialization; using Deltares.Standard; using Deltares.Standard.Attributes; using Deltares.Standard.Language; namespace Deltares.Stability { /// /// This class represents a calculated zone for a given dike profile. /// The zone contains the safety factor and the sliding curve /// public class Zone { // TODO: find a proper way to use the constant defined in StabilityCalculation public static double DefaultSafetyZone = -9999.99; private SlidingCurve minimumSafetyCurve = null; private string specialName = string.Empty; private bool subZones = true; private int zoneId; public Zone() {} /// /// Gets or sets the safety curve for this zone /// [Label("Safety curve")] public SlidingCurve MinimumSafetyCurve { get { return minimumSafetyCurve; } set { minimumSafetyCurve = value; } } [Label("Safety factor")] [Format("F3")] public double SafetyFactor { get { return MinimumSafetyCurve == null ? DefaultSafetyZone : MinimumSafetyCurve.SafetyFactor; } } /// /// Gets or sets the zone id or number used in the calculation /// [Browsable(false)] public int ZoneId { get { return zoneId; } set { zoneId = value; } } /// /// Special name which will ne used instead of the name based on the zone id /// [Browsable(false)] public string SpecialName { get { return specialName; } set { specialName = value; } } /// /// Indicates whether the zone is defined as a subzone. e.g. 1a instead of 1 /// [Browsable(false)] public bool SubZones { get { return subZones; } set { subZones = value; } } /// /// Gets the name of this safety zone /// [XmlIgnore] public string Name { get { if (!string.IsNullOrWhiteSpace(specialName)) { return specialName; } if (subZones) { switch (ZoneId) { case 0: return LocalizationManager.GetTranslatedText(typeof(Zone), "AllZones"); case 1: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone1a"); case 2: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone1b"); case 3: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone2a"); case 4: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone2b"); case 5: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone3a"); case 6: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone3b"); default: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone") + " " + ZoneId; } } else { switch (ZoneId) { case 0: return LocalizationManager.GetTranslatedText(typeof(Zone), "AllZones"); case 1: case 2: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone1"); case 3: case 4: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone2"); case 5: case 6: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone3"); default: return LocalizationManager.GetTranslatedText(typeof(Zone), "SafetyZone") + " " + ZoneId; } } } } public bool IsEmpty { get; private set; } /// /// Creates an empty zone. /// /// public static Zone Empty() { return new Zone() { IsEmpty = true }; } public override string ToString() { return Name; } } }