From eaaacd398dc8f5edf186a3a545be8a5f180ac6a4 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 20 Dec 2014 17:26:40 +0800 Subject: [PATCH] minor fixes --- shadowsocks-csharp/Controller/UpdateChecker.cs | 4 +++- shadowsocks-csharp/Data/cn.txt | 4 +++- shadowsocks-csharp/Model/Server.cs | 8 ++++++++ shadowsocks-csharp/Properties/AssemblyInfo.cs | 5 +++-- shadowsocks-csharp/View/ConfigForm.Designer.cs | 6 +++--- shadowsocks-csharp/View/ConfigForm.cs | 2 +- shadowsocks-csharp/View/MenuViewController.cs | 14 ++++++++------ 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/shadowsocks-csharp/Controller/UpdateChecker.cs b/shadowsocks-csharp/Controller/UpdateChecker.cs index 046ae941..43a1af07 100755 --- a/shadowsocks-csharp/Controller/UpdateChecker.cs +++ b/shadowsocks-csharp/Controller/UpdateChecker.cs @@ -17,6 +17,8 @@ namespace Shadowsocks.Controller public string LatestVersionURL; public event EventHandler NewVersionFound; + public const string Version = "2.1.3"; + public void CheckUpdate() { // TODO test failures @@ -100,7 +102,7 @@ namespace Shadowsocks.Controller { return false; } - string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + string currentVersion = Version; return CompareVersion(version, currentVersion) > 0; } diff --git a/shadowsocks-csharp/Data/cn.txt b/shadowsocks-csharp/Data/cn.txt index 17736537..0e2cc5e5 100644 --- a/shadowsocks-csharp/Data/cn.txt +++ b/shadowsocks-csharp/Data/cn.txt @@ -33,4 +33,6 @@ Please add at least one server=请添加至少一个服务器 Shadowsocks {0} Update Found=Shadowsocks {0} 更新 Click here to download=点击这里下载 Shadowsocks is here=Shadowsocks 在这里 -You can turn on/off Shadowsocks in the context menu=可以在右键菜单中开关 Shadowsocks \ No newline at end of file +You can turn on/off Shadowsocks in the context menu=可以在右键菜单中开关 Shadowsocks +Enabled=已启用代理 +Disabled=已禁用代理 diff --git a/shadowsocks-csharp/Model/Server.cs b/shadowsocks-csharp/Model/Server.cs index 99e74f88..ddc3602d 100755 --- a/shadowsocks-csharp/Model/Server.cs +++ b/shadowsocks-csharp/Model/Server.cs @@ -16,5 +16,13 @@ namespace Shadowsocks.Model public string password; public string method; public string remarks; + + public string FriendlyName + { + get + { + return string.IsNullOrEmpty(remarks) ? server + ":" + server_port : server + ":" + server_port + " (" + remarks + ")"; + } + } } } diff --git a/shadowsocks-csharp/Properties/AssemblyInfo.cs b/shadowsocks-csharp/Properties/AssemblyInfo.cs index 28eb113d..edc36101 100755 --- a/shadowsocks-csharp/Properties/AssemblyInfo.cs +++ b/shadowsocks-csharp/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using Shadowsocks.Controller; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -32,5 +33,5 @@ using System.Runtime.InteropServices; // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2")] +[assembly: AssemblyVersion(UpdateChecker.Version)] // [assembly: AssemblyFileVersion("2.0.0")] diff --git a/shadowsocks-csharp/View/ConfigForm.Designer.cs b/shadowsocks-csharp/View/ConfigForm.Designer.cs index e95ca022..86d95143 100755 --- a/shadowsocks-csharp/View/ConfigForm.Designer.cs +++ b/shadowsocks-csharp/View/ConfigForm.Designer.cs @@ -295,9 +295,9 @@ // ServerGroupBox // 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.Size = new System.Drawing.Size(255, 205); + this.ServerGroupBox.Size = new System.Drawing.Size(258, 199); this.ServerGroupBox.TabIndex = 6; this.ServerGroupBox.TabStop = false; this.ServerGroupBox.Text = "Server"; @@ -307,7 +307,7 @@ this.ServersListBox.FormattingEnabled = true; this.ServersListBox.Location = new System.Drawing.Point(12, 12); 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.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged); // diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index 2ab4e03a..77281160 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -119,7 +119,7 @@ namespace Shadowsocks.View ServersListBox.Items.Clear(); 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); } } diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 50bd991c..7ffe071c 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -56,9 +56,8 @@ namespace Shadowsocks.View controller.Errored += controller_Errored; _notifyIcon = new NotifyIcon(); - LoadTrayIcon(); + UpdateTrayIcon(); _notifyIcon.Visible = true; - _notifyIcon.Text = I18N.GetString("Shadowsocks"); _notifyIcon.ContextMenu = contextMenu1; _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)); } - private void LoadTrayIcon() + private void UpdateTrayIcon() { int dpi; Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); @@ -102,7 +101,8 @@ namespace Shadowsocks.View { icon = Resources.ss24; } - if (!controller.GetConfiguration().enabled) + bool enabled = controller.GetConfiguration().enabled; + if (!enabled) { Bitmap iconCopy = new Bitmap(icon); for (int x = 0; x < iconCopy.Width; x++) @@ -116,6 +116,8 @@ namespace Shadowsocks.View icon = iconCopy; } _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() @@ -263,12 +265,12 @@ namespace Shadowsocks.View private void controller_ConfigChanged(object sender, EventArgs e) { LoadCurrentConfiguration(); + UpdateTrayIcon(); } private void controller_EnableStatusChanged(object sender, EventArgs e) { enableItem.Checked = controller.GetConfiguration().enabled; - LoadTrayIcon(); } void controller_ShareOverLANStatusChanged(object sender, EventArgs e) @@ -326,7 +328,7 @@ namespace Shadowsocks.View for (int i = 0; i < configuration.configs.Count; 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.Click += AServerItem_Click; items.Add(item);