using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Interfaces;
namespace NvAPIWrapper.Native.Display.Structures
{
///
/// DisplayHandle is a one-to-one map to the GDI handle of an attached display in the Windows Display Properties
/// Settings page.
///
[StructLayout(LayoutKind.Sequential)]
public struct DisplayHandle : IHandle, IEquatable
{
internal readonly IntPtr _MemoryAddress;
///
public IntPtr MemoryAddress
{
get => _MemoryAddress;
}
///
public bool IsNull
{
get => _MemoryAddress == IntPtr.Zero;
}
///
public bool Equals(DisplayHandle other)
{
return _MemoryAddress.Equals(other._MemoryAddress);
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is DisplayHandle handle && Equals(handle);
}
///
public override int GetHashCode()
{
return _MemoryAddress.GetHashCode();
}
///
/// 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 ==(DisplayHandle left, DisplayHandle 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 !=(DisplayHandle left, DisplayHandle right)
{
return !left.Equals(right);
}
///
public override string ToString()
{
return $"DisplayHandle #{MemoryAddress.ToInt64()}";
}
///
/// Gets default DisplayHandle with a null pointer
///
public static DisplayHandle DefaultHandle
{
get => default(DisplayHandle);
}
}
}