-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPointExtensions.cs
33 lines (33 loc) · 1.28 KB
/
PointExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace VolumeControl.TypeExtensions
{
/// <summary>
/// Extends the <see cref="System.Drawing.Point"/> & <see cref="System.Windows.Point"/> structs.
/// </summary>
public static class PointExtensions
{
/// <summary>
/// Deconstruct method for <see cref="System.Windows.Point"/>.
/// </summary>
public static void Deconstruct(this System.Windows.Point p, out double x, out double y)
{
x = p.X;
y = p.Y;
}
/// <summary>
/// Deconstruct method for <see cref="System.Drawing.Point"/>.
/// </summary>
public static void Deconstruct(this System.Drawing.Point p, out int x, out int y)
{
x = p.X;
y = p.Y;
}
/// <summary>
/// Get a <see cref="System.Drawing.Point"/> instance from a <see cref="System.Windows.Point"/> instance.
/// </summary>
public static System.Drawing.Point ToFormsPoint(this System.Windows.Point p) => new((int)p.X, (int)p.Y);
/// <summary>
/// Get a <see cref="System.Drawing.Point"/> instance from a <see cref="System.Windows.Point"/> instance.
/// </summary>
public static System.Windows.Point ToWpfPoint(this System.Drawing.Point p) => new(p.X, p.Y);
}
}