@@ -17,6 +17,8 @@ namespace Shadowsocks.Controller | |||||
public string LatestVersionURL; | public string LatestVersionURL; | ||||
public event EventHandler NewVersionFound; | public event EventHandler NewVersionFound; | ||||
public const string Version = "2.1.3"; | |||||
public void CheckUpdate() | public void CheckUpdate() | ||||
{ | { | ||||
// TODO test failures | // TODO test failures | ||||
@@ -100,7 +102,7 @@ namespace Shadowsocks.Controller | |||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); | |||||
string currentVersion = Version; | |||||
return CompareVersion(version, currentVersion) > 0; | return CompareVersion(version, currentVersion) > 0; | ||||
} | } | ||||
@@ -33,4 +33,6 @@ Please add at least one server=请添加至少一个服务器 | |||||
Shadowsocks {0} Update Found=Shadowsocks {0} 更新 | Shadowsocks {0} Update Found=Shadowsocks {0} 更新 | ||||
Click here to download=点击这里下载 | Click here to download=点击这里下载 | ||||
Shadowsocks is here=Shadowsocks 在这里 | Shadowsocks is here=Shadowsocks 在这里 | ||||
You can turn on/off Shadowsocks in the context menu=可以在右键菜单中开关 Shadowsocks | |||||
You can turn on/off Shadowsocks in the context menu=可以在右键菜单中开关 Shadowsocks | |||||
Enabled=已启用代理 | |||||
Disabled=已禁用代理 |
@@ -16,5 +16,13 @@ namespace Shadowsocks.Model | |||||
public string password; | public string password; | ||||
public string method; | public string method; | ||||
public string remarks; | public string remarks; | ||||
public string FriendlyName | |||||
{ | |||||
get | |||||
{ | |||||
return string.IsNullOrEmpty(remarks) ? server + ":" + server_port : server + ":" + server_port + " (" + remarks + ")"; | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,4 +1,5 @@ | |||||
using System.Reflection; | |||||
using Shadowsocks.Controller; | |||||
using System.Reflection; | |||||
using System.Runtime.CompilerServices; | using System.Runtime.CompilerServices; | ||||
using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
@@ -32,5 +33,5 @@ using System.Runtime.InteropServices; | |||||
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, | ||||
// 方法是按如下所示使用“*”: | // 方法是按如下所示使用“*”: | ||||
// [assembly: AssemblyVersion("1.0.*")] | // [assembly: AssemblyVersion("1.0.*")] | ||||
[assembly: AssemblyVersion("2.1.2")] | |||||
[assembly: AssemblyVersion(UpdateChecker.Version)] | |||||
// [assembly: AssemblyFileVersion("2.0.0")] | // [assembly: AssemblyFileVersion("2.0.0")] |
@@ -295,9 +295,9 @@ | |||||
// ServerGroupBox | // ServerGroupBox | ||||
// | // | ||||
this.ServerGroupBox.Controls.Add(this.tableLayoutPanel1); | this.ServerGroupBox.Controls.Add(this.tableLayoutPanel1); | ||||
this.ServerGroupBox.Location = new System.Drawing.Point(223, 12); | |||||
this.ServerGroupBox.Location = new System.Drawing.Point(220, 12); | |||||
this.ServerGroupBox.Name = "ServerGroupBox"; | this.ServerGroupBox.Name = "ServerGroupBox"; | ||||
this.ServerGroupBox.Size = new System.Drawing.Size(255, 205); | |||||
this.ServerGroupBox.Size = new System.Drawing.Size(258, 199); | |||||
this.ServerGroupBox.TabIndex = 6; | this.ServerGroupBox.TabIndex = 6; | ||||
this.ServerGroupBox.TabStop = false; | this.ServerGroupBox.TabStop = false; | ||||
this.ServerGroupBox.Text = "Server"; | this.ServerGroupBox.Text = "Server"; | ||||
@@ -307,7 +307,7 @@ | |||||
this.ServersListBox.FormattingEnabled = true; | this.ServersListBox.FormattingEnabled = true; | ||||
this.ServersListBox.Location = new System.Drawing.Point(12, 12); | this.ServersListBox.Location = new System.Drawing.Point(12, 12); | ||||
this.ServersListBox.Name = "ServersListBox"; | this.ServersListBox.Name = "ServersListBox"; | ||||
this.ServersListBox.Size = new System.Drawing.Size(192, 173); | |||||
this.ServersListBox.Size = new System.Drawing.Size(192, 199); | |||||
this.ServersListBox.TabIndex = 5; | this.ServersListBox.TabIndex = 5; | ||||
this.ServersListBox.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged); | this.ServersListBox.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged); | ||||
// | // | ||||
@@ -119,7 +119,7 @@ namespace Shadowsocks.View | |||||
ServersListBox.Items.Clear(); | ServersListBox.Items.Clear(); | ||||
foreach (Server server in _modifiedConfiguration.configs) | foreach (Server server in _modifiedConfiguration.configs) | ||||
{ | { | ||||
ServersListBox.Items.Add(string.IsNullOrEmpty(server.server) ? I18N.GetString("New server") : string.IsNullOrEmpty(server.remarks)? server.server + ":" + server.server_port : server.server + ":" + server.server_port + " (" + server.remarks + ")"); | |||||
ServersListBox.Items.Add(string.IsNullOrEmpty(server.server) ? I18N.GetString("New server") : server.FriendlyName); | |||||
} | } | ||||
} | } | ||||
@@ -56,9 +56,8 @@ namespace Shadowsocks.View | |||||
controller.Errored += controller_Errored; | controller.Errored += controller_Errored; | ||||
_notifyIcon = new NotifyIcon(); | _notifyIcon = new NotifyIcon(); | ||||
LoadTrayIcon(); | |||||
UpdateTrayIcon(); | |||||
_notifyIcon.Visible = true; | _notifyIcon.Visible = true; | ||||
_notifyIcon.Text = I18N.GetString("Shadowsocks"); | |||||
_notifyIcon.ContextMenu = contextMenu1; | _notifyIcon.ContextMenu = contextMenu1; | ||||
_notifyIcon.DoubleClick += notifyIcon1_DoubleClick; | _notifyIcon.DoubleClick += notifyIcon1_DoubleClick; | ||||
@@ -81,7 +80,7 @@ namespace Shadowsocks.View | |||||
MessageBox.Show(e.GetException().ToString(), String.Format(I18N.GetString("Shadowsocks Error: {0}"), e.GetException().Message)); | MessageBox.Show(e.GetException().ToString(), String.Format(I18N.GetString("Shadowsocks Error: {0}"), e.GetException().Message)); | ||||
} | } | ||||
private void LoadTrayIcon() | |||||
private void UpdateTrayIcon() | |||||
{ | { | ||||
int dpi; | int dpi; | ||||
Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); | Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); | ||||
@@ -102,7 +101,8 @@ namespace Shadowsocks.View | |||||
{ | { | ||||
icon = Resources.ss24; | icon = Resources.ss24; | ||||
} | } | ||||
if (!controller.GetConfiguration().enabled) | |||||
bool enabled = controller.GetConfiguration().enabled; | |||||
if (!enabled) | |||||
{ | { | ||||
Bitmap iconCopy = new Bitmap(icon); | Bitmap iconCopy = new Bitmap(icon); | ||||
for (int x = 0; x < iconCopy.Width; x++) | for (int x = 0; x < iconCopy.Width; x++) | ||||
@@ -116,6 +116,8 @@ namespace Shadowsocks.View | |||||
icon = iconCopy; | icon = iconCopy; | ||||
} | } | ||||
_notifyIcon.Icon = Icon.FromHandle(icon.GetHicon()); | _notifyIcon.Icon = Icon.FromHandle(icon.GetHicon()); | ||||
_notifyIcon.Text = I18N.GetString("Shadowsocks") + " " + UpdateChecker.Version + "\n" + (enabled ? I18N.GetString("Enabled") : I18N.GetString("Disabled")) + "\n" + controller.GetCurrentServer().FriendlyName; | |||||
} | } | ||||
private void LoadMenu() | private void LoadMenu() | ||||
@@ -263,12 +265,12 @@ namespace Shadowsocks.View | |||||
private void controller_ConfigChanged(object sender, EventArgs e) | private void controller_ConfigChanged(object sender, EventArgs e) | ||||
{ | { | ||||
LoadCurrentConfiguration(); | LoadCurrentConfiguration(); | ||||
UpdateTrayIcon(); | |||||
} | } | ||||
private void controller_EnableStatusChanged(object sender, EventArgs e) | private void controller_EnableStatusChanged(object sender, EventArgs e) | ||||
{ | { | ||||
enableItem.Checked = controller.GetConfiguration().enabled; | enableItem.Checked = controller.GetConfiguration().enabled; | ||||
LoadTrayIcon(); | |||||
} | } | ||||
void controller_ShareOverLANStatusChanged(object sender, EventArgs e) | void controller_ShareOverLANStatusChanged(object sender, EventArgs e) | ||||
@@ -326,7 +328,7 @@ namespace Shadowsocks.View | |||||
for (int i = 0; i < configuration.configs.Count; i++) | for (int i = 0; i < configuration.configs.Count; i++) | ||||
{ | { | ||||
Server server = configuration.configs[i]; | Server server = configuration.configs[i]; | ||||
MenuItem item = new MenuItem(string.IsNullOrEmpty(server.remarks) ? server.server + ":" + server.server_port : server.server + ":" + server.server_port + " (" + server.remarks + ")"); | |||||
MenuItem item = new MenuItem(server.FriendlyName); | |||||
item.Tag = i; | item.Tag = i; | ||||
item.Click += AServerItem_Click; | item.Click += AServerItem_Click; | ||||
items.Add(item); | items.Add(item); | ||||