Release 4.0.0-preview1-00201
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / Common / 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 Tizen.Multimedia
20 {
21     /// <summary>
22     /// Represents a point in the 2D space.
23     /// </summary>
24     public struct Point
25     {
26
27         /// <summary>
28         /// Initializes a new instance of the Point with the specified coordinates.
29         /// </summary>
30         /// <param name="x">X-axis coordinate of the point in the 2D space.</param>
31         /// <param name="y">Y-axis coordinate of the point in the 2D space.</param>
32         public Point(int x, int y)
33         {
34             X = x;
35             Y = y;
36         }
37
38         /// <summary>
39         /// Gets or sets the X-axis coordinate of the point in the 2D space.
40         /// </summary>
41         public int X
42         {
43             get;
44             set;
45         }
46
47         /// <summary>
48         /// Gets or sets the Y-axis coordinate of the point in the 2D space.
49         /// </summary>
50         public int Y
51         {
52             get;
53             set;
54         }
55
56         /// <summary>
57         /// Returns a string that represents the current object.
58         /// </summary>
59         /// <returns>A string that represents the current object.</returns>
60         public override string ToString() => $"X={X.ToString()}, Y={Y.ToString()}";
61
62         /// <summary>
63         /// Gets the hash code for this instance of <see cref="Point"/>.
64         /// </summary>
65         /// <returns>The hash code for this instance of <see cref="Point"/>.</returns>
66         public override int GetHashCode()
67         {
68             return new { X, Y }.GetHashCode();
69         }
70
71         /// <summary>
72         /// Compares an object to an instance of <see cref="Point"/> for equality.
73         /// </summary>
74         /// <param name="obj">A <see cref="Object"/> to compare.</param>
75         /// <returns>true if the points are equal; otherwise, false.</returns>
76         public override bool Equals(object obj)
77         {
78             return obj is Point && this == (Point)obj;
79         }
80
81         /// <summary>
82         /// Compares two instances of <see cref="Point"/> for equality.
83         /// </summary>
84         /// <param name="point1">A <see cref="Point"/> to compare.</param>
85         /// <param name="point2">A <see cref="Point"/> to compare.</param>
86         /// <returns>true if the two instances of <see cref="Point"/> are equal; otherwise false.</returns>
87         public static bool operator ==(Point point1, Point point2)
88         {
89             return point1.X == point2.X && point1.Y == point2.Y;
90         }
91
92         /// <summary>
93         /// Compares two instances of <see cref="Point"/> for inequality.
94         /// </summary>
95         /// <param name="point1">A <see cref="Point"/> to compare.</param>
96         /// <param name="point2">A <see cref="Point"/> to compare.</param>
97         /// <returns>true if the two instances of <see cref="Point"/> are not equal; otherwise false.</returns>
98         public static bool operator !=(Point point1, Point point2)
99         {
100             return !(point1 == point2);
101         }
102     }
103 }