using System; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Helpers; using NvAPIWrapper.Native.Interfaces; namespace NvAPIWrapper.Native.GPU.Structures { /// /// Holds information regarding a zone control status /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct IlluminationZoneControlV1 : IInitializable { private const int MaximumNumberOfDataBytes = 128; private const int MaximumNumberOfReservedBytes = 64; internal IlluminationZoneType _ZoneType; internal IlluminationZoneControlMode _ControlMode; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDataBytes)] internal byte[] _Data; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReservedBytes)] internal byte[] _Reserved; /// /// Creates a new instance of . /// /// The zone control mode. /// The zone control RGB data. public IlluminationZoneControlV1( IlluminationZoneControlMode controlMode, IlluminationZoneControlDataRGB rgbData) : this(controlMode, IlluminationZoneType.RGB, rgbData.ToByteArray()) { } /// /// Creates a new instance of . /// /// The zone control mode. /// The zone control fixed color data. public IlluminationZoneControlV1( IlluminationZoneControlMode controlMode, IlluminationZoneControlDataFixedColor fixedColorData) : this(controlMode, IlluminationZoneType.FixedColor, fixedColorData.ToByteArray()) { } private IlluminationZoneControlV1( IlluminationZoneControlMode controlMode, IlluminationZoneType zoneType, byte[] data) { if (!(data?.Length > 0) || data.Length > MaximumNumberOfDataBytes) { throw new ArgumentOutOfRangeException(nameof(data)); } this = typeof(IlluminationZoneControlV1).Instantiate(); _ControlMode = controlMode; _ZoneType = zoneType; Array.Copy(data, 0, _Data, 0, data.Length); } /// /// Gets the type of zone and the type of data needed to control this zone /// internal IlluminationZoneType ZoneType { get => _ZoneType; } /// /// Gets the zone control mode /// internal IlluminationZoneControlMode ControlMode { get => _ControlMode; } /// /// Gets the control data as a RGB data structure. /// /// An instance of containing RGB settings. public IlluminationZoneControlDataRGB AsRGBData() { return _Data.ToStructure(); } /// /// Gets the control data as a fixed color data structure. /// /// An instance of containing fixed color settings. public IlluminationZoneControlDataFixedColor AsFixedColorData() { return _Data.ToStructure(); } } }