-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlayform.cs
53 lines (46 loc) · 1.46 KB
/
overlayform.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Drawing;
using System.Management;
using System.Windows.Forms;
namespace Brightness_Stress_Test
{
public partial class overlayform : Form
{
public overlayform()
{
InitializeComponent();
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//empty implementation
this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
}
private void CheckBattery()
{
ManagementClass wmi = new ManagementClass("Win32_Battery");
var allBatteries = wmi.GetInstances();
foreach (var battery in allBatteries)
{
int batteryLevel = Convert.ToInt32(battery["EstimatedChargeRemaining"]);
var msg = $"Battery Level: {batteryLevel}%";
label1.Text = msg;
}
}
private void overlayform_Load(object sender, EventArgs e)
{
label1.Text = "Battery Level: NaN";
timer1.Tick += __timer_Tick;
timer1.Interval = 1000 * 10;
timer1.Enabled = true;
timer1.Start();
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(100, 100);
this.TopMost = true;
}
private void __timer_Tick(object sender, EventArgs e)
{
CheckBattery();
}
}
}