Workaround NotifyIcon's 63 chars limit(#965)

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-12-23 21:41:11 +08:00
parent f9ed9174cc
commit d21162318e
2 changed files with 16 additions and 2 deletions
@@ -180,13 +180,13 @@ namespace Shadowsocks.View
{
serverInfo = config.GetCurrentServer().FriendlyName();
}
// we want to show more details but notify icon title is limited to 63 characters
// show more info by hacking the P/Invoke declaration for NOTIFYICONDATA inside Windows Forms
string text = I18N.GetString("Shadowsocks") + " " + UpdateChecker.Version + "\n" +
(enabled ?
I18N.GetString("System Proxy On: ") + (global ? I18N.GetString("Global") : I18N.GetString("PAC")) :
String.Format(I18N.GetString("Running: Port {0}"), config.localPort)) // this feedback is very important because they need to know Shadowsocks is running
+ "\n" + serverInfo;
_notifyIcon.Text = text.Substring(0, Math.Min(63, text.Length));
ViewUtils.SetNotifyIconText(_notifyIcon, text);
}
private Bitmap getTrayIconByState(Bitmap originIcon, bool enabled, bool global)