1 using System.Diagnostics;
2 using System.ComponentModel;
4 namespace Tizen.NUI.Binding
7 /// Struct defining thickness around the edges of a Rectangle using doubles.
9 [DebuggerDisplay("Left={Left}, Top={Top}, Right={Right}, Bottom={Bottom}, HorizontalThickness={HorizontalThickness}, VerticalThickness={VerticalThickness}")]
10 [TypeConverter(typeof(ThicknessTypeConverter))]
11 [EditorBrowsable(EditorBrowsableState.Never)]
12 public struct Thickness
15 /// The thickness of the left side of a rectangle.
17 public double Left { get; set; }
20 /// The thickness of the top of a rectangle.
22 public double Top { get; set; }
25 /// The thickness of the right side of a rectangle.
27 public double Right { get; set; }
30 /// The thickness of the bottom of a rectangle.
32 public double Bottom { get; set; }
35 /// The sum of Left and Right.
37 public double HorizontalThickness
39 get { return Left + Right; }
43 /// The sum of Top and Bottom.
45 public double VerticalThickness
47 get { return Top + Bottom; }
50 internal bool IsDefault
52 get { return Left == 0 && Top == 0 && Right == 0 && Bottom == 0; }
56 /// Creates a new Thickness object that represents a uniform thickness of size uniformSize.
58 /// <param name="uniformSize">The uniform size of all edges in the new thickness.</param>
59 public Thickness(double uniformSize) : this(uniformSize, uniformSize, uniformSize, uniformSize)
64 /// Creates a new Thickness object that has a horizontal thickness of horizontalSize and a vertical thickness of verticalSize.
66 /// <param name="horizontalSize">The width of the left and right thicknesses.</param>
67 /// <param name="verticalSize">The height of the top and bottom thicknesses.</param>
68 public Thickness(double horizontalSize, double verticalSize) : this(horizontalSize, verticalSize, horizontalSize, verticalSize)
73 /// Creates a new Thickness object with thicknesses defined by left, top, right, and bottom.
75 /// <param name="left">The width of the left thickness.</param>
76 /// <param name="top">The height of the top thickness.</param>
77 /// <param name="right">The width of the right thickness.</param>
78 /// <param name="bottom">The height of the bottom thickness.</param>
79 public Thickness(double left, double top, double right, double bottom) : this()
88 /// Converts a Size into a Thickness.
90 /// <param name="size">A Size to convert to a Thickness</param>
91 public static implicit operator Thickness(Size size)
93 return new Thickness(size.Width, size.Height, size.Width, size.Height);
97 /// Implicit cast operator from Double.
99 /// <param name="uniformSize">The value for the uniform Thickness.</param>
100 public static implicit operator Thickness(double uniformSize)
102 return new Thickness(uniformSize);
106 /// Whether the other has equivalent values.
108 /// <param name="other">A Thickness to be compared.</param>
109 /// <returns>true if other has equivalent values.</returns>
110 bool Equals(Thickness other)
112 return Left.Equals(other.Left) && Top.Equals(other.Top) && Right.Equals(other.Right) && Bottom.Equals(other.Bottom);
116 /// Whether the obj has equivalent values.
118 /// <param name="obj">A Thickness to be compared.</param>
119 /// <returns>true if obj is a Thickness and has equivalent values.</returns>
120 public override bool Equals(object obj)
122 if (ReferenceEquals(null, obj))
124 return obj is Thickness && Equals((Thickness)obj);
128 /// A hash value for this Thickness.
130 /// <returns>The hash value</returns>
131 public override int GetHashCode()
135 int hashCode = Left.GetHashCode();
136 hashCode = (hashCode * 397) ^ Top.GetHashCode();
137 hashCode = (hashCode * 397) ^ Right.GetHashCode();
138 hashCode = (hashCode * 397) ^ Bottom.GetHashCode();
144 /// Whether two Thicknesses have identical values.
146 /// <param name="left">A Thickness to be compared.</param>
147 /// <param name="right">A Thickness to be compared.</param>
148 /// <returns>true if left and right have identical values for Left,Right, Top, and Bottom.</returns>
149 public static bool operator ==(Thickness left, Thickness right)
151 return left.Equals(right);
155 /// Whether the values of two Thickness's have at least one difference.
157 /// <param name="left">A Thickness to be compared.</param>
158 /// <param name="right">A Thickness to be compared.</param>
159 /// <returns>true if any of the Left,Right, Top, and Bottom values differ between left and right.</returns>
160 public static bool operator !=(Thickness left, Thickness right)
162 return !left.Equals(right);
166 /// Stores the components of the thickness in the corresponding arguments.
168 /// <param name="left">Variable in which to store the left thickness of thickness object.</param>
169 /// <param name="top">Variable in which to store the top thickness of thickness object.</param>
170 /// <param name="right">Variable in which to store the right thickness of thickness object.</param>
171 /// <param name="bottom">Variable in which to store the bottom thickness of thickness object.</param>
172 public void Deconstruct(out double left, out double top, out double right, out double bottom)