public static void UpDateChargingIcon(double BatteryVoltage, bool OffLine)
{
int PercentageBattery = Convert.ToInt32(((BatteryVoltage - UPS_Manager.Properties.Settings.Default.BatteryChargeMin) / ((UPS_Manager.Properties.Settings.Default.BatteryChargeMax - 0.1) - UPS_Manager.Properties.Settings.Default.BatteryChargeMin)) * 100);
if (PercentageBattery <= 100 && !OffLine)
{
System.Drawing.Font drawFont = new System.Drawing.Font("Webdings", 70, FontStyle.Regular);
System.Drawing.Font drawFont1 = new System.Drawing.Font("Webdings", 85, FontStyle.Bold);
System.Drawing.SolidBrush DrawBrushEmpty = new System.Drawing.SolidBrush(System.Drawing.Color.Transparent);
System.Drawing.SolidBrush DrawBrushSymbol = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.SolidBrush DrawBrushSymbol1 = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.SolidBrush DrawBrushFull = new System.Drawing.SolidBrush(System.Drawing.Color.White);
Bitmap bitmap = new Bitmap(100, 100); // new Bitmap(100, 100);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
System.Drawing.Rectangle DrawRectRed = new Rectangle(0, 100 - PercentageBattery, 100, PercentageBattery);
System.Drawing.Region DrawRegionRed = new System.Drawing.Region(DrawRectRed);
graphics.FillRegion(DrawBrushFull, DrawRegionRed);
System.Drawing.Rectangle DrawRectGreen = new Rectangle(0, 0, 100, 100 - PercentageBattery);
System.Drawing.Region DrawRegionGreen = new System.Drawing.Region(DrawRectGreen);
graphics.FillRegion(DrawBrushEmpty, DrawRegionGreen);
graphics.DrawString("~", drawFont1, DrawBrushSymbol1, -22, -3);
graphics.DrawString("~", drawFont, DrawBrushSymbol, -8, 0);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
UPSNotifyIcon.Icon = createdIcon;
UPSNotifyIcon.Text = " " + PercentageBattery.ToString() + "%" + System.Environment.NewLine + BatteryVoltage.ToString() + "V";
}
else
{
UPSNotifyIcon.Icon = Properties.Resources.OnLine;
UPSNotifyIcon.Text = BatteryVoltage.ToString() + "V";
}
}