mirror of https://github.com/dahall/Vanara.git
Fixed and extended implicit operators for RECT and PRECT
parent
bebc771ac6
commit
6f80b4217d
|
@ -117,7 +117,7 @@ namespace Vanara.PInvoke
|
|||
|
||||
/// <summary>Gets or sets the size of this <see cref="RECT"/> structure.</summary>
|
||||
/// <value>A Size that represents the width and height of this <see cref="RECT"/> structure.</value>
|
||||
public Size Size
|
||||
public SIZE Size
|
||||
{
|
||||
get => new(Width, Height);
|
||||
set
|
||||
|
@ -295,7 +295,7 @@ namespace Vanara.PInvoke
|
|||
|
||||
/// <summary>Gets or sets the size of this <see cref="PRECT"/> structure.</summary>
|
||||
/// <value>A Size that represents the width and height of this <see cref="PRECT"/> structure.</value>
|
||||
public Size Size
|
||||
public SIZE Size
|
||||
{
|
||||
get => rect.Size;
|
||||
set => rect.Size = value;
|
||||
|
@ -305,25 +305,25 @@ namespace Vanara.PInvoke
|
|||
/// <value><c>true</c> if this instance is empty; otherwise, <c>false</c>.</value>
|
||||
public bool IsEmpty => rect.IsEmpty;
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="PRECT"/> to <see cref="RECT"/>.</summary>
|
||||
/// <param name="r">The <see cref="PRECT"/> to convert.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public static implicit operator RECT?(PRECT r) => r?.rect;
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="PRECT"/> to <see cref="Rectangle"/>.</summary>
|
||||
/// <param name="r">The <see cref="PRECT"/> to convert.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public static implicit operator Rectangle(PRECT r) => r.rect;
|
||||
public static implicit operator Rectangle?(PRECT r) => r?.rect;
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="System.Nullable{Rectangle}"/> to <see cref="PRECT"/>.</summary>
|
||||
/// <param name="r">The <see cref="Rectangle"/> to convert.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public static implicit operator PRECT(Rectangle? r) => r.HasValue ? new PRECT(r.Value) : null;
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="Rectangle"/> to <see cref="PRECT"/>.</summary>
|
||||
/// <param name="r">The <see cref="Rectangle"/> to convert.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public static implicit operator PRECT(Rectangle r) => new(r);
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="RECT"/> to <see cref="PRECT"/>.</summary>
|
||||
/// <summary>Performs an implicit conversion from <see cref="System.Nullable{RECT}"/> to <see cref="PRECT"/>.</summary>
|
||||
/// <param name="r">The <see cref="RECT"/> to convert.</param>
|
||||
/// <returns>The result of the conversion.</returns>
|
||||
public static implicit operator PRECT(RECT r) => new(r);
|
||||
public static implicit operator PRECT(RECT? r) => r.HasValue ? new PRECT(r.Value) : null;
|
||||
|
||||
/// <summary>Implements the operator ==.</summary>
|
||||
/// <param name="r1">The first <see cref="PRECT"/> structure.</param>
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Vanara.PInvoke.Tests
|
|||
r.Width = 11;
|
||||
Assert.That(r.Width == 11 && r.right == 21);
|
||||
Assert.That(r.Location == new POINT(10, 5));
|
||||
Assert.That(r.Size == new Size(11, 7));
|
||||
Assert.That(r.Size == new SIZE(11, 7));
|
||||
r.Size = new Size(5, 5);
|
||||
Assert.That(r.Width, Is.EqualTo(5));
|
||||
Assert.That(r.Height, Is.EqualTo(5));
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Vanara.PInvoke.Tests
|
|||
r.Width = 11;
|
||||
Assert.That(r.Width == 11 && r.right == 21);
|
||||
Assert.That(r.Location == new POINT(10, 5));
|
||||
Assert.That(r.Size == new Size(11, 7));
|
||||
Assert.That(r.Size == new SIZE(11, 7));
|
||||
r.Size = new Size(5,5);
|
||||
Assert.That(r.Width, Is.EqualTo(5));
|
||||
Assert.That(r.Height, Is.EqualTo(5));
|
||||
|
|
Loading…
Reference in New Issue