From 95242208ec10d8e05fc6a6bfe74850b8eac12d84 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sun, 22 Mar 2015 20:23:40 +0800 Subject: [PATCH] UX fix 1. only enable menu items relevant to pac status 2. rename edit pac file into edit local pac file 3. users are allowed to enable online pac then input online pac url, not to input then enable --- shadowsocks-csharp/Data/cn.txt | 11 ++-- shadowsocks-csharp/View/MenuViewController.cs | 51 +++++++++++++++---- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/shadowsocks-csharp/Data/cn.txt b/shadowsocks-csharp/Data/cn.txt index 22a6478b..e092575c 100644 --- a/shadowsocks-csharp/Data/cn.txt +++ b/shadowsocks-csharp/Data/cn.txt @@ -12,7 +12,10 @@ Servers=服务器 Edit Servers...=编辑服务器... Start on Boot=开机启动 Allow Clients from LAN=允许来自局域网的连接 -Edit PAC File...=编辑 PAC 文件... +Local PAC=使用本地 PAC +Online PAC=使用在线 PAC +Edit Local PAC File...=编辑本地 PAC 文件... +Update Local PAC from GFWList=从 GFWList 更新本地 PAC Edit User Rule for GFWList...=编辑 GFWList 的用户规则... Show QRCode...=显示二维码... Scan QRCode from Screen...=扫描屏幕上的二维码... @@ -42,9 +45,8 @@ QRCode=二维码 # PAC Url Form -Local PAC=使用本地 PAC -Online PAC=使用在线 PAC -Update Online PAC URL=更新在线 PAC 网址 +Edit Online PAC URL=编辑在线 PAC 网址 +Edit Online PAC URL...=编辑在线 PAC 网址... Please input PAC Url=请输入 PAC 网址 # Messages @@ -62,7 +64,6 @@ Shadowsocks is here=Shadowsocks 在这里 You can turn on/off Shadowsocks in the context menu=可以在右键菜单中开关 Shadowsocks System Proxy Enabled=系统代理已启用 System Proxy Disabled=系统代理未启用 -Update PAC from GFWList=从 GFWList 更新 PAC Failed to update PAC file =更新 PAC 文件失败 PAC updated=更新 PAC 成功 No updates found. Please report to GFWList if you have problems with it.=未发现更新。如有问题请提交给 GFWList。 diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 53284975..ff5a018c 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -37,6 +37,10 @@ namespace Shadowsocks.View private MenuItem PACModeItem; private MenuItem localPACItem; private MenuItem onlinePACItem; + private MenuItem editLocalPACItem; + private MenuItem updateFromGFWListItem; + private MenuItem editGFWUserRuleItem; + private MenuItem editOnlinePACItem; private ConfigForm configForm; private string _urlToOpen; @@ -153,14 +157,14 @@ namespace Shadowsocks.View CreateMenuItem("Show QRCode...", new EventHandler(this.QRCodeItem_Click)), CreateMenuItem("Scan QRCode from Screen...", new EventHandler(this.ScanQRCodeItem_Click)) }), - CreateMenuGroup("PAC", new MenuItem[] { + CreateMenuGroup("PAC ", new MenuItem[] { this.localPACItem = CreateMenuItem("Local PAC", new EventHandler(this.LocalPACItem_Click)), this.onlinePACItem = CreateMenuItem("Online PAC", new EventHandler(this.OnlinePACItem_Click)), new MenuItem("-"), - CreateMenuItem("Edit PAC File...", new EventHandler(this.EditPACFileItem_Click)), - CreateMenuItem("Update PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)), - CreateMenuItem("Edit User Rule for GFWList...", new EventHandler(this.EditUserRuleFileForGFWListItem_Click)), - CreateMenuItem("Update Online PAC URL", new EventHandler(this.UpdateOnlinePACURLItem_Click)), + this.editLocalPACItem = CreateMenuItem("Edit Local PAC File...", new EventHandler(this.EditPACFileItem_Click)), + this.updateFromGFWListItem = CreateMenuItem("Update Local PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)), + this.editGFWUserRuleItem = CreateMenuItem("Edit User Rule for GFWList...", new EventHandler(this.EditUserRuleFileForGFWListItem_Click)), + this.editOnlinePACItem = CreateMenuItem("Edit Online PAC URL...", new EventHandler(this.UpdateOnlinePACURLItem_Click)), }), new MenuItem("-"), this.AutoStartupItem = CreateMenuItem("Start on Boot", new EventHandler(this.AutoStartupItem_Click)), @@ -247,9 +251,9 @@ namespace Shadowsocks.View PACModeItem.Checked = !config.global; ShareOverLANItem.Checked = config.shareOverLan; AutoStartupItem.Checked = AutoStartup.Check(); - onlinePACItem.Enabled = !string.IsNullOrEmpty(config.pacUrl); onlinePACItem.Checked = onlinePACItem.Enabled && config.useOnlinePac; localPACItem.Checked = !onlinePACItem.Checked; + UpdatePACItemsEnabledStatus(); } private void UpdateServersMenu() @@ -499,6 +503,7 @@ namespace Shadowsocks.View localPACItem.Checked = true; onlinePACItem.Checked = false; controller.UseOnlinePAC(false); + UpdatePACItemsEnabledStatus(); } } @@ -506,9 +511,17 @@ namespace Shadowsocks.View { if (!onlinePACItem.Checked) { - localPACItem.Checked = false; - onlinePACItem.Checked = true; - controller.UseOnlinePAC(true); + if (String.IsNullOrEmpty(controller.GetConfiguration().pacUrl)) + { + UpdateOnlinePACURLItem_Click(sender, e); + } + if (!String.IsNullOrEmpty(controller.GetConfiguration().pacUrl)) + { + localPACItem.Checked = false; + onlinePACItem.Checked = true; + controller.UseOnlinePAC(true); + } + UpdatePACItemsEnabledStatus(); } } @@ -517,12 +530,30 @@ namespace Shadowsocks.View string origPacUrl = controller.GetConfiguration().pacUrl; string pacUrl = Microsoft.VisualBasic.Interaction.InputBox( I18N.GetString("Please input PAC Url"), - I18N.GetString("Update Online PAC URL"), + I18N.GetString("Edit Online PAC URL"), origPacUrl, -1, -1); if (!string.IsNullOrEmpty(pacUrl) && pacUrl != origPacUrl) { controller.SavePACUrl(pacUrl); } } + + private void UpdatePACItemsEnabledStatus() + { + if (this.localPACItem.Checked) + { + this.editLocalPACItem.Enabled = true; + this.updateFromGFWListItem.Enabled = true; + this.editGFWUserRuleItem.Enabled = true; + this.editOnlinePACItem.Enabled = false; + } + else + { + this.editLocalPACItem.Enabled = false; + this.updateFromGFWListItem.Enabled = false; + this.editGFWUserRuleItem.Enabled = false; + this.editOnlinePACItem.Enabled = true; + } + } } }