|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using System.Diagnostics.Contracts; |
| 6 | +using System.Runtime.CompilerServices; |
| 7 | +using Point = Windows.Foundation.Point; |
| 8 | +using Rect = Windows.Foundation.Rect; |
| 9 | +using Size = Windows.Foundation.Size; |
| 10 | + |
| 11 | +namespace Microsoft.Toolkit.Uwp.Extensions |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Extensions for the <see cref="Point"/> type. |
| 15 | + /// </summary> |
| 16 | + public static class PointExtensions |
| 17 | + { |
| 18 | + /// <summary> |
| 19 | + /// Creates a new <see cref="Rect"/> of the specified size, starting at a given point. |
| 20 | + /// </summary> |
| 21 | + /// <param name="point">The input <see cref="Point"/> value to convert.</param> |
| 22 | + /// <param name="width">The width of the rectangle.</param> |
| 23 | + /// <param name="height">The height of the rectangle.</param> |
| 24 | + /// <returns>A <see cref="Rect"/> value of the specified size, starting at the given point.</returns> |
| 25 | + [Pure] |
| 26 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 27 | + public static Rect ToRect(this Point point, double width, double height) |
| 28 | + { |
| 29 | + return new Rect(point.X, point.Y, width, height); |
| 30 | + } |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// Creates a new <see cref="Rect"/> of the specified size, starting at the given coordinates. |
| 34 | + /// </summary> |
| 35 | + /// <param name="point">The input <see cref="Point"/> value to convert.</param> |
| 36 | + /// <param name="size">The size of the rectangle to create.</param> |
| 37 | + /// <returns>A <see cref="Rect"/> value of the specified size, starting at the given coordinates.</returns> |
| 38 | + [Pure] |
| 39 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 40 | + public static Rect ToRect(this Point point, Size size) |
| 41 | + { |
| 42 | + return new Rect(point, size); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments