You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
919 B
24 lines
919 B
using System; |
|
using DotSDL.Events; |
|
using DotSDL.Graphics; |
|
using DotSDL.Input.Keyboard; |
|
|
|
namespace Sample.Power { |
|
public class Window : SdlWindow { |
|
public Window(int width, int height) : base("Power Test", |
|
new Point { X = WindowPosUndefined, Y = WindowPosUndefined }, |
|
width, height, width, height) { |
|
KeyPressed += Window_KeyPressed; |
|
} |
|
|
|
private void Window_KeyPressed(object sender, KeyboardEvent e) { |
|
if(e.Keycode == Keycode.Escape) |
|
Stop(); |
|
|
|
if(e.Keycode == Keycode.P) { |
|
var power = DotSDL.Power.PowerState.CurrentPowerState; |
|
Console.WriteLine($"Status: {power.BatteryStatus}; percent: {power.BatteryPercent}; minutes: {power.TimeRemaining.TotalMinutes}"); |
|
} |
|
} |
|
} |
|
}
|
|
|