Merge "[Multimedia] Removed build warnings"
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Point.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     /// The Point is a struct that defines a 2-D point as a pair of generic type.
23     /// </summary>
24     public struct Point : IEquatable<Point>
25     {
26         /// <summary>
27         /// Location along the horizontal axis.
28         /// </summary>
29         public int X;
30
31         /// <summary>
32         /// Location along the vertical axis.
33         /// </summary>
34         public int Y;
35
36         /// <summary>
37         /// A human-readable representation of the <see cref="T:Tizen.UI.Point" />.
38         /// </summary>
39         /// <returns>The string is formatted as "{{X={0} Y={1}}}".</returns>
40         public override string ToString()
41         {
42             return string.Format("{{X={0} Y={1}}}", X, Y);
43         }
44
45         /// <summary>
46         /// Gets hash code.
47         /// </summary>
48         /// <returns>The hash code.</returns>
49         public override int GetHashCode()
50         {
51             unchecked
52             {
53                 return X.GetHashCode() ^ (Y.GetHashCode() * 397);
54             }
55         }
56
57         /// <summary>
58         /// Indicates whether this instance and a specified object are equal.
59         /// </summary>
60         /// <param name="obj">The object to compare with the current instance.</param>
61         /// <returns>
62         /// true if obj and this instance are the same type and represent the same value.
63         /// otherwise, false.
64         /// </returns>
65         public override bool Equals(object obj)
66         {
67             if (!(obj is Point))
68                 return false;
69
70             return Equals((Point)obj);
71         }
72
73         /// <summary>
74         /// Indicates whether this instance and a <see cref="Point"/> object are equal.
75         /// </summary>
76         /// <param name="other">The <see cref="Point"/> to compare with the current instance.</param>
77         /// <returns>
78         /// true if obj and this instance are the same type and represent the same value.
79         /// otherwise, false.
80         /// </returns>
81         public bool Equals(Point other)
82         {
83             return X.Equals(other.X) && Y.Equals(other.Y);
84         }
85
86         /// <summary>
87         /// Whether the two <see cref="T:Tizen.UI.Point" />s are equal.
88         /// </summary>
89         /// <param name="p1">A <see cref="T:Tizen.UI.Point" /> on the left hand side.</param>
90         /// <param name="p2">A <see cref="T:Tizen.UI.Point" /> on the right hand side.</param>
91         /// <returns>True if the two <see cref="T:Tizen.UI.Point" />s have equal values.</returns>
92         public static bool operator ==(Point p1, Point p2)
93         {
94             return p1.Equals(p2);
95         }
96
97         /// <summary>
98         /// Whether two <see cref="T:Tizen.UI.Point" />s are not equal.
99         /// </summary>
100         /// <param name="p1">A <see cref="T:Tizen.UI.Point" /> on the left hand side.</param>
101         /// <param name="p2">A <see cref="T:Tizen.UI.Point" /> on the right hand side.</param>
102         /// <returns>True if the two <see cref="T:Tizen.UI.Point" />s do not have equal values.</returns>
103         public static bool operator !=(Point p1, Point p2)
104         {
105             return !p1.Equals(p2);
106         }
107     }
108 }