예제 #1
0
        public override bool SetBrightness(int brightness)
        {
            if (brightness is < 0 or > 100)
            {
                throw new ArgumentOutOfRangeException(nameof(brightness), brightness, "The brightness must be within 0 to 100.");
            }

            if (_isRemovable)
            {
                brightness = ArraySearch.GetNearest(_brightnessLevels, (byte)brightness);

                if (MSMonitor.SetBrightness(DeviceInstanceId, brightness))
                {
                    this.Brightness = brightness;
                    return(true);
                }
            }
            else
            {
                if (PowerManagement.SetActiveSchemeBrightness(brightness))
                {
                    this.Brightness = brightness;
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        public override AccessResult SetBrightness(int brightness)
        {
            if (brightness is < 0 or > 100)
            {
                throw new ArgumentOutOfRangeException(nameof(brightness), brightness, "The brightness must be within 0 to 100.");
            }

            if (_isInternal)
            {
                if (PowerManagement.SetActiveSchemeBrightness(brightness))
                {
                    this.Brightness = brightness;
                    return(AccessResult.Succeeded);
                }
            }
            else
            {
                brightness = ArraySearch.GetNearest(_brightnessLevels, (byte)brightness);

                if (MSMonitor.SetBrightness(DeviceInstanceId, brightness))
                {
                    this.Brightness = brightness;
                    return(AccessResult.Succeeded);
                }
            }
            return(AccessResult.Failed);
        }