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