PowerStatus 1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PowerStatus --version 1.0.0
NuGet\Install-Package PowerStatus -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PowerStatus" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowerStatus --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PowerStatus, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PowerStatus as a Cake Addin #addin nuget:?package=PowerStatus&version=1.0.0 // Install PowerStatus as a Cake Tool #tool nuget:?package=PowerStatus&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PowerStatus
C# wrapper for win32's System Power Status
Examples
Get a snapshot of the current power status
var statusProvider = new PowerStatusProvider();
var status = statusProvider.GetStatus();
Console.WriteLine($"{status}");
PowerStatus { AcLineStatus = Offline, BatteryFlags = 0, BatteryLifeProportion = 0.47, BatterySaver = False, BatteryTime = 01:53:54, FullTime = }
Receive notifications when something changes
var statusProvider = new PowerStatusProvider();
using (statusProvider.Subscribe(
e => Console.WriteLine(e.ToString()),
PowerStatusNotification.BatteryProportionChanged(proportion =>
Console.WriteLine($"The battery proportion is {proportion}")),
PowerStatusNotification.BatterySaverIsOn(isOn =>
Console.WriteLine($"Battery saver {(isOn ? "is" : "is not")} on")),
PowerStatusNotification.CurrentMonitorDisplayState(state =>
Console.WriteLine($"The current monitor's display state is {state}")),
PowerStatusNotification.LidIsOpen(isOpen =>
Console.WriteLine($"The lid {(isOpen ? "is" : "is not")} open")),
PowerStatusNotification.PowerSchemePersonalityChanged(personality =>
Console.WriteLine($"The power scheme is {personality}")),
PowerStatusNotification.PowerSource(powerSource =>
Console.WriteLine($"The power source is {powerSource}")),
PowerStatusNotification.PrimaryMonitorIsOn(isOn =>
Console.WriteLine($"The primary monitor {(isOn ? "is" : "is not")} on")),
PowerStatusNotification.SessionDisplayState(state =>
Console.WriteLine($"The session display is {state}")),
PowerStatusNotification.SystemAwayModeChanged(awayMode =>
Console.WriteLine($"The system is {awayMode} away mode")),
PowerStatusNotification.SystemIsBusy(() =>
Console.WriteLine("The system is busy")),
PowerStatusNotification.UserIsActive(isActive =>
Console.WriteLine($"The user {(isActive ? "is" : "is not")} active"))
))
{
Console.WriteLine("Press any key to stop listening to events...");
Console.ReadKey(true);
}
Press any key to stop listening to events...
The battery proportion is 0.47
Battery saver is not on
The lid is open
The power scheme is Automatic
The power source is DC
The primary monitor is on
The current monitor's display state is On
The system is busy
The user is active
The session display is On
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.