2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace Tizen.Multimedia
22 /// Represents a size in 2D space.
27 /// Initializes a new instance of the <see cref="Size"/> with the specified values.
29 /// <param name="width">Width of the size.</param>
30 /// <param name="height">Height of the size.</param>
31 public Size(int width, int height)
38 /// Gets or sets the width.
47 /// Gets or sets the height.
56 /// Returns a string that represents the current object.
58 /// <returns>A string that represents the current object.</returns>
59 public override string ToString() => $"Width={ Width.ToString() }, Height={ Height.ToString() }";
62 /// Gets the hash code for this instance of <see cref="Size"/>.
64 /// <returns>The hash code for this instance of <see cref="Size"/>.</returns>
65 public override int GetHashCode()
67 return new { Width, Height }.GetHashCode();
71 /// Compares an object to an instance of <see cref="Size"/> for equality.
73 /// <param name="obj">A <see cref="Object"/> to compare.</param>
74 /// <returns>true if the two sizes are equal; otherwise, false.</returns>
75 public override bool Equals(object obj)
77 return obj is Size && this == (Size)obj;
81 /// Compares two instances of <see cref="Size"/> for equality.
83 /// <param name="size1">A <see cref="Size"/> to compare.</param>
84 /// <param name="size2">A <see cref="Size"/> to compare.</param>
85 /// <returns>true if the two instances of <see cref="Size"/> are equal; otherwise false.</returns>
86 public static bool operator ==(Size size1, Size size2)
88 return size1.Width == size2.Width && size1.Height == size2.Height;
92 /// Compares two instances of <see cref="Size"/> for inequality.
94 /// <param name="size1">A <see cref="Size"/> to compare.</param>
95 /// <param name="size2">A <see cref="Size"/> to compare.</param>
96 /// <returns>true if the two instances of <see cref="Size"/> are not equal; otherwise false.</returns>
97 public static bool operator !=(Size size1, Size size2)
99 return !(size1 == size2);