2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 /// Struct defining height and width as a pair of generic type.
24 public struct Size : IEquatable<Size>
27 /// Magnitude along the horizontal axis, in platform-defined units.
32 /// Magnitude along the vertical axis, in platform-specific units.
37 /// Initializes a new instance of the Size structure from the specified dimensions.
39 /// <param name="width">The width to set</param>
40 /// <param name="height">The height to set</param>
41 public Size(int width, int height)
48 /// A human-readable representation of the <see cref="T:Tizen.UI.Size" />.
50 /// <returns>The string is formatted as "{{Width={0} Height={1}}}".</returns>
51 public override string ToString()
53 return string.Format("{{Width={0} Height={1}}}", Width, Height);
57 /// Returns a hash value for the <see cref="T:Tizen.UI.Size" />.
59 /// <returns>A value intended for efficient insertion and lookup in hashtable-based data structures.</returns>
60 public override int GetHashCode()
64 return Width.GetHashCode() ^ (Height.GetHashCode() * 397);
69 /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
71 /// <param name="obj">Another <see cref="T:Tizen.UI.Size" />.</param>
72 /// <returns>True if the Width and Height values are equal to those in <paramref name="obj" />. Returns false if <paramref name="obj" /> is not a <see cref="T:Tizen.UI.Size" />.</returns>
73 public override bool Equals(object obj)
78 return Equals((Size)obj);
82 /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
84 /// <param name="other">Another <see cref="T:Tizen.UI.Size" />.</param>
85 /// <returns>True if the Width and Height values are equal to those in <paramref name="other" />.</returns>
86 public bool Equals(Size other)
88 return Width.Equals(other.Width) && Height.Equals(other.Height);
92 /// Whether the two <see cref="T:Tizen.UI.Size" />s are equal.
94 /// <param name="s1">A <see cref="T:Tizen.UI.Size" /> on the left hand side.</param>
95 /// <param name="s2">A <see cref="T:Tizen.UI.Size" /> on the right hand side.</param>
96 /// <returns>True if the two <see cref="T:Tizen.UI.Size" />s have equal values.</returns>
97 public static bool operator ==(Size s1, Size s2)
103 /// Whether two <see cref="T:Tizen.UI.Size" />s are not equal.
105 /// <param name="s1">A <see cref="T:Tizen.UI.Size" /> on the left hand side.</param>
106 /// <param name="s2">A <see cref="T:Tizen.UI.Size" /> on the right hand side.</param>
107 /// <returns>True if the two <see cref="T:Tizen.UI.Size" />s do not have equal values.</returns>
108 public static bool operator !=(Size s1, Size s2)
110 return !s1.Equals(s2);