diff --git a/src/DirectX12GameEngine.Core/Extensions/PointExtensions.cs b/src/DirectX12GameEngine.Core/Extensions/PointExtensions.cs new file mode 100644 index 00000000..4c636790 --- /dev/null +++ b/src/DirectX12GameEngine.Core/Extensions/PointExtensions.cs @@ -0,0 +1,27 @@ +using System.Diagnostics.Contracts; +using System.Numerics; + +namespace Windows.Foundation +{ + /// + /// A with some extension methods for the type + /// + public static class PointExtensions + { + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + [Pure] + public static Vector2 ToVector2(this in Point value) => new Vector2((float)value.X, (float)value.Y); + + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + [Pure] + public static Point ToPoint(this in Vector2 value) => new Point(value.X, value.Y); + } +} diff --git a/src/DirectX12GameEngine.Core/Extensions/RectExtensions.cs b/src/DirectX12GameEngine.Core/Extensions/RectExtensions.cs new file mode 100644 index 00000000..55956a6e --- /dev/null +++ b/src/DirectX12GameEngine.Core/Extensions/RectExtensions.cs @@ -0,0 +1,29 @@ +using System.Diagnostics.Contracts; +using System.Numerics; + +namespace Windows.Foundation +{ + /// + /// A with some extension methods for the type + /// + public static class RectExtensions + { + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + /// The input is read in the following order: , , , + [Pure] + public static Vector4 ToVector2(this in Rect value) => new Vector4((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom); + + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + /// The input is assigned in the following order: , , , + [Pure] + public static Rect ToPoint(this in Vector4 value) => new Rect(value.X, value.Y, value.Z, value.W); + } +} \ No newline at end of file diff --git a/src/DirectX12GameEngine.Core/Extensions/SizeExtensions.cs b/src/DirectX12GameEngine.Core/Extensions/SizeExtensions.cs new file mode 100644 index 00000000..f8871206 --- /dev/null +++ b/src/DirectX12GameEngine.Core/Extensions/SizeExtensions.cs @@ -0,0 +1,29 @@ +using System.Diagnostics.Contracts; +using System.Numerics; + +namespace Windows.Foundation +{ + /// + /// A with some extension methods for the type + /// + public static class SizeExtensions + { + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + /// The input is read in the following order: , + [Pure] + public static Vector2 ToVector2(this in Size value) => new Vector2((float)value.Width, (float)value.Height); + + /// + /// Converts a value to a + /// + /// The input to convert + /// A value representing the input + /// The input is assigned in the following order: , + [Pure] + public static Size ToPoint(this in Vector2 value) => new Size(value.X, value.Y); + } +} \ No newline at end of file diff --git a/src/DirectX12GameEngine.Core/WindowsRuntimeExtensions.cs b/src/DirectX12GameEngine.Core/WindowsRuntimeExtensions.cs deleted file mode 100644 index 787b5040..00000000 --- a/src/DirectX12GameEngine.Core/WindowsRuntimeExtensions.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Numerics; -using Windows.Foundation; - -namespace DirectX12GameEngine.Core -{ - public static class PointExtensions - { - public static Vector2 ToVector2(this in Point value) - { - return new Vector2((float)value.X, (float)value.Y); - } - - public static Point ToPoint(this in Vector2 value) - { - return new Point(value.X, value.Y); - } - - public static System.Drawing.PointF ToPointF(this in Point value) - { - return new System.Drawing.PointF((float)value.X, (float)value.Y); - } - - public static Point ToPoint(this in System.Drawing.PointF value) - { - return new Point(value.X, value.Y); - } - } - - public static class RectangleExtensions - { - public static System.Drawing.RectangleF ToRectangleF(this in Rect value) - { - return new System.Drawing.RectangleF((float)value.X, (float)value.Y, (float)value.Width, (float)value.Height); - } - - public static Rect ToRect(this in System.Drawing.RectangleF value) - { - return new Rect(value.X, value.Y, value.Width, value.Height); - } - } - - public static class SizeExtensions - { - public static Vector2 ToVector2(this in Size value) - { - return new Vector2((float)value.Width, (float)value.Height); - } - - public static Size ToSize(this in Vector2 value) - { - return new Size(value.X, value.Y); - } - - public static System.Drawing.SizeF ToSizeF(this in Size value) - { - return new System.Drawing.SizeF((float)value.Width, (float)value.Height); - } - - public static Size ToSize(this in System.Drawing.SizeF value) - { - return new Size(value.Width, value.Height); - } - } -}