mirror of https://github.com/dahall/Vanara.git
Removed as many references to System.Drawing as possible
parent
73fdcb4146
commit
65f846483d
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Vanara.PInvoke
|
namespace Vanara.PInvoke
|
||||||
|
@ -17,12 +15,12 @@ namespace Vanara.PInvoke
|
||||||
public short y;
|
public short y;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="POINTS"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="POINTS"/> struct.</summary>
|
||||||
/// <param name="width">The x-coordinate.</param>
|
/// <param name="x">The x-coordinate.</param>
|
||||||
/// <param name="height">The y-coordinate.</param>
|
/// <param name="y">The y-coordinate.</param>
|
||||||
public POINTS(short width, short height)
|
public POINTS(short x, short y)
|
||||||
{
|
{
|
||||||
x = width;
|
this.x = x;
|
||||||
y = height;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is empty.</summary>
|
/// <summary>Gets a value indicating whether this instance is empty.</summary>
|
||||||
|
@ -33,13 +31,13 @@ namespace Vanara.PInvoke
|
||||||
/// <param name="pt1">The <see cref="POINTS"/> structure on the left side of the equality operator.</param>
|
/// <param name="pt1">The <see cref="POINTS"/> structure on the left side of the equality operator.</param>
|
||||||
/// <param name="pt2">The <see cref="POINTS"/> structure on the right side of the equality operator.</param>
|
/// <param name="pt2">The <see cref="POINTS"/> structure on the right side of the equality operator.</param>
|
||||||
/// <returns><c>true</c> if <paramref name="pt1"/> and <paramref name="pt2"/> have equal width and height; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if <paramref name="pt1"/> and <paramref name="pt2"/> have equal width and height; otherwise, <c>false</c>.</returns>
|
||||||
public static bool operator ==(POINTS pt1, POINTS pt2) => pt1.x == pt2.x && pt1.y == pt2.y;
|
public static bool operator ==(POINTS pt1, POINTS pt2) => pt1.Equals(pt2);
|
||||||
|
|
||||||
/// <summary>Tests whether two <see cref="POINTS"/> structures are different.</summary>
|
/// <summary>Tests whether two <see cref="POINTS"/> structures are different.</summary>
|
||||||
/// <param name="pt1">The <see cref="POINTS"/> structure on the left side of the inequality operator.</param>
|
/// <param name="pt1">The <see cref="POINTS"/> structure on the left side of the inequality operator.</param>
|
||||||
/// <param name="pt2">The <see cref="POINTS"/> structure on the right side of the inequality operator.</param>
|
/// <param name="pt2">The <see cref="POINTS"/> structure on the right side of the inequality operator.</param>
|
||||||
/// <returns><c>true</c> if <paramref name="pt1"/> and <paramref name="pt2"/> differ either in width or height; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if <paramref name="pt1"/> and <paramref name="pt2"/> differ either in width or height; otherwise, <c>false</c>.</returns>
|
||||||
public static bool operator !=(POINTS pt1, POINTS pt2) => !(pt1 == pt2);
|
public static bool operator !=(POINTS pt1, POINTS pt2) => !pt1.Equals(pt2);
|
||||||
|
|
||||||
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
|
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
|
||||||
/// <param name="other">An object to compare with this object.</param>
|
/// <param name="other">An object to compare with this object.</param>
|
||||||
|
@ -49,41 +47,33 @@ namespace Vanara.PInvoke
|
||||||
/// <summary>Determines whether the specified <see cref="object"/>, is equal to this instance.</summary>
|
/// <summary>Determines whether the specified <see cref="object"/>, is equal to this instance.</summary>
|
||||||
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
|
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
|
||||||
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj) => obj switch
|
||||||
{
|
{
|
||||||
switch (obj)
|
POINTS pt => Equals(pt),
|
||||||
{
|
POINT ptl => Equals(ptl),
|
||||||
case POINTS pt:
|
_ => false,
|
||||||
return Equals(pt);
|
};
|
||||||
|
|
||||||
case Point ptl:
|
|
||||||
return Equals(ptl);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Returns a hash code for this instance.</summary>
|
/// <summary>Returns a hash code for this instance.</summary>
|
||||||
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
|
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
|
||||||
public override int GetHashCode() => IsEmpty ? 0 : x.GetHashCode() ^ y.GetHashCode();
|
public override int GetHashCode() => IsEmpty ? 0 : x.GetHashCode() ^ y.GetHashCode();
|
||||||
|
|
||||||
/// <summary>Converts this structure to a <see cref="Point"/> structure.</summary>
|
/// <summary>Converts this structure to a <see cref="POINT"/> structure.</summary>
|
||||||
/// <returns>An equivalent <see cref="Point"/> structure.</returns>
|
/// <returns>An equivalent <see cref="POINT"/> structure.</returns>
|
||||||
public Point ToPoint() => this;
|
public POINT ToPoint() => this;
|
||||||
|
|
||||||
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
|
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
|
||||||
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
||||||
public override string ToString() => "{x=" + x.ToString(CultureInfo.CurrentCulture) + ", y=" + y.ToString(CultureInfo.CurrentCulture) + "}";
|
public override string ToString() => $"{{x={x}, y={y}}}";
|
||||||
|
|
||||||
/// <summary>Performs an implicit conversion from <see cref="POINTS"/> to <see cref="Point"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="POINTS"/> to <see cref="POINT"/>.</summary>
|
||||||
/// <param name="p">The <see cref="POINTS"/>.</param>
|
/// <param name="p">The <see cref="POINTS"/>.</param>
|
||||||
/// <returns>The <see cref="Point"/> result of the conversion.</returns>
|
/// <returns>The <see cref="POINT"/> result of the conversion.</returns>
|
||||||
public static implicit operator Point(POINTS p) => new Point(p.x, p.y);
|
public static implicit operator POINT(POINTS p) => new(p.x, p.y);
|
||||||
|
|
||||||
/// <summary>Performs an implicit conversion from <see cref="Point"/> to <see cref="POINTS"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="POINT"/> to <see cref="POINTS"/>.</summary>
|
||||||
/// <param name="p">The <see cref="Point"/>.</param>
|
/// <param name="p">The <see cref="POINT"/>.</param>
|
||||||
/// <returns>The <see cref="POINTS"/> result of the conversion.</returns>
|
/// <returns>The <see cref="POINTS"/> result of the conversion.</returns>
|
||||||
public static implicit operator POINTS(Point p) => new POINTS((short)p.X, (short)p.Y);
|
public static implicit operator POINTS(POINT p) => new((short)p.X, (short)p.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -93,7 +93,7 @@ namespace Vanara.PInvoke
|
||||||
|
|
||||||
/// <summary>Gets or sets the coordinates of the upper-left corner of this <see cref="RECT"/> structure.</summary>
|
/// <summary>Gets or sets the coordinates of the upper-left corner of this <see cref="RECT"/> structure.</summary>
|
||||||
/// <value>A Point that represents the upper-left corner of this <see cref="RECT"/> structure.</value>
|
/// <value>A Point that represents the upper-left corner of this <see cref="RECT"/> structure.</value>
|
||||||
public Point Location
|
public POINT Location
|
||||||
{
|
{
|
||||||
get => new(left, top);
|
get => new(left, top);
|
||||||
set
|
set
|
||||||
|
@ -275,7 +275,7 @@ namespace Vanara.PInvoke
|
||||||
|
|
||||||
/// <summary>Gets or sets the coordinates of the upper-left corner of this <see cref="PRECT"/> structure.</summary>
|
/// <summary>Gets or sets the coordinates of the upper-left corner of this <see cref="PRECT"/> structure.</summary>
|
||||||
/// <value>A Point that represents the upper-left corner of this <see cref="PRECT"/> structure.</value>
|
/// <value>A Point that represents the upper-left corner of this <see cref="PRECT"/> structure.</value>
|
||||||
public Point Location
|
public POINT Location
|
||||||
{
|
{
|
||||||
get => rect.Location;
|
get => rect.Location;
|
||||||
set => rect.Location = value;
|
set => rect.Location = value;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Vanara.PInvoke
|
namespace Vanara.PInvoke
|
||||||
|
@ -34,26 +32,26 @@ namespace Vanara.PInvoke
|
||||||
/// <param name="sz1">The <see cref="SIZE"/> structure on the left side of the equality operator.</param>
|
/// <param name="sz1">The <see cref="SIZE"/> structure on the left side of the equality operator.</param>
|
||||||
/// <param name="sz2">The <see cref="SIZE"/> structure on the right side of the equality operator.</param>
|
/// <param name="sz2">The <see cref="SIZE"/> structure on the right side of the equality operator.</param>
|
||||||
/// <returns><c>true</c> if <paramref name="sz1"/> and <paramref name="sz2"/> have equal width and height; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if <paramref name="sz1"/> and <paramref name="sz2"/> have equal width and height; otherwise, <c>false</c>.</returns>
|
||||||
public static bool operator ==(SIZE sz1, SIZE sz2) => sz1.cx == sz2.cx && sz1.cy == sz2.cy;
|
public static bool operator ==(SIZE sz1, SIZE sz2) => sz1.Equals(sz2);
|
||||||
|
|
||||||
/// <summary>Tests whether two <see cref="SIZE"/> structures are different.</summary>
|
/// <summary>Tests whether two <see cref="SIZE"/> structures are different.</summary>
|
||||||
/// <param name="sz1">The <see cref="SIZE"/> structure on the left side of the inequality operator.</param>
|
/// <param name="sz1">The <see cref="SIZE"/> structure on the left side of the inequality operator.</param>
|
||||||
/// <param name="sz2">The <see cref="SIZE"/> structure on the right side of the inequality operator.</param>
|
/// <param name="sz2">The <see cref="SIZE"/> structure on the right side of the inequality operator.</param>
|
||||||
/// <returns><c>true</c> if <paramref name="sz1"/> and <paramref name="sz2"/> differ either in width or height; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if <paramref name="sz1"/> and <paramref name="sz2"/> differ either in width or height; otherwise, <c>false</c>.</returns>
|
||||||
public static bool operator !=(SIZE sz1, SIZE sz2) => !(sz1 == sz2);
|
public static bool operator !=(SIZE sz1, SIZE sz2) => !sz1.Equals(sz2);
|
||||||
|
|
||||||
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
|
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
|
||||||
/// <param name="other">An object to compare with this object.</param>
|
/// <param name="other">An object to compare with this object.</param>
|
||||||
/// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
|
/// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
|
||||||
public bool Equals(SIZE other) => cx == other.cx || cy == other.cy;
|
public bool Equals(SIZE other) => cx == other.cx || cy == other.cy;
|
||||||
|
|
||||||
/// <summary>Determines whether the specified <see cref="System.Object"/>, is equal to this instance.</summary>
|
/// <summary>Determines whether the specified <see cref="object"/>, is equal to this instance.</summary>
|
||||||
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
|
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
|
||||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
|
||||||
public override bool Equals(object obj) => obj switch
|
public override bool Equals(object obj) => obj switch
|
||||||
{
|
{
|
||||||
SIZE sz => Equals(sz),
|
SIZE sz => Equals(sz),
|
||||||
Size msz => Equals((SIZE)msz),
|
System.Drawing.Size msz => Equals((SIZE)msz),
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,21 +61,21 @@ namespace Vanara.PInvoke
|
||||||
|
|
||||||
/// <summary>Converts this structure to a <see cref="System.Drawing.Size"/> structure.</summary>
|
/// <summary>Converts this structure to a <see cref="System.Drawing.Size"/> structure.</summary>
|
||||||
/// <returns>An equivalent <see cref="System.Drawing.Size"/> structure.</returns>
|
/// <returns>An equivalent <see cref="System.Drawing.Size"/> structure.</returns>
|
||||||
public Size ToSize() => this;
|
public System.Drawing.Size ToSize() => this;
|
||||||
|
|
||||||
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
|
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
|
||||||
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
||||||
public override string ToString() => "{cx=" + cx.ToString(CultureInfo.CurrentCulture) + ", cy=" + cy.ToString(CultureInfo.CurrentCulture) + "}";
|
public override string ToString() => $"{{cx={cx}, cy={cy}}}";
|
||||||
|
|
||||||
/// <summary>Performs an implicit conversion from <see cref="SIZE"/> to <see cref="Size"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="SIZE"/> to <see cref="System.Drawing.Size"/>.</summary>
|
||||||
/// <param name="s">The <see cref="SIZE"/>.</param>
|
/// <param name="s">The <see cref="SIZE"/>.</param>
|
||||||
/// <returns>The <see cref="Size"/> result of the conversion.</returns>
|
/// <returns>The <see cref="System.Drawing.Size"/> result of the conversion.</returns>
|
||||||
public static implicit operator Size(SIZE s) => new(s.cx, s.cy);
|
public static implicit operator System.Drawing.Size(SIZE s) => new(s.cx, s.cy);
|
||||||
|
|
||||||
/// <summary>Performs an implicit conversion from <see cref="Size"/> to <see cref="SIZE"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="System.Drawing.Size"/> to <see cref="SIZE"/>.</summary>
|
||||||
/// <param name="s">The <see cref="Size"/>.</param>
|
/// <param name="s">The <see cref="System.Drawing.Size"/>.</param>
|
||||||
/// <returns>The <see cref="SIZE"/> result of the conversion.</returns>
|
/// <returns>The <see cref="SIZE"/> result of the conversion.</returns>
|
||||||
public static implicit operator SIZE(Size s) => new(s.Width, s.Height);
|
public static implicit operator SIZE(System.Drawing.Size s) => new(s.Width, s.Height);
|
||||||
|
|
||||||
/// <summary>Represents a SIZE structures whose values are set to zero.</summary>
|
/// <summary>Represents a SIZE structures whose values are set to zero.</summary>
|
||||||
public static readonly SIZE Empty = new();
|
public static readonly SIZE Empty = new();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Vanara.PInvoke
|
namespace Vanara.PInvoke
|
||||||
|
@ -912,7 +911,7 @@ namespace Vanara.PInvoke
|
||||||
public DMRES dmPrintQuality;
|
public DMRES dmPrintQuality;
|
||||||
|
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public Point dmPosition;
|
public POINT dmPosition;
|
||||||
|
|
||||||
[FieldOffset(8)]
|
[FieldOffset(8)]
|
||||||
public DMDO dmDisplayOrientation;
|
public DMDO dmDisplayOrientation;
|
||||||
|
@ -1441,7 +1440,7 @@ namespace Vanara.PInvoke
|
||||||
/// For display devices only, a POINTL structure that indicates the positional coordinates of the display device in reference to
|
/// For display devices only, a POINTL structure that indicates the positional coordinates of the display device in reference to
|
||||||
/// the desktop area. The primary display device is always located at coordinates (0,0).
|
/// the desktop area. The primary display device is always located at coordinates (0,0).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Point dmPosition { get => Union.dmPosition; set => Union.dmPosition = value; }
|
public POINT dmPosition { get => Union.dmPosition; set => Union.dmPosition = value; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>
|
/// <para>
|
||||||
|
|
Loading…
Reference in New Issue