Merge "[WiFi] GetConnectedAP() Returns null if there is no connected AP"
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / Common / Rectangle.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 the location of the object bounded by a rectangle defined by
23     /// coordinates of top left corner, width and height.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public struct Rectangle
27     {
28         private Point _location;
29         private Size _size;
30
31         /// <summary>
32         /// Initializes a new instance of the <see cref="Rectangle"/> with the specified values.
33         /// </summary>
34         /// <param name="x">The x-coordinate of the upper-left corner of the rectangle.</param>
35         /// <param name="y">The y-coordinate of the upper-left corner of the rectangle.</param>
36         /// <param name="width">The Width of the rectangle.</param>
37         /// <param name="height">The Height of the rectangle.</param>
38         /// <since_tizen> 3 </since_tizen>
39         public Rectangle(int x, int y, int width, int height) : this(new Point(x, y),
40             new Size(width, height))
41         {
42         }
43
44         /// <summary>
45         /// Initializes a new instance of the <see cref="Rectangle"/> with the specified values.
46         /// </summary>
47         /// <param name="location">A <see cref="Location"/> that represents the upper-left corner of the rectangular region.</param>
48         /// <param name="size">A <see cref="Size"/> that represents the width and height of the rectangular region.</param>
49         /// <since_tizen> 3 </since_tizen>
50         public Rectangle(Point location, Size size)
51         {
52             _location = location;
53             _size = size;
54         }
55
56         /// <summary>
57         /// Gets or sets the coordinates of the upper-left corner of the rectangle.
58         /// </summary>
59         /// <since_tizen> 3 </since_tizen>
60         public Point Location
61         {
62             get { return _location; }
63             set { _location = value; }
64         }
65
66         /// <summary>
67         /// Gets or sets the x-coordinate of the upper-left corner of the rectangle.
68         /// </summary>
69         /// <since_tizen> 3 </since_tizen>
70         public int X
71         {
72             get { return _location.X; }
73             set { _location.X = value; }
74         }
75
76         /// <summary>
77         /// Gets or sets the y-coordinate of the upper-left corner of the rectangle.
78         /// </summary>
79         /// <since_tizen> 3 </since_tizen>
80         public int Y
81         {
82             get { return _location.Y; }
83             set { _location.Y = value; }
84         }
85
86         /// <summary>
87         /// Gets or sets the width of the rectangle.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public int Width
91         {
92             get { return _size.Width; }
93             set { _size.Width = value; }
94         }
95
96         /// <summary>
97         /// Gets or sets the height of the rectangle.
98         /// </summary>
99         /// <since_tizen> 3 </since_tizen>
100         public int Height
101         {
102             get { return _size.Height; }
103             set { _size.Height = value; }
104         }
105
106         /// <summary>
107         /// Gets the x-coordinate of the left edge of the rectangle.
108         /// </summary>
109         /// <since_tizen> 3 </since_tizen>
110         public int Left => X;
111
112         /// <summary>
113         /// Gets the y-coordinate of the top edge of the rectangle.
114         /// </summary>
115         /// <since_tizen> 3 </since_tizen>
116         public int Top => Y;
117
118         /// <summary>
119         /// Gets the x-coordinate of the right edge of the rectangle.
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         public int Right => X + Width;
123
124         /// <summary>
125         /// Gets the y-coordinate of the bottom edge of the rectangle.
126         /// </summary>
127         /// <since_tizen> 3 </since_tizen>
128         public int Bottom => Y + Height;
129
130         /// <summary>
131         /// Gets or sets the size of the rectangle.
132         /// </summary>
133         /// <since_tizen> 3 </since_tizen>
134         public Size Size
135         {
136             get { return _size; }
137             set { _size = value; }
138         }
139
140         /// <summary>
141         /// Returns a string that represents the current object.
142         /// </summary>
143         /// <returns>A string that represents the current object.</returns>
144         /// <since_tizen> 3 </since_tizen>
145         public override string ToString() => $"{_location.ToString()}, {_size.ToString()}";
146
147         /// <summary>
148         /// Gets the hash code for this instance of <see cref="Rectangle"/>.
149         /// </summary>
150         /// <returns>The hash code for this instance of <see cref="Rectangle"/>.</returns>
151         /// <since_tizen> 3 </since_tizen>
152         public override int GetHashCode()
153         {
154             return new { Location, Size }.GetHashCode();
155         }
156
157         /// <summary>
158         /// Compares an object to an instance of <see cref="Rectangle"/> for equality.
159         /// </summary>
160         /// <param name="obj">A <see cref="Object"/> to compare.</param>
161         /// <returns>true if the rectangles are equal; otherwise, false.</returns>
162         /// <since_tizen> 3 </since_tizen>
163         public override bool Equals(object obj)
164         {
165             return obj is Rectangle && this == (Rectangle)obj;
166         }
167
168         /// <summary>
169         /// Compares two instances of <see cref="Rectangle"/> for equality.
170         /// </summary>
171         /// <param name="rect1">A <see cref="Rectangle"/> to compare.</param>
172         /// <param name="rect2">A <see cref="Rectangle"/> to compare.</param>
173         /// <returns>true if the two instances of <see cref="Rectangle"/> are equal; otherwise false.</returns>
174         /// <since_tizen> 3 </since_tizen>
175         public static bool operator ==(Rectangle rect1, Rectangle rect2)
176         {
177             return rect1.Location == rect2.Location && rect1.Size == rect2.Size;
178         }
179
180         /// <summary>
181         /// Compares two instances of <see cref="Rectangle"/> for inequality.
182         /// </summary>
183         /// <param name="rect1">A <see cref="Rectangle"/> to compare.</param>
184         /// <param name="rect2">A <see cref="Rectangle"/> to compare.</param>
185         /// <returns>true if the two instances of <see cref="Rectangle"/> are not equal; otherwise false.</returns>
186         /// <since_tizen> 3 </since_tizen>
187         public static bool operator !=(Rectangle rect1, Rectangle rect2)
188         {
189             return !(rect1 == rect2);
190         }
191     }
192 }