Fix License boiler-plate
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Size.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// Struct defining height and width as a pair of generic type.
23     /// </summary>
24     public struct Size : IEquatable<Size>
25     {
26         /// <summary>
27         /// Magnitude along the horizontal axis, in platform-defined units.
28         /// </summary>
29         public int Width;
30
31         /// <summary>
32         /// Magnitude along the vertical axis, in platform-specific units.
33         /// </summary>
34         public int Height;
35
36         /// <summary>
37         /// Initializes a new instance of the Size structure from the specified dimensions.
38         /// </summary>
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)
42         {
43             Width = width;
44             Height = height;
45         }
46
47         /// <summary>
48         /// A human-readable representation of the <see cref="T:Tizen.UI.Size" />.
49         /// </summary>
50         /// <returns>The string is formatted as "{{Width={0} Height={1}}}".</returns>
51         public override string ToString()
52         {
53             return string.Format("{{Width={0} Height={1}}}", Width, Height);
54         }
55
56         /// <summary>
57         /// Returns a hash value for the <see cref="T:Tizen.UI.Size" />.
58         /// </summary>
59         /// <returns>A value intended for efficient insertion and lookup in hashtable-based data structures.</returns>
60         public override int GetHashCode()
61         {
62             unchecked
63             {
64                 return Width.GetHashCode() ^ (Height.GetHashCode() * 397);
65             }
66         }
67
68         /// <summary>
69         /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
70         /// </summary>
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)
74         {
75             if (!(obj is Size))
76                 return false;
77
78             return Equals((Size)obj);
79         }
80
81         /// <summary>
82         /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
83         /// </summary>
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)
87         {
88             return Width.Equals(other.Width) && Height.Equals(other.Height);
89         }
90
91         /// <summary>
92         /// Whether the two <see cref="T:Tizen.UI.Size" />s are equal.
93         /// </summary>
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)
98         {
99             return s1.Equals(s2);
100         }
101
102         /// <summary>
103         /// Whether two <see cref="T:Tizen.UI.Size" />s are not equal.
104         /// </summary>
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)
109         {
110             return !s1.Equals(s2);
111         }
112     }
113 }