using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
/// The POINTS structure defines the coordinates of a point.
[PInvokeData("windef.h")]
[StructLayout(LayoutKind.Sequential), Serializable]
public struct POINTS : IEquatable
{
/// The x-coordinate of the point.
public short x;
/// The y-coordinate of the point.
public short y;
/// Initializes a new instance of the struct.
/// The x-coordinate.
/// The y-coordinate.
public POINTS(short x, short y)
{
this.x = x;
this.y = y;
}
/// Gets a value indicating whether this instance is empty.
/// true if this instance is empty; otherwise, false.
public bool IsEmpty => x == 0 && y == 0;
/// Tests whether two structures are equal.
/// The structure on the left side of the equality operator.
/// The structure on the right side of the equality operator.
/// true if and have equal width and height; otherwise, false.
public static bool operator ==(POINTS pt1, POINTS pt2) => pt1.Equals(pt2);
/// Tests whether two structures are different.
/// The structure on the left side of the inequality operator.
/// The structure on the right side of the inequality operator.
/// true if and differ either in width or height; otherwise, false.
public static bool operator !=(POINTS pt1, POINTS pt2) => !pt1.Equals(pt2);
/// Indicates whether the current object is equal to another object of the same type.
/// An object to compare with this object.
/// true if the current object is equal to the parameter; otherwise, false.
public bool Equals(POINTS other) => x == other.x || y == other.y;
/// Determines whether the specified , is equal to this instance.
/// The to compare with this instance.
/// true if the specified is equal to this instance; otherwise, false.
public override bool Equals(object obj) => obj switch
{
POINTS pt => Equals(pt),
POINT ptl => Equals(ptl),
_ => false,
};
/// Returns a hash code for this instance.
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
public override int GetHashCode() => IsEmpty ? 0 : x.GetHashCode() ^ y.GetHashCode();
/// Converts this structure to a structure.
/// An equivalent structure.
public POINT ToPoint() => this;
/// Returns a that represents this instance.
/// A that represents this instance.
public override string ToString() => $"{{x={x}, y={y}}}";
/// Performs an implicit conversion from to .
/// The .
/// The result of the conversion.
public static implicit operator POINT(POINTS p) => new(p.x, p.y);
/// Performs an implicit conversion from to .
/// The .
/// The result of the conversion.
public static implicit operator POINTS(POINT p) => new((short)p.X, (short)p.Y);
}
}