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(2)] public struct DisplaySettingsV2 : IDisplaySettings, IInitializable, IEquatable, IEquatable { internal StructureVersion _Version; internal readonly uint _Width; internal readonly uint _Height; internal readonly uint _BitsPerPixel; internal readonly uint _Frequency; internal readonly uint _FrequencyInMillihertz; /// /// Creates a new DisplaySettingsV2 /// /// Per-display width /// Per-display height /// Bits per pixel /// Display frequency /// Display frequency in x1k // ReSharper disable once TooManyDependencies public DisplaySettingsV2(int width, int height, int bitsPerPixel, int frequency, uint frequencyInMillihertz) { this = typeof(DisplaySettingsV2).Instantiate(); _Width = (uint) width; _Height = (uint) height; _BitsPerPixel = (uint) bitsPerPixel; _Frequency = (uint) frequency; _FrequencyInMillihertz = frequencyInMillihertz; } /// public bool Equals(DisplaySettingsV2 other) { return _Width == other._Width && _Height == other._Height && _BitsPerPixel == other._BitsPerPixel && _Frequency == other._Frequency && _FrequencyInMillihertz == other._FrequencyInMillihertz; } /// public bool Equals(DisplaySettingsV1 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 DisplaySettingsV2 v2 && Equals(v2); } /// public override int GetHashCode() { unchecked { var hashCode = (int) _Width; hashCode = (hashCode * 397) ^ (int) _Height; hashCode = (hashCode * 397) ^ (int) _BitsPerPixel; hashCode = (hashCode * 397) ^ (int) _Frequency; hashCode = (hashCode * 397) ^ (int) _FrequencyInMillihertz; 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 ==(DisplaySettingsV2 left, DisplaySettingsV2 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 !=(DisplaySettingsV2 left, DisplaySettingsV2 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 => _FrequencyInMillihertz; } } }