| @@ -0,0 +1,42 @@ | |||
| using Shadowsocks.Properties; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using System.Text.RegularExpressions; | |||
| namespace Shadowsocks.Controller | |||
| { | |||
| public class I18N | |||
| { | |||
| protected static Dictionary<string, string> Strings; | |||
| static I18N() | |||
| { | |||
| Strings = new Dictionary<string, string>(); | |||
| if (System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag.ToLowerInvariant().StartsWith("zh")) | |||
| { | |||
| string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n"); | |||
| foreach (string line in lines) | |||
| { | |||
| string[] kv = Regex.Split(line, "="); | |||
| if (kv.Length == 2) | |||
| { | |||
| Strings[kv[0]] = kv[1]; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| public static string GetString(string key) | |||
| { | |||
| if (Strings.ContainsKey(key)) | |||
| { | |||
| return Strings[key]; | |||
| } | |||
| else | |||
| { | |||
| return key; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -61,7 +61,7 @@ namespace Shadowsocks.Controller | |||
| SocketException se = (SocketException)e; | |||
| if (se.SocketErrorCode == SocketError.AccessDenied) | |||
| { | |||
| e = new Exception("Port is already used", e); | |||
| e = new Exception(I18N.GetString("Port is already used"), e); | |||
| } | |||
| } | |||
| Errored(this, new ErrorEventArgs(e)); | |||
| @@ -0,0 +1,36 @@ | |||
| Shadowsocks=Shadowsocks | |||
| Enable=启用代理 | |||
| Mode=代理模式 | |||
| PAC=PAC 模式 | |||
| Global=全局模式 | |||
| Servers=服务器选择 | |||
| Edit Servers...=编辑服务器... | |||
| Start on Boot=自动启动 | |||
| Share over LAN=在局域网共享代理 | |||
| Edit PAC File...=编辑 PAC 文件... | |||
| Show QRCode...=显示二维码... | |||
| Show Logs...=显示日志... | |||
| About...=关于... | |||
| Quit=退出 | |||
| Edit Servers=编辑服务器 | |||
| &Add=添加(&A) | |||
| &Delete=删除(&D) | |||
| Server=服务器 | |||
| Server IP=服务器 IP | |||
| Server Port=服务器端口 | |||
| Password=密码 | |||
| Encryption=加密 | |||
| Proxy Port=代理端口 | |||
| Remarks=备注 | |||
| OK=确定 | |||
| Cancel=取消 | |||
| New server=新服务器 | |||
| QRCode=二维码 | |||
| Shadowsocks Error: {0}=Shadowsocks 错误: {0} | |||
| Port is already used=端口已被占用 | |||
| Illegal port number format=非法端口格式 | |||
| 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 | |||
| @@ -60,6 +60,39 @@ namespace Shadowsocks.Properties { | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// Looks up a localized string similar to Enable=启用 | |||
| ///Mode=模式 | |||
| ///PAC=PAC | |||
| ///Global=全局 | |||
| ///Servers=服务器 | |||
| ///Edit Servers...=编辑服务器... | |||
| ///Start on Boot=自动启动 | |||
| ///Share over LAN=在局域网共享代理 | |||
| ///Edit PAC File...=修改 PAC 文件... | |||
| ///Show QRCode...=显示二维码... | |||
| ///Show Logs...=显示日志... | |||
| ///About...=关于... | |||
| ///Quit=退出 | |||
| ///Edit Servers=编辑服务器 | |||
| ///Add=添加 | |||
| ///Delete=删除 | |||
| ///Server=服务器 | |||
| ///Server IP=服务器 IP | |||
| ///Server Port=服务器端口 | |||
| ///Password=密码 | |||
| ///Encryption=加密 | |||
| ///Proxy Port=代理端口 | |||
| ///Remarks=备注 | |||
| /// | |||
| ///. | |||
| /// </summary> | |||
| internal static string cn { | |||
| get { | |||
| return ResourceManager.GetString("cn", resourceCulture); | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// Looks up a localized resource of type System.Byte[]. | |||
| /// </summary> | |||
| @@ -118,6 +118,9 @@ | |||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | |||
| <data name="cn" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||
| <value>..\data\cn.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> | |||
| </data> | |||
| <data name="libsscrypto_dll" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||
| <value>..\data\libsscrypto.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </data> | |||
| @@ -30,16 +30,16 @@ | |||
| { | |||
| this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); | |||
| this.RemarksTextBox = new System.Windows.Forms.TextBox(); | |||
| this.label6 = new System.Windows.Forms.Label(); | |||
| this.label1 = new System.Windows.Forms.Label(); | |||
| this.label2 = new System.Windows.Forms.Label(); | |||
| this.RemarksLabel = new System.Windows.Forms.Label(); | |||
| this.IPLabel = new System.Windows.Forms.Label(); | |||
| this.ServerPortLabel = new System.Windows.Forms.Label(); | |||
| this.ProxyPortTextBox = new System.Windows.Forms.TextBox(); | |||
| this.label4 = new System.Windows.Forms.Label(); | |||
| this.label3 = new System.Windows.Forms.Label(); | |||
| this.ProxyPortLabel = new System.Windows.Forms.Label(); | |||
| this.PasswordLabel = new System.Windows.Forms.Label(); | |||
| this.IPTextBox = new System.Windows.Forms.TextBox(); | |||
| this.ServerPortTextBox = new System.Windows.Forms.TextBox(); | |||
| this.PasswordTextBox = new System.Windows.Forms.TextBox(); | |||
| this.label5 = new System.Windows.Forms.Label(); | |||
| this.EncryptionLabel = new System.Windows.Forms.Label(); | |||
| this.EncryptionSelect = new System.Windows.Forms.ComboBox(); | |||
| this.panel2 = new System.Windows.Forms.Panel(); | |||
| this.OKButton = new System.Windows.Forms.Button(); | |||
| @@ -64,16 +64,16 @@ | |||
| this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | |||
| this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); | |||
| this.tableLayoutPanel1.Controls.Add(this.RemarksTextBox, 1, 5); | |||
| this.tableLayoutPanel1.Controls.Add(this.label6, 0, 5); | |||
| this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); | |||
| this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); | |||
| this.tableLayoutPanel1.Controls.Add(this.RemarksLabel, 0, 5); | |||
| this.tableLayoutPanel1.Controls.Add(this.IPLabel, 0, 0); | |||
| this.tableLayoutPanel1.Controls.Add(this.ServerPortLabel, 0, 1); | |||
| this.tableLayoutPanel1.Controls.Add(this.ProxyPortTextBox, 1, 4); | |||
| this.tableLayoutPanel1.Controls.Add(this.label4, 0, 4); | |||
| this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2); | |||
| this.tableLayoutPanel1.Controls.Add(this.ProxyPortLabel, 0, 4); | |||
| this.tableLayoutPanel1.Controls.Add(this.PasswordLabel, 0, 2); | |||
| this.tableLayoutPanel1.Controls.Add(this.IPTextBox, 1, 0); | |||
| this.tableLayoutPanel1.Controls.Add(this.ServerPortTextBox, 1, 1); | |||
| this.tableLayoutPanel1.Controls.Add(this.PasswordTextBox, 1, 2); | |||
| this.tableLayoutPanel1.Controls.Add(this.label5, 0, 3); | |||
| this.tableLayoutPanel1.Controls.Add(this.EncryptionLabel, 0, 3); | |||
| this.tableLayoutPanel1.Controls.Add(this.EncryptionSelect, 1, 3); | |||
| this.tableLayoutPanel1.Location = new System.Drawing.Point(8, 21); | |||
| this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(5); | |||
| @@ -98,35 +98,35 @@ | |||
| this.RemarksTextBox.TabIndex = 10; | |||
| this.RemarksTextBox.WordWrap = false; | |||
| // | |||
| // label6 | |||
| // RemarksLabel | |||
| // | |||
| this.label6.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label6.AutoSize = true; | |||
| this.label6.Location = new System.Drawing.Point(19, 142); | |||
| this.label6.Name = "label6"; | |||
| this.label6.Size = new System.Drawing.Size(49, 13); | |||
| this.label6.TabIndex = 9; | |||
| this.label6.Text = "Remarks"; | |||
| this.RemarksLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.RemarksLabel.AutoSize = true; | |||
| this.RemarksLabel.Location = new System.Drawing.Point(19, 142); | |||
| this.RemarksLabel.Name = "RemarksLabel"; | |||
| this.RemarksLabel.Size = new System.Drawing.Size(49, 13); | |||
| this.RemarksLabel.TabIndex = 9; | |||
| this.RemarksLabel.Text = "Remarks"; | |||
| // | |||
| // label1 | |||
| // IPLabel | |||
| // | |||
| this.label1.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label1.AutoSize = true; | |||
| this.label1.Location = new System.Drawing.Point(17, 11); | |||
| this.label1.Name = "label1"; | |||
| this.label1.Size = new System.Drawing.Size(51, 13); | |||
| this.label1.TabIndex = 0; | |||
| this.label1.Text = "Server IP"; | |||
| this.IPLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.IPLabel.AutoSize = true; | |||
| this.IPLabel.Location = new System.Drawing.Point(17, 11); | |||
| this.IPLabel.Name = "IPLabel"; | |||
| this.IPLabel.Size = new System.Drawing.Size(51, 13); | |||
| this.IPLabel.TabIndex = 0; | |||
| this.IPLabel.Text = "Server IP"; | |||
| // | |||
| // label2 | |||
| // ServerPortLabel | |||
| // | |||
| this.label2.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label2.AutoSize = true; | |||
| this.label2.Location = new System.Drawing.Point(8, 37); | |||
| this.label2.Name = "label2"; | |||
| this.label2.Size = new System.Drawing.Size(60, 13); | |||
| this.label2.TabIndex = 1; | |||
| this.label2.Text = "Server Port"; | |||
| this.ServerPortLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.ServerPortLabel.AutoSize = true; | |||
| this.ServerPortLabel.Location = new System.Drawing.Point(8, 37); | |||
| this.ServerPortLabel.Name = "ServerPortLabel"; | |||
| this.ServerPortLabel.Size = new System.Drawing.Size(60, 13); | |||
| this.ServerPortLabel.TabIndex = 1; | |||
| this.ServerPortLabel.Text = "Server Port"; | |||
| // | |||
| // ProxyPortTextBox | |||
| // | |||
| @@ -137,25 +137,25 @@ | |||
| this.ProxyPortTextBox.TabIndex = 4; | |||
| this.ProxyPortTextBox.WordWrap = false; | |||
| // | |||
| // label4 | |||
| // ProxyPortLabel | |||
| // | |||
| this.label4.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label4.AutoSize = true; | |||
| this.label4.Location = new System.Drawing.Point(13, 116); | |||
| this.label4.Name = "label4"; | |||
| this.label4.Size = new System.Drawing.Size(55, 13); | |||
| this.label4.TabIndex = 3; | |||
| this.label4.Text = "Proxy Port"; | |||
| this.ProxyPortLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.ProxyPortLabel.AutoSize = true; | |||
| this.ProxyPortLabel.Location = new System.Drawing.Point(13, 116); | |||
| this.ProxyPortLabel.Name = "ProxyPortLabel"; | |||
| this.ProxyPortLabel.Size = new System.Drawing.Size(55, 13); | |||
| this.ProxyPortLabel.TabIndex = 3; | |||
| this.ProxyPortLabel.Text = "Proxy Port"; | |||
| // | |||
| // label3 | |||
| // PasswordLabel | |||
| // | |||
| this.label3.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label3.AutoSize = true; | |||
| this.label3.Location = new System.Drawing.Point(15, 63); | |||
| this.label3.Name = "label3"; | |||
| this.label3.Size = new System.Drawing.Size(53, 13); | |||
| this.label3.TabIndex = 2; | |||
| this.label3.Text = "Password"; | |||
| this.PasswordLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.PasswordLabel.AutoSize = true; | |||
| this.PasswordLabel.Location = new System.Drawing.Point(15, 63); | |||
| this.PasswordLabel.Name = "PasswordLabel"; | |||
| this.PasswordLabel.Size = new System.Drawing.Size(53, 13); | |||
| this.PasswordLabel.TabIndex = 2; | |||
| this.PasswordLabel.Text = "Password"; | |||
| // | |||
| // IPTextBox | |||
| // | |||
| @@ -185,15 +185,15 @@ | |||
| this.PasswordTextBox.TabIndex = 2; | |||
| this.PasswordTextBox.WordWrap = false; | |||
| // | |||
| // label5 | |||
| // EncryptionLabel | |||
| // | |||
| this.label5.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.label5.AutoSize = true; | |||
| this.label5.Location = new System.Drawing.Point(11, 90); | |||
| this.label5.Name = "label5"; | |||
| this.label5.Size = new System.Drawing.Size(57, 13); | |||
| this.label5.TabIndex = 8; | |||
| this.label5.Text = "Encryption"; | |||
| this.EncryptionLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; | |||
| this.EncryptionLabel.AutoSize = true; | |||
| this.EncryptionLabel.Location = new System.Drawing.Point(11, 90); | |||
| this.EncryptionLabel.Name = "EncryptionLabel"; | |||
| this.EncryptionLabel.Size = new System.Drawing.Size(57, 13); | |||
| this.EncryptionLabel.TabIndex = 8; | |||
| this.EncryptionLabel.Text = "Encryption"; | |||
| // | |||
| // EncryptionSelect | |||
| // | |||
| @@ -347,15 +347,15 @@ | |||
| #endregion | |||
| private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; | |||
| private System.Windows.Forms.Label label1; | |||
| private System.Windows.Forms.Label label2; | |||
| private System.Windows.Forms.Label label3; | |||
| private System.Windows.Forms.Label label4; | |||
| private System.Windows.Forms.Label IPLabel; | |||
| private System.Windows.Forms.Label ServerPortLabel; | |||
| private System.Windows.Forms.Label PasswordLabel; | |||
| private System.Windows.Forms.Label ProxyPortLabel; | |||
| private System.Windows.Forms.TextBox IPTextBox; | |||
| private System.Windows.Forms.TextBox ServerPortTextBox; | |||
| private System.Windows.Forms.TextBox PasswordTextBox; | |||
| private System.Windows.Forms.TextBox ProxyPortTextBox; | |||
| private System.Windows.Forms.Label label5; | |||
| private System.Windows.Forms.Label EncryptionLabel; | |||
| private System.Windows.Forms.ComboBox EncryptionSelect; | |||
| private System.Windows.Forms.Panel panel2; | |||
| private System.Windows.Forms.Button OKButton; | |||
| @@ -367,7 +367,7 @@ | |||
| private System.Windows.Forms.GroupBox ServerGroupBox; | |||
| private System.Windows.Forms.ListBox ServersListBox; | |||
| private System.Windows.Forms.TextBox RemarksTextBox; | |||
| private System.Windows.Forms.Label label6; | |||
| private System.Windows.Forms.Label RemarksLabel; | |||
| } | |||
| } | |||
| @@ -23,6 +23,7 @@ namespace Shadowsocks.View | |||
| public ConfigForm(ShadowsocksController controller) | |||
| { | |||
| InitializeComponent(); | |||
| UpdateTexts(); | |||
| this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); | |||
| this.controller = controller; | |||
| @@ -31,6 +32,22 @@ namespace Shadowsocks.View | |||
| LoadCurrentConfiguration(); | |||
| } | |||
| private void UpdateTexts() | |||
| { | |||
| AddButton.Text = I18N.GetString("&Add"); | |||
| DeleteButton.Text = I18N.GetString("&Delete"); | |||
| IPLabel.Text = I18N.GetString("Server IP"); | |||
| ServerPortLabel.Text = I18N.GetString("Server Port"); | |||
| PasswordLabel.Text = I18N.GetString("Password"); | |||
| EncryptionLabel.Text = I18N.GetString("Encryption"); | |||
| ProxyPortLabel.Text = I18N.GetString("Proxy Port"); | |||
| RemarksLabel.Text = I18N.GetString("Remarks"); | |||
| ServerGroupBox.Text = I18N.GetString("Server"); | |||
| OKButton.Text = I18N.GetString("OK"); | |||
| MyCancelButton.Text = I18N.GetString("Cancel"); | |||
| this.Text = I18N.GetString("Edit Servers"); | |||
| } | |||
| private void controller_ConfigChanged(object sender, EventArgs e) | |||
| { | |||
| LoadCurrentConfiguration(); | |||
| @@ -67,7 +84,7 @@ namespace Shadowsocks.View | |||
| } | |||
| catch (FormatException) | |||
| { | |||
| MessageBox.Show("illegal port number format"); | |||
| MessageBox.Show(I18N.GetString("Illegal port number format")); | |||
| } | |||
| catch (Exception ex) | |||
| { | |||
| @@ -102,7 +119,7 @@ namespace Shadowsocks.View | |||
| ServersListBox.Items.Clear(); | |||
| foreach (Server server in _modifiedConfiguration.configs) | |||
| { | |||
| ServersListBox.Items.Add(string.IsNullOrEmpty(server.server) ? "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") : string.IsNullOrEmpty(server.remarks)? server.server + ":" + server.server_port : server.server + ":" + server.server_port + " (" + server.remarks + ")"); | |||
| } | |||
| } | |||
| @@ -176,7 +193,7 @@ namespace Shadowsocks.View | |||
| } | |||
| if (_modifiedConfiguration.configs.Count == 0) | |||
| { | |||
| MessageBox.Show("Please add at least one server"); | |||
| MessageBox.Show(I18N.GetString("Please add at least one server")); | |||
| return; | |||
| } | |||
| controller.SaveServers(_modifiedConfiguration.configs); | |||
| @@ -19,7 +19,7 @@ namespace Shadowsocks.View | |||
| private ShadowsocksController controller; | |||
| private UpdateChecker updateChecker; | |||
| private NotifyIcon notifyIcon1; | |||
| private NotifyIcon _notifyIcon; | |||
| private ContextMenu contextMenu1; | |||
| private bool _isFirstRun; | |||
| @@ -44,10 +44,10 @@ namespace Shadowsocks.View | |||
| public MenuViewController(ShadowsocksController controller) | |||
| { | |||
| this.controller = controller; | |||
| LoadMenu(); | |||
| LoadTrayIcon(); | |||
| this.controller = controller; | |||
| controller.EnableStatusChanged += controller_EnableStatusChanged; | |||
| controller.ConfigChanged += controller_ConfigChanged; | |||
| controller.PACFileReadyToOpen += controller_PACFileReadyToOpen; | |||
| @@ -55,6 +55,13 @@ namespace Shadowsocks.View | |||
| controller.EnableGlobalChanged += controller_EnableGlobalChanged; | |||
| controller.Errored += controller_Errored; | |||
| _notifyIcon = new NotifyIcon(); | |||
| LoadTrayIcon(); | |||
| _notifyIcon.Visible = true; | |||
| _notifyIcon.Text = I18N.GetString("Shadowsocks"); | |||
| _notifyIcon.ContextMenu = contextMenu1; | |||
| _notifyIcon.DoubleClick += notifyIcon1_DoubleClick; | |||
| this.updateChecker = new UpdateChecker(); | |||
| updateChecker.NewVersionFound += updateChecker_NewVersionFound; | |||
| @@ -71,7 +78,7 @@ namespace Shadowsocks.View | |||
| void controller_Errored(object sender, System.IO.ErrorEventArgs e) | |||
| { | |||
| MessageBox.Show(e.GetException().ToString(), "Error: " + e.GetException().Message); | |||
| MessageBox.Show(e.GetException().ToString(), String.Format(I18N.GetString("Shadowsocks Error: {0}"), e.GetException().Message)); | |||
| } | |||
| private void LoadTrayIcon() | |||
| @@ -95,13 +102,20 @@ namespace Shadowsocks.View | |||
| { | |||
| icon = Resources.ss24; | |||
| } | |||
| notifyIcon1 = new NotifyIcon(); | |||
| notifyIcon1.Text = "Shadowsocks"; | |||
| notifyIcon1.Icon = Icon.FromHandle(icon.GetHicon()); | |||
| notifyIcon1.Visible = true; | |||
| notifyIcon1.ContextMenu = contextMenu1; | |||
| notifyIcon1.DoubleClick +=notifyIcon1_DoubleClick; | |||
| if (!controller.GetConfiguration().enabled) | |||
| { | |||
| Bitmap iconCopy = new Bitmap(icon); | |||
| for (int x = 0; x < iconCopy.Width; x++) | |||
| { | |||
| for (int y = 0; y < iconCopy.Height; y++) | |||
| { | |||
| Color color = icon.GetPixel(x, y); | |||
| iconCopy.SetPixel(x, y , Color.FromArgb((byte)(color.A / 1.25), color.R, color.G, color.B)); | |||
| } | |||
| } | |||
| icon = iconCopy; | |||
| } | |||
| _notifyIcon.Icon = Icon.FromHandle(icon.GetHicon()); | |||
| } | |||
| private void LoadMenu() | |||
| @@ -146,7 +160,7 @@ namespace Shadowsocks.View | |||
| // enableItem | |||
| // | |||
| this.enableItem.Index = 0; | |||
| this.enableItem.Text = "&Enable"; | |||
| this.enableItem.Text = I18N.GetString("Enable"); | |||
| this.enableItem.Click += new System.EventHandler(this.EnableItem_Click); | |||
| // | |||
| // modeMenu | |||
| @@ -155,18 +169,18 @@ namespace Shadowsocks.View | |||
| this.modeItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |||
| this.PACModeItem, | |||
| this.globalModeItem}); | |||
| this.modeItem.Text = "Mode"; | |||
| this.modeItem.Text = I18N.GetString("Mode"); | |||
| // | |||
| // PACModeItem | |||
| // | |||
| this.PACModeItem.Index = 0; | |||
| this.PACModeItem.Text = "PAC"; | |||
| this.PACModeItem.Text = I18N.GetString("PAC"); | |||
| this.PACModeItem.Click += new System.EventHandler(this.PACModeItem_Click); | |||
| // | |||
| // globalModeItem | |||
| // | |||
| this.globalModeItem.Index = 1; | |||
| this.globalModeItem.Text = "Global"; | |||
| this.globalModeItem.Text = I18N.GetString("Global"); | |||
| this.globalModeItem.Click += new System.EventHandler(this.GlobalModeItem_Click); | |||
| // | |||
| // ServersItem | |||
| @@ -175,7 +189,7 @@ namespace Shadowsocks.View | |||
| this.ServersItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |||
| this.SeperatorItem, | |||
| this.ConfigItem}); | |||
| this.ServersItem.Text = "&Servers"; | |||
| this.ServersItem.Text = I18N.GetString("Servers"); | |||
| // | |||
| // SeperatorItem | |||
| // | |||
| @@ -185,7 +199,7 @@ namespace Shadowsocks.View | |||
| // ConfigItem | |||
| // | |||
| this.ConfigItem.Index = 1; | |||
| this.ConfigItem.Text = "Edit Servers..."; | |||
| this.ConfigItem.Text = I18N.GetString("Edit Servers..."); | |||
| this.ConfigItem.Click += new System.EventHandler(this.Config_Click); | |||
| // | |||
| // menuItem1 | |||
| @@ -196,19 +210,19 @@ namespace Shadowsocks.View | |||
| // AutoStartupItem | |||
| // | |||
| this.AutoStartupItem.Index = 4; | |||
| this.AutoStartupItem.Text = "Start on Boot"; | |||
| this.AutoStartupItem.Text = I18N.GetString("Start on Boot"); | |||
| this.AutoStartupItem.Click += new System.EventHandler(this.AutoStartupItem_Click); | |||
| // | |||
| // ShareOverLANItem | |||
| // | |||
| this.ShareOverLANItem.Index = 5; | |||
| this.ShareOverLANItem.Text = "Share over LAN"; | |||
| this.ShareOverLANItem.Text = I18N.GetString("Share over LAN"); | |||
| this.ShareOverLANItem.Click += new System.EventHandler(this.ShareOverLANItem_Click); | |||
| // | |||
| // editPACFileItem | |||
| // | |||
| this.editPACFileItem.Index = 6; | |||
| this.editPACFileItem.Text = "Edit &PAC File..."; | |||
| this.editPACFileItem.Text = I18N.GetString("Edit PAC File..."); | |||
| this.editPACFileItem.Click += new System.EventHandler(this.EditPACFileItem_Click); | |||
| // | |||
| // menuItem4 | |||
| @@ -219,19 +233,19 @@ namespace Shadowsocks.View | |||
| // QRCodeItem | |||
| // | |||
| this.QRCodeItem.Index = 8; | |||
| this.QRCodeItem.Text = "Show &QRCode..."; | |||
| this.QRCodeItem.Text = I18N.GetString("Show QRCode..."); | |||
| this.QRCodeItem.Click += new System.EventHandler(this.QRCodeItem_Click); | |||
| // | |||
| // ShowLogItem | |||
| // | |||
| this.ShowLogItem.Index = 9; | |||
| this.ShowLogItem.Text = "Show Logs..."; | |||
| this.ShowLogItem.Text = I18N.GetString("Show Logs..."); | |||
| this.ShowLogItem.Click += new System.EventHandler(this.ShowLogItem_Click); | |||
| // | |||
| // aboutItem | |||
| // | |||
| this.aboutItem.Index = 10; | |||
| this.aboutItem.Text = "About..."; | |||
| this.aboutItem.Text = I18N.GetString("About..."); | |||
| this.aboutItem.Click += new System.EventHandler(this.AboutItem_Click); | |||
| // | |||
| // menuItem3 | |||
| @@ -242,7 +256,7 @@ namespace Shadowsocks.View | |||
| // quitItem | |||
| // | |||
| this.quitItem.Index = 12; | |||
| this.quitItem.Text = "&Quit"; | |||
| this.quitItem.Text = I18N.GetString("Quit"); | |||
| this.quitItem.Click += new System.EventHandler(this.Quit_Click); | |||
| } | |||
| @@ -254,6 +268,7 @@ namespace Shadowsocks.View | |||
| private void controller_EnableStatusChanged(object sender, EventArgs e) | |||
| { | |||
| enableItem.Checked = controller.GetConfiguration().enabled; | |||
| LoadTrayIcon(); | |||
| } | |||
| void controller_ShareOverLANStatusChanged(object sender, EventArgs e) | |||
| @@ -276,11 +291,11 @@ namespace Shadowsocks.View | |||
| void updateChecker_NewVersionFound(object sender, EventArgs e) | |||
| { | |||
| notifyIcon1.BalloonTipTitle = "Shadowsocks " + updateChecker.LatestVersionNumber + " Update Found"; | |||
| notifyIcon1.BalloonTipText = "Click here to download"; | |||
| notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; | |||
| notifyIcon1.BalloonTipClicked += notifyIcon1_BalloonTipClicked; | |||
| notifyIcon1.ShowBalloonTip(5000); | |||
| _notifyIcon.BalloonTipTitle = String.Format(I18N.GetString("Shadowsocks {0} Update Found"), updateChecker.LatestVersionNumber); | |||
| _notifyIcon.BalloonTipText = I18N.GetString("Click here to download"); | |||
| _notifyIcon.BalloonTipIcon = ToolTipIcon.Info; | |||
| _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked; | |||
| _notifyIcon.ShowBalloonTip(5000); | |||
| _isFirstRun = false; | |||
| } | |||
| @@ -354,7 +369,7 @@ namespace Shadowsocks.View | |||
| private void Quit_Click(object sender, EventArgs e) | |||
| { | |||
| controller.Stop(); | |||
| notifyIcon1.Visible = false; | |||
| _notifyIcon.Visible = false; | |||
| Application.Exit(); | |||
| } | |||
| @@ -362,10 +377,10 @@ namespace Shadowsocks.View | |||
| { | |||
| if (_isFirstRun) | |||
| { | |||
| notifyIcon1.BalloonTipTitle = "Shadowsocks is here"; | |||
| notifyIcon1.BalloonTipText = "You can turn on/off Shadowsocks in the context menu"; | |||
| notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; | |||
| notifyIcon1.ShowBalloonTip(0); | |||
| _notifyIcon.BalloonTipTitle = I18N.GetString("Shadowsocks is here"); | |||
| _notifyIcon.BalloonTipText = I18N.GetString("You can turn on/off Shadowsocks in the context menu"); | |||
| _notifyIcon.BalloonTipIcon = ToolTipIcon.Info; | |||
| _notifyIcon.ShowBalloonTip(0); | |||
| _isFirstRun = false; | |||
| } | |||
| } | |||
| @@ -1,4 +1,5 @@ | |||
| using QRCode4CS; | |||
| using Shadowsocks.Controller; | |||
| using Shadowsocks.Properties; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| @@ -21,6 +22,7 @@ namespace Shadowsocks.View | |||
| this.code = code; | |||
| InitializeComponent(); | |||
| this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon()); | |||
| this.Text = I18N.GetString("QRCode"); | |||
| } | |||
| private void GenQR(string ssconfig) | |||
| @@ -73,6 +73,7 @@ | |||
| <Compile Include="3rd\SimpleJson.cs" /> | |||
| <Compile Include="Controller\AutoStartup.cs" /> | |||
| <Compile Include="Controller\FileManager.cs" /> | |||
| <Compile Include="Controller\I18N.cs" /> | |||
| <Compile Include="Controller\Logging.cs" /> | |||
| <Compile Include="Controller\UpdateChecker.cs" /> | |||
| <Compile Include="Encrypt\EncryptorBase.cs" /> | |||
| @@ -146,6 +147,7 @@ | |||
| <None Include="Resources\ss16.png" /> | |||
| <None Include="Resources\ss24.png" /> | |||
| <None Include="Resources\ssw128.png" /> | |||
| <Content Include="Data\cn.txt" /> | |||
| <Content Include="shadowsocks.ico" /> | |||
| <None Include="Data\polipo_config.txt" /> | |||
| </ItemGroup> | |||