using System;
using System.ComponentModel;
using System.Xml.Serialization;
using Deltares.Geotechnics;
using Deltares.Standard;
using Deltares.Standard.Attributes;
using Deltares.Standard.EventPublisher;
using Deltares.Standard.Language;
using Deltares.Standard.Units;
using Deltares.Standard.Validation;
namespace Deltares.DeltaModel
{
///
/// Revetment Layer Object
/// TODO: Comment
///
public class BlockRevetmentLayer : IVisibleEnabled, ICloneable
{
private object material;
private bool obliged;
private bool present = true;
private double thickness;
private BlockRevetmentLayerType type = BlockRevetmentLayerType.None;
///
/// Initializes a new instance of the class.
///
public BlockRevetmentLayer() {}
///
/// Initializes a new instance of the class.
///
/// The material.
/// if set to true, internal present and obliged will be set to true.
/// The revetment layer type.
public BlockRevetmentLayer(object material, bool obliged, BlockRevetmentLayerType type)
{
this.type = type;
this.material = material;
this.obliged = obliged;
present = obliged;
}
///
/// Gets the type.
///
///
/// The type.
///
[ReadOnly(true)]
public BlockRevetmentLayerType Type
{
get
{
return type;
}
set
{
this.SetAndNotify2(out type, value, x => x.Type);
}
}
///
/// Indicates whether the layer is used in the revetment calculation
///
[PropertyOrder(1, 1)]
public bool Present
{
get
{
return present;
}
set
{
this.SetAndNotify2(out present, value || obliged, x => x.Present);
}
}
///
/// Gets or sets the thickness.
///
///
/// The thickness.
///
[Unit(UnitType.Length)]
[Format("F3")]
[PropertyOrder(1, 2)]
[Clearable]
public virtual double Thickness
{
get
{
return thickness;
}
set
{
this.SetAndNotify2(out thickness, value, x => x.Thickness);
}
}
///
/// Gets or sets the material.
///
///
/// The material.
///
[PropertyOrder(1, 2)]
[Validate]
public object Material
{
get
{
return material;
}
set
{
this.SetAndNotify2(out material, value, x => x.Material);
}
}
///
/// Gets or sets the revetment profile.
///
///
/// The revetment profile.
///
[XmlIgnore]
[Browsable(false)]
public BlockRevetmentProfile BlockRevetmentProfile { get; set; }
///
/// Gets or sets a value indicating whether obliged.
///
///
/// true if obliged; otherwise, false.
///
[Browsable(false)]
public bool Obliged
{
get
{
return obliged;
}
set
{
obliged = value;
}
}
public override string ToString()
{
return LocalizationManager.GetTranslatedText(typeof(BlockRevetmentLayerType), Type.ToString());
}
///
/// Creates a deep clone of the .
///
/// A deep clone.
/// When is not cloneable.
public BlockRevetmentLayer Clone()
{
if (material != null && !(material is ICloneable))
{
throw new InvalidOperationException("Material should be cloneable");
}
var clonedMaterial = material != null ? ((ICloneable) material).Clone() : null;
return new BlockRevetmentLayer(clonedMaterial, Obliged, Type)
{
present = present,
thickness = thickness
};
}
///
/// Determines whether the specified property is enabled.
///
/// The property.
/// for Property false if obliged is true, otherwisse true
public bool IsEnabled(string property)
{
switch (property)
{
case "Present":
return !Obliged;
default:
return true;
}
}
///
/// Determines whether the specified property is visible.
///
/// The property.
/// truefor property is Present, otherwise value of this.Present
public bool IsVisible(string property)
{
return property.Equals("Present") || Present;
}
}
}