using System.Diagnostics;
using System.ComponentModel;
namespace Tizen.NUI.Binding
{
///
/// Struct defining thickness around the edges of a Rectangle using doubles.
///
[DebuggerDisplay("Left={Left}, Top={Top}, Right={Right}, Bottom={Bottom}, HorizontalThickness={HorizontalThickness}, VerticalThickness={VerticalThickness}")]
[TypeConverter(typeof(ThicknessTypeConverter))]
[EditorBrowsable(EditorBrowsableState.Never)]
public struct Thickness
{
///
/// The thickness of the left side of a rectangle.
///
public double Left { get; set; }
///
/// The thickness of the top of a rectangle.
///
public double Top { get; set; }
///
/// The thickness of the right side of a rectangle.
///
public double Right { get; set; }
///
/// The thickness of the bottom of a rectangle.
///
public double Bottom { get; set; }
///
/// The sum of Left and Right.
///
public double HorizontalThickness
{
get { return Left + Right; }
}
///
/// The sum of Top and Bottom.
///
public double VerticalThickness
{
get { return Top + Bottom; }
}
internal bool IsDefault
{
get { return Left == 0 && Top == 0 && Right == 0 && Bottom == 0; }
}
///
/// Creates a new Thickness object that represents a uniform thickness of size uniformSize.
///
/// The uniform size of all edges in the new thickness.
public Thickness(double uniformSize) : this(uniformSize, uniformSize, uniformSize, uniformSize)
{
}
///
/// Creates a new Thickness object that has a horizontal thickness of horizontalSize and a vertical thickness of verticalSize.
///
/// The width of the left and right thicknesses.
/// The height of the top and bottom thicknesses.
public Thickness(double horizontalSize, double verticalSize) : this(horizontalSize, verticalSize, horizontalSize, verticalSize)
{
}
///
/// Creates a new Thickness object with thicknesses defined by left, top, right, and bottom.
///
/// The width of the left thickness.
/// The height of the top thickness.
/// The width of the right thickness.
/// The height of the bottom thickness.
public Thickness(double left, double top, double right, double bottom) : this()
{
Left = left;
Top = top;
Right = right;
Bottom = bottom;
}
///
/// Converts a Size into a Thickness.
///
/// A Size to convert to a Thickness
public static implicit operator Thickness(Size size)
{
return new Thickness(size.Width, size.Height, size.Width, size.Height);
}
///
/// Implicit cast operator from Double.
///
/// The value for the uniform Thickness.
public static implicit operator Thickness(double uniformSize)
{
return new Thickness(uniformSize);
}
///
/// Whether the other has equivalent values.
///
/// A Thickness to be compared.
/// true if other has equivalent values.
bool Equals(Thickness other)
{
return Left.Equals(other.Left) && Top.Equals(other.Top) && Right.Equals(other.Right) && Bottom.Equals(other.Bottom);
}
///
/// Whether the obj has equivalent values.
///
/// A Thickness to be compared.
/// true if obj is a Thickness and has equivalent values.
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
return obj is Thickness && Equals((Thickness)obj);
}
///
/// A hash value for this Thickness.
///
/// The hash value
public override int GetHashCode()
{
unchecked
{
int hashCode = Left.GetHashCode();
hashCode = (hashCode * 397) ^ Top.GetHashCode();
hashCode = (hashCode * 397) ^ Right.GetHashCode();
hashCode = (hashCode * 397) ^ Bottom.GetHashCode();
return hashCode;
}
}
///
/// Whether two Thicknesses have identical values.
///
/// A Thickness to be compared.
/// A Thickness to be compared.
/// true if left and right have identical values for Left,Right, Top, and Bottom.
public static bool operator ==(Thickness left, Thickness right)
{
return left.Equals(right);
}
///
/// Whether the values of two Thickness's have at least one difference.
///
/// A Thickness to be compared.
/// A Thickness to be compared.
/// true if any of the Left,Right, Top, and Bottom values differ between left and right.
public static bool operator !=(Thickness left, Thickness right)
{
return !left.Equals(right);
}
///
/// Stores the components of the thickness in the corresponding arguments.
///
/// Variable in which to store the left thickness of thickness object.
/// Variable in which to store the top thickness of thickness object.
/// Variable in which to store the right thickness of thickness object.
/// Variable in which to store the bottom thickness of thickness object.
public void Deconstruct(out double left, out double top, out double right, out double bottom)
{
left = Left;
top = Top;
right = Right;
bottom = Bottom;
}
}
}