BrightnessOverride BrightnessOverride BrightnessOverride BrightnessOverride Class

Definition

Overrides the screen brightness level setting on a device. This API provides the ability to have per-application brightness control on devices that support controllable brightness. Use the BrightnessOverride object to override the user's brightness level setting temporarily or permanently.

public : sealed class BrightnessOverride : IBrightnessOverridepublic sealed class BrightnessOverride : IBrightnessOverridePublic NotInheritable Class BrightnessOverride Implements IBrightnessOverride// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Properties

BrightnessLevel BrightnessLevel BrightnessLevel BrightnessLevel

Gets the current screen brightness level.

public : double BrightnessLevel { get; }public double BrightnessLevel { get; }Public ReadOnly Property BrightnessLevel As double// You can use this property in JavaScript.
Value
double double double double

IsOverrideActive IsOverrideActive IsOverrideActive IsOverrideActive

BOOLEAN value that indicates whether the brightness override is active. If TRUE, the current brightness level matches the override brightness level. This property value will always be FALSE if StartOverride() isn’t called.

public : PlatForm::Boolean IsOverrideActive { get; }public bool IsOverrideActive { get; }Public ReadOnly Property IsOverrideActive As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

IsSupported IsSupported IsSupported IsSupported

Indicates whether the device currently has at least one brightness controllable display. If TRUE, the device has at least one brightness controllable display that supports brightness override.

public : PlatForm::Boolean IsSupported { get; }public bool IsSupported { get; }Public ReadOnly Property IsSupported As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

Methods

GetDefaultForSystem() GetDefaultForSystem() GetDefaultForSystem() GetDefaultForSystem()

Returns a brightness override object. This method does not require CoreWindow so it can be used by apps that are running in the background.

public : static BrightnessOverride GetDefaultForSystem()public static BrightnessOverride GetDefaultForSystem()Public Static Function GetDefaultForSystem() As BrightnessOverride// You can use this method in JavaScript.
Returns

Examples

This example overrides the device's brightness at full brightness, but is used by apps that run in the background and do not have a CoreWindow.

private void Set_Full_Brightness_AppsInBackground()
{

    //Create BrightnessOverride object

    BrightnessOverride bo = BrightnessOverride.GetDefaultForSystem();



    //Set override brightness to full brightness even when battery is low

    bo.SetBrightnessScenario(DisplayBrightnessScenario.FullBrightness, DisplayBrightnessOverrideOptions.None);



    //Request to start the overriding process

    bo.StartOverride();

}

Remarks

Requires the systemManagement capability to be declared in your app's package manifest. This capability allows apps to have basic system administration privileges. If it isn’t declared, this method throws an access is denied exception. For more info, see App capability declarations.

GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Returns a brightness override object. This method requires CoreWindow so it can only be used by apps that are currently running in a window. The returned BrightnessOverride object may not be the same between multiple GetForCurrentView() calls on the same thread.

public : static BrightnessOverride GetForCurrentView()public static BrightnessOverride GetForCurrentView()Public Static Function GetForCurrentView() As BrightnessOverride// You can use this method in JavaScript.
Returns

Examples

This example shows how apps that run in a window can override the device's brightness at full brightness. To stop the overriding process, use StopOverride().

private void Set_Full_Brightness()
{

    //Create BrightnessOverride object

    BrightnessOverride bo = BrightnessOverride.GetForCurrentView();



    //Set override brightness to full brightness even when battery is low

    bo.SetBrightnessScenario(DisplayBrightnessScenario.FullBrightness, DisplayBrightnessOverrideOptions.None);



    //Request to start the overriding process

    bo.StartOverride();

}

Remarks

This method throws an access is denied exception if there is no CoreWindow on the calling thread.

GetLevelForScenario(DisplayBrightnessScenario) GetLevelForScenario(DisplayBrightnessScenario) GetLevelForScenario(DisplayBrightnessScenario) GetLevelForScenario(DisplayBrightnessScenario)

Gets the brightness level associated with the specified scenario.

public : double GetLevelForScenario(DisplayBrightnessScenario scenario)public double GetLevelForScenario(DisplayBrightnessScenario scenario)Public Function GetLevelForScenario(scenario As DisplayBrightnessScenario) As double// You can use this method in JavaScript.
Parameters
scenario
DisplayBrightnessScenario DisplayBrightnessScenario DisplayBrightnessScenario DisplayBrightnessScenario

The enum value of the scenario that you want to retrieve the brightness level for, as defined in DisplayBrightnessScenario.

Returns
double double double double

A value to indicate the brightness level.

SaveForSystemAsync(BrightnessOverride) SaveForSystemAsync(BrightnessOverride) SaveForSystemAsync(BrightnessOverride) SaveForSystemAsync(BrightnessOverride)

Saves the specified brightness override settings by committing these values to user settings. Use this method to persist the override settings after overriding stops. If a NULL object is passed in, the system turns on auto-brightness.

public : static IAsyncOperation<PlatForm::Boolean> SaveForSystemAsync(BrightnessOverride value)public static IAsyncOperation<bool> SaveForSystemAsync(BrightnessOverride value)Public Static Function SaveForSystemAsync(value As BrightnessOverride) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Parameters
Returns

BOOLEAN value to indicate if the operation is successful or not.

Remarks

Requires the systemManagement capability to be declared in your app's package manifest. This capability allows apps to have basic system administration privileges. If it isn’t declared, this method throws an access is denied exception. For more info, see App capability declarations.

SetBrightnessLevel(Double, DisplayBrightnessOverrideOptions) SetBrightnessLevel(Double, DisplayBrightnessOverrideOptions) SetBrightnessLevel(Double, DisplayBrightnessOverrideOptions) SetBrightnessLevel(Double, DisplayBrightnessOverrideOptions)

Sets the brightness level and the override options. When your app is ready to change the current brightness with what you want to override it with, call StartOverride().

public : void SetBrightnessLevel(double brightnessLevel, DisplayBrightnessOverrideOptions options)public void SetBrightnessLevel(Double brightnessLevel, DisplayBrightnessOverrideOptions options)Public Function SetBrightnessLevel(brightnessLevel As Double, options As DisplayBrightnessOverrideOptions) As void// You can use this method in JavaScript.
Parameters
brightnessLevel
double Double Double Double

Brightness of the screen. Value should be in the range of 0.0 and 1.0, where 1.0 is for 100% brightness.

options
DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions

Options that modify the brightness level of the screen during the brightness override session.

Examples

/* Set display to 80% brightness and if the device is on low battery during overriding, allow the display to dim*/


bo.SetBrightnessLevel(0.80, DisplayBrightnessOverrideOptions.UseDimmedPolicyWhenBatteryIsLow);

SetBrightnessScenario(DisplayBrightnessScenario, DisplayBrightnessOverrideOptions) SetBrightnessScenario(DisplayBrightnessScenario, DisplayBrightnessOverrideOptions) SetBrightnessScenario(DisplayBrightnessScenario, DisplayBrightnessOverrideOptions) SetBrightnessScenario(DisplayBrightnessScenario, DisplayBrightnessOverrideOptions)

Sets the brightness level, by specifying a scenario that has a well-known brightness level, and the override options of the brightness override.

public : void SetBrightnessScenario(DisplayBrightnessScenario scenario, DisplayBrightnessOverrideOptions options)public void SetBrightnessScenario(DisplayBrightnessScenario scenario, DisplayBrightnessOverrideOptions options)Public Function SetBrightnessScenario(scenario As DisplayBrightnessScenario, options As DisplayBrightnessOverrideOptions) As void// You can use this method in JavaScript.
Parameters
options
DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions DisplayBrightnessOverrideOptions

Options that modify the brightness level of the screen during the brightness override session.

Examples

/* Set the display brightness to a level that is optimum for reading barcodes. If the device is on low battery during overriding, allow the display to dim*/

bo.SetBrightnessScenario(DisplayBrightnessScenario.BarcodeReadingBrightness, DisplayBrightnessOverrideOptions.UseDimmedPolicyWhenBatteryIsLow); 

StartOverride() StartOverride() StartOverride() StartOverride()

Request to start overriding the screen brightness level. The request to start overriding does not mean that the screen brightness level always changes to match the specified override brightness level. It's still up to the system to decide whether or not to honor this override request. Use IsOverrideActive and IsOverrideActiveChanged properties to determine if the system has honored the override request.

public : void StartOverride()public void StartOverride()Public Function StartOverride() As void// You can use this method in JavaScript.

StopOverride() StopOverride() StopOverride() StopOverride()

Stops overriding the brightness level.

public : void StopOverride()public void StopOverride()Public Function StopOverride() As void// You can use this method in JavaScript.

Events

BrightnessLevelChanged BrightnessLevelChanged BrightnessLevelChanged BrightnessLevelChanged

Occurs when the screen brightness level changes.

public : event TypedEventHandler BrightnessLevelChanged<BrightnessOverride,  object>public event TypedEventHandler BrightnessLevelChanged<BrightnessOverride,  object>Public Event BrightnessLevelChanged<BrightnessOverride,  object>// You can use this event in JavaScript.

Remarks

This event is raised whenever the screen brightness changes, regardless whether the app has requested to start the override session or not.

IsOverrideActiveChanged IsOverrideActiveChanged IsOverrideActiveChanged IsOverrideActiveChanged

Occurs when the screen brightness level either starts to match or stops to match the override brightness level. This event is raised when the IsOverrideActive property changes state.

public : event TypedEventHandler IsOverrideActiveChanged<BrightnessOverride,  object>public event TypedEventHandler IsOverrideActiveChanged<BrightnessOverride,  object>Public Event IsOverrideActiveChanged<BrightnessOverride,  object>// You can use this event in JavaScript.

Examples

This example shows how to use the IsOverrideActiveChanged event and the OnIsOverrideActiveChanged event handler to notify the user whether or not the brightness override object is in fact controlling the screen brightness.

bo.IsOverrideActiveChanged += OnIsOverrideActiveChanged;
...
private void OnIsOverrideActiveChanged(BrightnessOverride sender, object e)
{

    rootPage.NotifyUser("Brightness override is " + (sender.IsOverrideActive ? "active" : "not active"),   NotifyType.StatusMessage);

}

IsSupportedChanged IsSupportedChanged IsSupportedChanged IsSupportedChanged

Occurs when a brightness controllable display is detected or removed. This event is raised when the IsSupported property changes.

public : event TypedEventHandler IsSupportedChanged<BrightnessOverride,  object>public event TypedEventHandler IsSupportedChanged<BrightnessOverride,  object>Public Event IsSupportedChanged<BrightnessOverride,  object>// You can use this event in JavaScript.