kas / percentage

See your battery percentage in the Windows 10 system tray
MIT License
365 stars 128 forks source link

Change color according to electricity #18

Closed cqjdcheng closed 3 years ago

cqjdcheng commented 4 years ago

var powerLineStatus = powerStatus.PowerLineStatus; batteryPercentage = (powerStatus.BatteryLifePercent * 100).ToString(); var bg_color = Color.Green; if (int.Parse(batteryPercentage) < 60) { bg_color = Color.Orange; } if (int.Parse(batteryPercentage) < 30) { bg_color = Color.Red; } if (powerLineStatus== PowerLineStatus.Online) { bg_color = Color.Green; } using (Bitmap bitmap = new Bitmap(DrawText(batteryPercentage, new Font(iconFont, iconFontSize), Color.White, bg_color)))

ajtazer commented 3 years ago

var powerLineStatus = powerStatus.PowerLineStatus; batteryPercentage = (powerStatus.BatteryLifePercent * 100).ToString(); var bg_color = Color.Green; if (int.Parse(batteryPercentage) < 60) { bg_color = Color.Orange; } if (int.Parse(batteryPercentage) < 30) { bg_color = Color.Red; } if (powerLineStatus== PowerLineStatus.Online) { bg_color = Color.Green; } using (Bitmap bitmap = new Bitmap(DrawText(batteryPercentage, new Font(iconFont, iconFontSize), Color.White, bg_color)))

Thanks for the Code but can u explain a little how do i edit percentage.exe to use this code?

kas commented 3 years ago

Thanks cqjdcheng this might be a bit out of scope for where I'd like to take the project, feel free to fork the project though

ajtazer you can update the GetTextBitmap method to change how the background color is initialized

This piece of code is setting the background color

graphics.Clear(Color.FromArgb(0, 0, 0, 0));