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 /// The Size is a struct defining the height and width as a pair of generic type.
24 /// <since_tizen> preview </since_tizen>
25 public struct Size : IEquatable<Size>
28 /// Magnitude along the horizontal axis, in platform-defined units.
30 /// <since_tizen> preview </since_tizen>
34 /// Magnitude along the vertical axis, in platform-specific units.
36 /// <since_tizen> preview </since_tizen>
40 /// Initializes a new instance of the size structure from specified dimensions.
42 /// <param name="width">The width to set.</param>
43 /// <param name="height">The height to set.</param>
44 /// <since_tizen> preview </since_tizen>
45 public Size(int width, int height)
52 /// A human-readable representation of <see cref="T:Tizen.UI.Size"/>.
54 /// <returns>The string is formatted as "{{Width={0} Height={1}}}".</returns>
55 /// <since_tizen> preview </since_tizen>
56 public override string ToString()
58 return string.Format("{{Width={0} Height={1}}}", Width, Height);
62 /// Gets the hash code.
64 /// <returns>The hash code.</returns>
65 /// <since_tizen> preview </since_tizen>
66 public override int GetHashCode()
70 return Width.GetHashCode() ^ (Height.GetHashCode() * 397);
75 /// Indicates whether this instance and a specified object are equal.
77 /// <param name="obj">The object to compare with the current instance.</param>
79 /// true if the object and this instance are of the same type and represent the same value,
82 /// <since_tizen> preview </since_tizen>
83 public override bool Equals(object obj)
88 return Equals((Size)obj);
92 /// Indicates whether this instance and a <see cref="Size"/> object are equal.
94 /// <param name="other">The <see cref="Size"/> to compare with the current instance.</param>
96 /// true if the object and this instance are of the same type and represent the same value,
99 /// <since_tizen> preview </since_tizen>
100 public bool Equals(Size other)
102 return Width.Equals(other.Width) && Height.Equals(other.Height);
106 /// Whether both <see cref="T:Tizen.UI.Size"/>s are equal.
108 /// <param name="s1">A <see cref="T:Tizen.UI.Size"/> on the left hand side.</param>
109 /// <param name="s2">A <see cref="T:Tizen.UI.Size"/> on the right hand side.</param>
110 /// <returns>True if both <see cref="T:Tizen.UI.Size"/>s have equal values.</returns>
111 /// <since_tizen> preview </since_tizen>
112 public static bool operator ==(Size s1, Size s2)
114 return s1.Equals(s2);
118 /// Whether both <see cref="T:Tizen.UI.Size"/>s are not equal.
120 /// <param name="s1">A <see cref="T:Tizen.UI.Size"/> on the left hand side.</param>
121 /// <param name="s2">A <see cref="T:Tizen.UI.Size"/> on the right hand side.</param>
122 /// <returns>True if both <see cref="T:Tizen.UI.Size"/>s do not have equal values.</returns>
123 /// <since_tizen> preview </since_tizen>
124 public static bool operator !=(Size s1, Size s2)
126 return !s1.Equals(s2);