using System;
using System.Runtime.InteropServices;
namespace NvAPIWrapper.Native.Display.Structures
{
///
/// Holds a [X,Y] pair as a position on a 2D plane
///
[StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct Position : IEquatable
{
internal readonly int _X;
internal readonly int _Y;
///
public override string ToString()
{
return $"[{X}, {Y}]";
}
///
public bool Equals(Position other)
{
return _X == other._X && _Y == other._Y;
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is Position position && Equals(position);
}
///
public override int GetHashCode()
{
unchecked
{
return (_X * 397) ^ _Y;
}
}
///
/// Checks for equality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are equal, otherwise false
public static bool operator ==(Position left, Position right)
{
return left.Equals(right);
}
///
/// Checks for inequality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are not equal, otherwise false
public static bool operator !=(Position left, Position right)
{
return !left.Equals(right);
}
///
/// Creates a new Position
///
/// X value
/// Y value
public Position(int x, int y)
{
_X = x;
_Y = y;
}
///
/// X value
///
public int X
{
get => _X;
}
///
/// Y value
///
public int Y
{
get => _Y;
}
}
}