Introduce ElmSharp project
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Size.cs
1 // Copyright 2016 by Samsung Electronics, Inc.,
2 //
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
8
9 using System;
10
11 namespace ElmSharp
12 {
13     /// <summary>
14     /// Struct defining height and width as a pair of generic type.
15     /// </summary>
16     public struct Size : IEquatable<Size>
17     {
18         /// <summary>
19         /// Magnitude along the horizontal axis, in platform-defined units.
20         /// </summary>
21         public int Width;
22
23         /// <summary>
24         /// Magnitude along the vertical axis, in platform-specific units.
25         /// </summary>
26         public int Height;
27
28         /// <summary>
29         /// Initializes a new instance of the Size structure from the specified dimensions.
30         /// </summary>
31         /// <param name="width">The width to set</param>
32         /// <param name="height">The height to set</param>
33         public Size(int width, int height)
34         {
35             Width = width;
36             Height = height;
37         }
38
39         /// <summary>
40         /// A human-readable representation of the <see cref="T:Tizen.UI.Size" />.
41         /// </summary>
42         /// <returns>The string is formatted as "{{Width={0} Height={1}}}".</returns>
43         public override string ToString()
44         {
45             return string.Format("{{Width={0} Height={1}}}", Width, Height);
46         }
47
48         /// <summary>
49         /// Returns a hash value for the <see cref="T:Tizen.UI.Size" />.
50         /// </summary>
51         /// <returns>A value intended for efficient insertion and lookup in hashtable-based data structures.</returns>
52         public override int GetHashCode()
53         {
54             unchecked
55             {
56                 return Width.GetHashCode() ^ (Height.GetHashCode() * 397);
57             }
58         }
59
60         /// <summary>
61         /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
62         /// </summary>
63         /// <param name="obj">Another <see cref="T:Tizen.UI.Size" />.</param>
64         /// <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>
65         public override bool Equals(object obj)
66         {
67             if (!(obj is Size))
68                 return false;
69
70             return Equals((Size)obj);
71         }
72
73         /// <summary>
74         /// Returns true if the Width and Height values of this are exactly equal to those in the argument.
75         /// </summary>
76         /// <param name="other">Another <see cref="T:Tizen.UI.Size" />.</param>
77         /// <returns>True if the Width and Height values are equal to those in <paramref name="other" />.</returns>
78         public bool Equals(Size other)
79         {
80             return Width.Equals(other.Width) && Height.Equals(other.Height);
81         }
82
83         /// <summary>
84         /// Whether the two <see cref="T:Tizen.UI.Size" />s are equal.
85         /// </summary>
86         /// <param name="s1">A <see cref="T:Tizen.UI.Size" /> on the left hand side.</param>
87         /// <param name="s2">A <see cref="T:Tizen.UI.Size" /> on the right hand side.</param>
88         /// <returns>True if the two <see cref="T:Tizen.UI.Size" />s have equal values.</returns>
89         public static bool operator ==(Size s1, Size s2)
90         {
91             return s1.Equals(s2);
92         }
93
94         /// <summary>
95         /// Whether two <see cref="T:Tizen.UI.Size" />s are not equal.
96         /// </summary>
97         /// <param name="s1">A <see cref="T:Tizen.UI.Size" /> on the left hand side.</param>
98         /// <param name="s2">A <see cref="T:Tizen.UI.Size" /> on the right hand side.</param>
99         /// <returns>True if the two <see cref="T:Tizen.UI.Size" />s do not have equal values.</returns>
100         public static bool operator !=(Size s1, Size s2)
101         {
102             return !s1.Equals(s2);
103         }
104     }
105 }