[ElmSharp] Fix XML documentation warnings.
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Rect.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 using System.Runtime.InteropServices;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// The Rect is a struct that represent rectangluar space.
24     /// </summary>
25     [StructLayout(LayoutKind.Sequential)]
26     public struct Rect : IEquatable<Rect>
27     {
28         /// <summary>
29         /// Creates and initializes a new instance of the Rect class.
30         /// </summary>
31         /// <param name="x">X axis value.</param>
32         /// <param name="y">Y axis value.</param>
33         /// <param name="w">Width value.</param>
34         /// <param name="h">Height value.</param>
35         public Rect(int x, int y, int w, int h)
36         {
37             X = x;
38             Y = y;
39             Width = w;
40             Height = h;
41         }
42
43         /// <summary>
44         /// Gets or sets the position of this Rectangle on the X axis.
45         /// </summary>
46         public int X { get; set; }
47
48         /// <summary>
49         /// Gets or sets the position of this Rectangle on the Y axis.
50         /// </summary>
51         public int Y { get; set; }
52
53         /// <summary>
54         /// Gets or sets the width of this Rectangle.
55         /// </summary>
56         public int Width { get; set; }
57
58         /// <summary>
59         /// Gets or sets the height of this Rectangle.
60         /// </summary>
61         public int Height { get; set; }
62
63         /// <summary>
64         /// Gets the position of this Rectangle on the X axis.
65         /// </summary>
66         public int Left { get { return X; } }
67
68         /// <summary>
69         /// Gets the extent along the X axis.
70         /// </summary>
71         public int Right { get { return X + Width; } }
72
73         /// <summary>
74         /// Gets the position of this Rectangle on the Y axis.
75         /// </summary>
76         public int Top { get { return Y; } }
77
78         /// <summary>
79         /// Gets the extent along the Y axis.
80         /// </summary>
81         public int Bottom { get { return Y + Height; } }
82
83         /// <summary>
84         /// Gets the Point defined by Rectangle.Left and Rectangle.Top.
85         /// </summary>
86         public Point Location { get { return new Point { X = X, Y = Y }; } }
87
88         /// <summary>
89         /// Gets the extent of the Rectangle along its X and Y axis.
90         /// </summary>
91         public Size Size { get { return new Size { Width = Width, Height = Height }; } }
92
93         /// <summary>
94         /// A human-readable representation of the <see cref="T:Tizen.UI.Rect" />.
95         /// </summary>
96         /// <returns>The string is formatted as "{{X={0} Y={1} Width={2} Height={3}}}".</returns>
97         public override string ToString()
98         {
99             return string.Format("{{X={0} Y={1} Width={2} Height={3}}}", X, Y, Width, Height);
100         }
101
102         /// <summary>
103         /// Gets the hash code.
104         /// </summary>
105         /// <returns>The hash code.</returns>
106         public override int GetHashCode()
107         {
108             unchecked
109             {
110                 int hashCode = X.GetHashCode();
111                 hashCode = (hashCode * 397) ^ Y.GetHashCode();
112                 hashCode = (hashCode * 397) ^ Width.GetHashCode();
113                 hashCode = (hashCode * 397) ^ Height.GetHashCode();
114                 return hashCode;
115             }
116         }
117
118         public override bool Equals(object obj)
119         {
120             if (!(obj is Rect))
121                 return false;
122
123             return Equals((Rect)obj);
124         }
125
126         public bool Equals(Rect other)
127         {
128             return X.Equals(other.X) && Y.Equals(other.Y) && Width.Equals(other.Width) && Height.Equals(other.Height);
129         }
130
131         /// <summary>
132         /// Whether the two <see cref="T:Tizen.UI.Rectangle" />s are equal.
133         /// </summary>
134         /// <param name="r1">A <see cref="T:Tizen.UI.Rectangle" /> on the left hand side.</param>
135         /// <param name="r2">A <see cref="T:Tizen.UI.Rectangle" /> on the right hand side.</param>
136         /// <returns>True if the two <see cref="T:Tizen.UI.Rectangle" />s have equal values.</returns>
137         public static bool operator ==(Rect r1, Rect r2)
138         {
139             return r1.Equals(r2);
140         }
141
142         /// <summary>
143         /// Whether two <see cref="T:Tizen.UI.Rectangle" />s are not equal.
144         /// </summary>
145         /// <param name="r1">A <see cref="T:Tizen.UI.Rectangle" /> on the left hand side.</param>
146         /// <param name="r2">A <see cref="T:Tizen.UI.Rectangle" /> on the right hand side.</param>
147         /// <returns>True if the two <see cref="T:Tizen.UI.Rectangle" />s do not have equal values.</returns>
148         public static bool operator !=(Rect r1, Rect r2)
149         {
150             return !r1.Equals(r2);
151         }
152     }
153 }