using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Attributes;
using NvAPIWrapper.Native.General.Structures;
using NvAPIWrapper.Native.Helpers;
using NvAPIWrapper.Native.Interfaces;
using NvAPIWrapper.Native.Interfaces.Mosaic;
namespace NvAPIWrapper.Native.Mosaic.Structures
{
///
/// Holds a display setting
///
[StructLayout(LayoutKind.Sequential, Pack = 8)]
[StructureVersion(1)]
public struct DisplaySettingsV1 : IDisplaySettings,
IInitializable,
IEquatable,
IEquatable
{
internal StructureVersion _Version;
internal readonly uint _Width;
internal readonly uint _Height;
internal readonly uint _BitsPerPixel;
internal readonly uint _Frequency;
///
/// Creates a new DisplaySettingsV1
///
/// Per-display width
/// Per-display height
/// Bits per pixel
/// Display frequency
// ReSharper disable once TooManyDependencies
public DisplaySettingsV1(int width, int height, int bitsPerPixel, int frequency)
{
this = typeof(DisplaySettingsV1).Instantiate();
_Width = (uint) width;
_Height = (uint) height;
_BitsPerPixel = (uint) bitsPerPixel;
_Frequency = (uint) frequency;
}
///
public bool Equals(DisplaySettingsV1 other)
{
return _Width == other._Width &&
_Height == other._Height &&
_BitsPerPixel == other._BitsPerPixel &&
_Frequency == other._Frequency;
}
///
public bool Equals(DisplaySettingsV2 other)
{
return _Width == other._Width &&
_Height == other._Height &&
_BitsPerPixel == other._BitsPerPixel &&
_Frequency == other._Frequency;
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is DisplaySettingsV1 v1 && Equals(v1);
}
///
public override int GetHashCode()
{
unchecked
{
var hashCode = (int) _Width;
hashCode = (hashCode * 397) ^ (int) _Height;
hashCode = (hashCode * 397) ^ (int) _BitsPerPixel;
hashCode = (hashCode * 397) ^ (int) _Frequency;
return hashCode;
}
}
///
/// 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 ==(DisplaySettingsV1 left, DisplaySettingsV1 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 !=(DisplaySettingsV1 left, DisplaySettingsV1 right)
{
return !left.Equals(right);
}
///
public int Width
{
get => (int) _Width;
}
///
public int Height
{
get => (int) _Height;
}
///
public int BitsPerPixel
{
get => (int) _BitsPerPixel;
}
///
public int Frequency
{
get => (int) _Frequency;
}
///
public uint FrequencyInMillihertz
{
get => _Frequency * 1000;
}
}
}