Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public override bool UpdateBrightness(int brightness = -1)
        {
            if (_isRemovable)
            {
                this.Brightness = (0 <= brightness)
                                        ? brightness
                                        : MSMonitor.GetBrightness(DeviceInstanceId);
            }
            else
            {
                this.Brightness = PowerManagement.GetActiveSchemeBrightness();

                this.BrightnessSystemAdjusted = !PowerManagement.IsAdaptiveBrightnessEnabled
                                        ? -1 // Default
                                        : (0 <= brightness)
                                                ? brightness
                                                : MSMonitor.GetBrightness(DeviceInstanceId);
            }
            return(0 <= this.Brightness);
        }
Ejemplo n.º 4
0
        public override AccessResult UpdateBrightness(int brightness = -1)
        {
            if (_isInternal)
            {
                this.Brightness = PowerManagement.GetActiveSchemeBrightness();

                this.BrightnessSystemAdjusted = !PowerManagement.IsAdaptiveBrightnessEnabled
                                        ? -1 // Default
                                        : (0 <= brightness)
                                                ? brightness
                                                : MSMonitor.GetBrightness(DeviceInstanceId);
            }
            else
            {
                this.Brightness = (0 <= brightness)
                                        ? brightness
                                        : MSMonitor.GetBrightness(DeviceInstanceId);
            }
            return((0 <= this.Brightness) ? AccessResult.Succeeded : AccessResult.Failed);
        }
Ejemplo n.º 5
0
        public override bool UpdateBrightness(int brightness = -1)
        {
            lock (_lock)
            {
                if (_isRemovable)
                {
                    this.Brightness = (0 <= brightness)
                                                ? brightness
                                                : MSMonitor.GetBrightness(DeviceInstanceId);
                }
                else
                {
                    this.Brightness = PowerManagement.GetActiveSchemeBrightness();

                    if (LightSensor.AmbientLightSensorExists)
                    {
                        this.BrightnessSystemAdjusted = (0 <= brightness)
                                                        ? brightness
                                                        : MSMonitor.GetBrightness(DeviceInstanceId);
                    }
                }
                return(0 <= this.Brightness);
            }
        }