Make sure to update tray icon text

This commit is contained in:
Travis Nickles 2017-06-04 19:13:14 -07:00
parent 31f1382245
commit 5c5e983ec1

View File

@ -990,6 +990,7 @@ namespace DS4Windows
autoProfilesTimer.Stop(); autoProfilesTimer.Stop();
btnStartStop.Text = Properties.Resources.StartText; btnStartStop.Text = Properties.Resources.StartText;
blankControllerTab(); blankControllerTab();
generateNotifyText();
} }
startToolStripMenuItem.Text = btnStartStop.Text; startToolStripMenuItem.Text = btnStartStop.Text;
@ -1058,6 +1059,7 @@ namespace DS4Windows
string battery; string battery;
int level = args.getLevel(); int level = args.getLevel();
bool charging = args.isCharging(); bool charging = args.isCharging();
int Index = args.getIndex();
if (charging) if (charging)
{ {
if (level >= 100) if (level >= 100)
@ -1071,9 +1073,28 @@ namespace DS4Windows
} }
Batteries[args.getIndex()].Text = battery; Batteries[args.getIndex()].Text = battery;
// Update device battery level display for tray icon
generateNotifyText();
} }
} }
protected void generateNotifyText()
{
string tooltip = "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
for (int i = 0; i < ControlService.DS4_CONTROLLER_COUNT; i++)
{
string temp = Program.rootHub.getShortDS4ControllerInfo(i);
if (temp != Properties.Resources.NoneText)
tooltip += "\n" + (i + 1) + ": " + temp; // Carefully stay under the 63 character limit.
}
if (tooltip.Length > 63)
notifyIcon1.Text = tooltip.Substring(0, 63);
else
notifyIcon1.Text = tooltip;
}
protected void DeviceSerialChanged(object sender, SerialChangeArgs args) protected void DeviceSerialChanged(object sender, SerialChangeArgs args)
{ {
if (InvokeRequired) if (InvokeRequired)
@ -1192,6 +1213,9 @@ namespace DS4Windows
lbNoControllers.Visible = nocontrollers; lbNoControllers.Visible = nocontrollers;
tLPControllers.Visible = !nocontrollers; tLPControllers.Visible = !nocontrollers;
// Update device battery level display for tray icon
generateNotifyText();
} }
} }