jfversluis / Plugin.Maui.ScreenBrightness

Plugin.Maui.ScreenBrightness provides the ability to get or set the screen brightness inside a .NET MAUI application.
MIT License
45 stars 3 forks source link

Windows implementation #3

Closed VladislavAntonyuk closed 1 year ago

VladislavAntonyuk commented 1 year ago

https://github.com/jfversluis/Plugin.Maui.ScreenBrightness/blob/bbb09f291a4f4fff19249b9510a2ca4107fb7810/src/Plugin.Maui.ScreenBrightness/ScreenBrightness.windows.cs#L6

Possible Windows implementation: https://github.com/VladislavAntonyuk/ScreenBrightnessService/blob/main/ScreenBrightnessService/BrightnessService/BrightnessService.cs

However it requires these nuget packages:

<PackageReference Include="Microsoft.Win32.Registry" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="System.Management" Version="7.0.0" />

If we can use them, I can copy the changes to this library. @jfversluis what do you think?

jfversluis commented 1 year ago

Oh does that one work?! What I had should work but throws an exception... yeah if this works, let's do it! Thanks!

VladislavAntonyuk commented 1 year ago

yes, I created that small utility to change screen brightness depending on battery status. I will create PR soon!

VladislavAntonyuk commented 1 year ago

unfortunately, my code doesn't work with WinUI. I also get the exception. Unable to load winutill.dll.

jfversluis commented 1 year ago

That's too bad! Thank you for looking into it. Yeah I'll have to figure out if something is wrong or if this is simply not supported for WinUI at this time.

I think it's less relevant than for iOS and Android anyway but still good to have if we can :)

VladislavAntonyuk commented 1 year ago

Sorry @jfversluis , It works. I initially tried on mac on VM. Works on Windows laptop