Compare commits

..
2 Commits
Author SHA1 Message Date
Opportunity 70ec5df5b0 Add temp folder path selection (#1827)
* Translation
* Environment Variables support
2018-05-12 20:31:59 +08:00
celeron533 153727b3b7 Fix typo 2018-05-10 23:53:40 +08:00
10 changed files with 905 additions and 947 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
- Add plugin CLI arguments support - Add plugin CLI arguments support
- Bug fix: Server address should not be encoded (#1758) - Bug fix: Server address should not be encoded (#1758)
- Bug fix: Wrong splash on multi display (#1729) - Bug fix: Wrong splash on multi display (#1729)
- Fix PerPixelAlphaForm's issue in disigner - Fix PerPixelAlphaForm's issue in designer
- Other minor bug fixes and improvements - Other minor bug fixes and improvements
4.0.9 2018-03-14 4.0.9 2018-03-14
@@ -182,6 +182,12 @@ namespace Shadowsocks.Controller
Configuration.Save(_config); Configuration.Save(_config);
} }
public void SaveTempFolder(string tempFolder)
{
_config.tempFolder = tempFolder;
Configuration.Save(_config);
}
public void SaveStrategyConfigurations(StatisticsStrategyConfiguration configuration) public void SaveStrategyConfigurations(StatisticsStrategyConfiguration configuration)
{ {
StatisticsConfiguration = configuration; StatisticsConfiguration = configuration;
@@ -250,7 +256,8 @@ namespace Shadowsocks.Controller
{ {
_config.isVerboseLogging = enabled; _config.isVerboseLogging = enabled;
SaveConfig(_config); SaveConfig(_config);
if ( VerboseLoggingStatusChanged != null ) { if (VerboseLoggingStatusChanged != null)
{
VerboseLoggingStatusChanged(this, new EventArgs()); VerboseLoggingStatusChanged(this, new EventArgs());
} }
} }
+1
View File
@@ -62,6 +62,7 @@ Cancel=取消
New server=未配置的服务器 New server=未配置的服务器
Move &Up=上移(&U) Move &Up=上移(&U)
Move D&own=下移(&O) Move D&own=下移(&O)
Temp Folder=临时文件夹
# Proxy Form # Proxy Form
+1
View File
@@ -62,6 +62,7 @@ Cancel=取消
New server=新伺服器 New server=新伺服器
Move &Up=上移 (&U) Move &Up=上移 (&U)
Move D&own=下移 (&O) Move D&own=下移 (&O)
Temp Folder=臨時資料夾
# Proxy Form # Proxy Form
@@ -30,6 +30,7 @@ namespace Shadowsocks.Model
public LogViewerConfig logViewer; public LogViewerConfig logViewer;
public ProxyConfig proxy; public ProxyConfig proxy;
public HotkeyConfig hotkey; public HotkeyConfig hotkey;
public string tempFolder;
private static string CONFIG_FILE = "gui-config.json"; private static string CONFIG_FILE = "gui-config.json";
@@ -145,6 +146,13 @@ namespace Shadowsocks.Model
throw new ArgumentException(I18N.GetString("Port can't be 8123")); throw new ArgumentException(I18N.GetString("Port can't be 8123"));
} }
public static void CheckTempFolder(string tempPath)
{
if (string.IsNullOrWhiteSpace(tempPath))
return;
Path.GetFullPath(tempPath);
}
private static void CheckPassword(string password) private static void CheckPassword(string password)
{ {
if (password.IsNullOrEmpty()) if (password.IsNullOrEmpty())
+23 -11
View File
@@ -35,7 +35,8 @@ namespace Shadowsocks.Util.SystemProxy
static Sysproxy() static Sysproxy()
{ {
try { try
{
FileManager.UncompressFile(Utils.GetTempPath("sysproxy.exe"), FileManager.UncompressFile(Utils.GetTempPath("sysproxy.exe"),
Environment.Is64BitOperatingSystem ? Resources.sysproxy64_exe : Resources.sysproxy_exe); Environment.Is64BitOperatingSystem ? Resources.sysproxy64_exe : Resources.sysproxy_exe);
} }
@@ -111,8 +112,10 @@ namespace Shadowsocks.Util.SystemProxy
throw new ProxyException(stderr); throw new ProxyException(stderr);
} }
if (arguments == "query") { if (arguments == "query")
if (stdout.IsNullOrWhiteSpace() || stdout.IsNullOrEmpty()) { {
if (stdout.IsNullOrWhiteSpace() || stdout.IsNullOrEmpty())
{
// we cannot get user settings // we cannot get user settings
throw new ProxyException("failed to query wininet settings"); throw new ProxyException("failed to query wininet settings");
} }
@@ -123,25 +126,34 @@ namespace Shadowsocks.Util.SystemProxy
private static void Save() private static void Save()
{ {
try { try
using (StreamWriter sw = new StreamWriter(File.Open(_userWininetConfigFile, FileMode.Create))) { {
using (StreamWriter sw = new StreamWriter(File.Open(Utils.GetTempPath(_userWininetConfigFile), FileMode.Create)))
{
string jsonString = JsonConvert.SerializeObject(_userSettings, Formatting.Indented); string jsonString = JsonConvert.SerializeObject(_userSettings, Formatting.Indented);
sw.Write(jsonString); sw.Write(jsonString);
sw.Flush(); sw.Flush();
} }
} catch (IOException e) { }
catch (IOException e)
{
Logging.LogUsefulException(e); Logging.LogUsefulException(e);
} }
} }
private static void Read() private static void Read()
{ {
try { try
string configContent = File.ReadAllText(_userWininetConfigFile); {
string configContent = File.ReadAllText(Utils.GetTempPath(_userWininetConfigFile));
_userSettings = JsonConvert.DeserializeObject<SysproxyConfig>(configContent); _userSettings = JsonConvert.DeserializeObject<SysproxyConfig>(configContent);
} catch(Exception) { }
// Suppress all exceptions. finally block will initialize new user config settings. catch (Exception)
} finally { {
// Suppress all exceptions. finally block will initialize new user config settings.
}
finally
{
if (_userSettings == null) _userSettings = new SysproxyConfig(); if (_userSettings == null) _userSettings = new SysproxyConfig();
} }
} }
+33 -3
View File
@@ -2,10 +2,12 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
using Shadowsocks.Controller; using Shadowsocks.Controller;
using Shadowsocks.Model;
namespace Shadowsocks.Util namespace Shadowsocks.Util
{ {
@@ -26,6 +28,24 @@ namespace Shadowsocks.Util
public static class Utils public static class Utils
{ {
private static string _tempPath = null; private static string _tempPath = null;
private const string TEMP_LOG = "temp.log";
private static readonly string[] COMMON_ENV =
{
"%Tmp%",
"%Temp%",
"%AppData%",
"%LocalAppData%",
"%Home%",
"%UserProfile%",
"%Public%",
"%CommonProgramFiles%",
"%CommonProgramFiles(x86)%",
"%CommonProgramW6432%",
"%ProgramFiles%",
"%ProgramFiles(x86)%",
"%ProgramW6432%",
"%ProgramData%",
};
// return path to store temporary files // return path to store temporary files
public static string GetTempPath() public static string GetTempPath()
@@ -34,9 +54,19 @@ namespace Shadowsocks.Util
{ {
try try
{ {
Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ss_win_temp")); var tempFolder = Configuration.Load().tempFolder;
// don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log if (string.IsNullOrWhiteSpace(tempFolder))
_tempPath = Path.Combine(Application.StartupPath, "ss_win_temp"); // don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log
tempFolder = "ss_win_temp";
else if (COMMON_ENV.Contains(tempFolder, StringComparer.OrdinalIgnoreCase))
// add subfolder for these common folders
tempFolder += (@"\Shadowsocks\ss_win_temp_" + Application.ExecutablePath.GetHashCode());
tempFolder = Environment.ExpandEnvironmentVariables(tempFolder);
// If `tempFolder` is an absolute path, `Application.StartupPath` will be ignored.
var tempDirectory = Directory.CreateDirectory(Path.Combine(Application.StartupPath, tempFolder));
_tempPath = tempDirectory.FullName;
File.AppendAllText(Path.Combine(_tempPath, TEMP_LOG), $"[{DateTimeOffset.Now.ToString("u")}] Temp folder used by \"{Application.ExecutablePath}\"{Environment.NewLine}");
} }
catch (Exception e) catch (Exception e)
{ {
+44 -19
View File
@@ -46,9 +46,9 @@
this.PluginLabel = new System.Windows.Forms.Label(); this.PluginLabel = new System.Windows.Forms.Label();
this.PluginOptionsTextBox = new System.Windows.Forms.TextBox(); this.PluginOptionsTextBox = new System.Windows.Forms.TextBox();
this.ShowPasswdCheckBox = new System.Windows.Forms.CheckBox(); this.ShowPasswdCheckBox = new System.Windows.Forms.CheckBox();
this.RemarksLabel = new System.Windows.Forms.Label();
this.PluginArgumentsTextBox = new System.Windows.Forms.TextBox(); this.PluginArgumentsTextBox = new System.Windows.Forms.TextBox();
this.PluginArgumentsLabel = new System.Windows.Forms.Label(); this.PluginArgumentsLabel = new System.Windows.Forms.Label();
this.RemarksLabel = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.OKButton = new System.Windows.Forms.Button(); this.OKButton = new System.Windows.Forms.Button();
this.MyCancelButton = new System.Windows.Forms.Button(); this.MyCancelButton = new System.Windows.Forms.Button();
@@ -63,6 +63,8 @@
this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();
this.ProxyPortTextBox = new System.Windows.Forms.TextBox(); this.ProxyPortTextBox = new System.Windows.Forms.TextBox();
this.ProxyPortLabel = new System.Windows.Forms.Label(); this.ProxyPortLabel = new System.Windows.Forms.Label();
this.TempFolderLabel = new System.Windows.Forms.Label();
this.TempFolderTextBox = new System.Windows.Forms.TextBox();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.DuplicateButton = new System.Windows.Forms.Button(); this.DuplicateButton = new System.Windows.Forms.Button();
@@ -311,16 +313,6 @@
this.ShowPasswdCheckBox.UseVisualStyleBackColor = true; this.ShowPasswdCheckBox.UseVisualStyleBackColor = true;
this.ShowPasswdCheckBox.CheckedChanged += new System.EventHandler(this.ShowPasswdCheckBox_CheckedChanged); this.ShowPasswdCheckBox.CheckedChanged += new System.EventHandler(this.ShowPasswdCheckBox_CheckedChanged);
// //
// RemarksLabel
//
this.RemarksLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.RemarksLabel.AutoSize = true;
this.RemarksLabel.Location = new System.Drawing.Point(60, 220);
this.RemarksLabel.Name = "RemarksLabel";
this.RemarksLabel.Size = new System.Drawing.Size(47, 12);
this.RemarksLabel.TabIndex = 8;
this.RemarksLabel.Text = "Remarks";
//
// PluginArgumentsTextBox // PluginArgumentsTextBox
// //
this.PluginArgumentsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.PluginArgumentsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@@ -342,13 +334,23 @@
this.PluginArgumentsLabel.Text = "Plugin Arguments"; this.PluginArgumentsLabel.Text = "Plugin Arguments";
this.toolTip1.SetToolTip(this.PluginArgumentsLabel, "Not SIP003 standard. Used as CLI arguments.\r\nMandatory:\r\n%SS_LOCAL_HOST%, %SS_LOC" + this.toolTip1.SetToolTip(this.PluginArgumentsLabel, "Not SIP003 standard. Used as CLI arguments.\r\nMandatory:\r\n%SS_LOCAL_HOST%, %SS_LOC" +
"SL_PORT%, %SS_REMOTE_HOST%, %SS_REMOTE_PORT%\r\nOptional:\r\n%SS_PLUGIN_OPTIONS%"); "SL_PORT%, %SS_REMOTE_HOST%, %SS_REMOTE_PORT%\r\nOptional:\r\n%SS_PLUGIN_OPTIONS%");
//
// RemarksLabel
//
this.RemarksLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.RemarksLabel.AutoSize = true;
this.RemarksLabel.Location = new System.Drawing.Point(60, 220);
this.RemarksLabel.Name = "RemarksLabel";
this.RemarksLabel.Size = new System.Drawing.Size(47, 12);
this.RemarksLabel.TabIndex = 8;
this.RemarksLabel.Text = "Remarks";
// //
// panel2 // panel2
// //
this.panel2.Anchor = System.Windows.Forms.AnchorStyles.Top; this.panel2.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.panel2.AutoSize = true; this.panel2.AutoSize = true;
this.panel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.panel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.panel2.Location = new System.Drawing.Point(207, 187); this.panel2.Location = new System.Drawing.Point(165, 187);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(0, 0); this.panel2.Size = new System.Drawing.Size(0, 0);
this.panel2.TabIndex = 1; this.panel2.TabIndex = 1;
@@ -496,7 +498,7 @@
// tableLayoutPanel5 // tableLayoutPanel5
// //
this.tableLayoutPanel5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.tableLayoutPanel5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Left)));
this.tableLayoutPanel5.AutoSize = true; this.tableLayoutPanel5.AutoSize = true;
this.tableLayoutPanel5.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanel5.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel5.ColumnCount = 2; this.tableLayoutPanel5.ColumnCount = 2;
@@ -504,23 +506,26 @@
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel5.Controls.Add(this.ProxyPortTextBox, 1, 0); this.tableLayoutPanel5.Controls.Add(this.ProxyPortTextBox, 1, 0);
this.tableLayoutPanel5.Controls.Add(this.ProxyPortLabel, 0, 0); this.tableLayoutPanel5.Controls.Add(this.ProxyPortLabel, 0, 0);
this.tableLayoutPanel5.Location = new System.Drawing.Point(272, 308); this.tableLayoutPanel5.Controls.Add(this.TempFolderLabel, 0, 1);
this.tableLayoutPanel5.Controls.Add(this.TempFolderTextBox, 1, 1);
this.tableLayoutPanel5.Location = new System.Drawing.Point(166, 308);
this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel5.Name = "tableLayoutPanel5"; this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.Padding = new System.Windows.Forms.Padding(3); this.tableLayoutPanel5.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel5.RowCount = 1; this.tableLayoutPanel5.RowCount = 2;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F)); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F)); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F)); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F)); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(196, 64); this.tableLayoutPanel5.Size = new System.Drawing.Size(202, 64);
this.tableLayoutPanel5.TabIndex = 9; this.tableLayoutPanel5.TabIndex = 9;
// //
// ProxyPortTextBox // ProxyPortTextBox
// //
this.ProxyPortTextBox.Anchor = System.Windows.Forms.AnchorStyles.Left; this.ProxyPortTextBox.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.ProxyPortTextBox.Location = new System.Drawing.Point(77, 21); this.ProxyPortTextBox.Location = new System.Drawing.Point(83, 6);
this.ProxyPortTextBox.MaxLength = 10; this.ProxyPortTextBox.MaxLength = 10;
this.ProxyPortTextBox.Name = "ProxyPortTextBox"; this.ProxyPortTextBox.Name = "ProxyPortTextBox";
this.ProxyPortTextBox.Size = new System.Drawing.Size(113, 21); this.ProxyPortTextBox.Size = new System.Drawing.Size(113, 21);
@@ -531,12 +536,30 @@
// //
this.ProxyPortLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; this.ProxyPortLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.ProxyPortLabel.AutoSize = true; this.ProxyPortLabel.AutoSize = true;
this.ProxyPortLabel.Location = new System.Drawing.Point(6, 26); this.ProxyPortLabel.Location = new System.Drawing.Point(12, 10);
this.ProxyPortLabel.Name = "ProxyPortLabel"; this.ProxyPortLabel.Name = "ProxyPortLabel";
this.ProxyPortLabel.Size = new System.Drawing.Size(65, 12); this.ProxyPortLabel.Size = new System.Drawing.Size(65, 12);
this.ProxyPortLabel.TabIndex = 10; this.ProxyPortLabel.TabIndex = 10;
this.ProxyPortLabel.Text = "Proxy Port"; this.ProxyPortLabel.Text = "Proxy Port";
// //
// TempFolderLabel
//
this.TempFolderLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.TempFolderLabel.AutoSize = true;
this.TempFolderLabel.Location = new System.Drawing.Point(6, 39);
this.TempFolderLabel.Name = "TempFolderLabel";
this.TempFolderLabel.Size = new System.Drawing.Size(71, 12);
this.TempFolderLabel.TabIndex = 9;
this.TempFolderLabel.Text = "Temp Folder";
//
// TempFolderTextBox
//
this.TempFolderTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.TempFolderTextBox.Location = new System.Drawing.Point(83, 35);
this.TempFolderTextBox.Name = "TempFolderTextBox";
this.TempFolderTextBox.Size = new System.Drawing.Size(113, 21);
this.TempFolderTextBox.TabIndex = 11;
//
// tableLayoutPanel3 // tableLayoutPanel3
// //
this.tableLayoutPanel3.AutoSize = true; this.tableLayoutPanel3.AutoSize = true;
@@ -596,7 +619,7 @@
this.AutoSize = true; this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.CancelButton = this.MyCancelButton; this.CancelButton = this.MyCancelButton;
this.ClientSize = new System.Drawing.Size(574, 438); this.ClientSize = new System.Drawing.Size(491, 438);
this.Controls.Add(this.tableLayoutPanel2); this.Controls.Add(this.tableLayoutPanel2);
this.Controls.Add(this.panel2); this.Controls.Add(this.panel2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@@ -663,9 +686,11 @@
private System.Windows.Forms.TextBox PluginOptionsTextBox; private System.Windows.Forms.TextBox PluginOptionsTextBox;
private System.Windows.Forms.CheckBox ShowPasswdCheckBox; private System.Windows.Forms.CheckBox ShowPasswdCheckBox;
private System.Windows.Forms.TextBox PasswordTextBox; private System.Windows.Forms.TextBox PasswordTextBox;
private System.Windows.Forms.Label TempFolderLabel;
private System.Windows.Forms.TextBox PluginArgumentsTextBox; private System.Windows.Forms.TextBox PluginArgumentsTextBox;
private System.Windows.Forms.Label PluginArgumentsLabel; private System.Windows.Forms.Label PluginArgumentsLabel;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.TextBox TempFolderTextBox;
} }
} }
+10 -4
View File
@@ -9,6 +9,7 @@ using Microsoft.Win32;
using Shadowsocks.Controller; using Shadowsocks.Controller;
using Shadowsocks.Model; using Shadowsocks.Model;
using Shadowsocks.Properties; using Shadowsocks.Properties;
using System.Threading.Tasks;
namespace Shadowsocks.View namespace Shadowsocks.View
{ {
@@ -22,11 +23,12 @@ namespace Shadowsocks.View
public ConfigForm(ShadowsocksController controller) public ConfigForm(ShadowsocksController controller)
{ {
this.Font = System.Drawing.SystemFonts.MessageBoxFont; this.Font = SystemFonts.MessageBoxFont;
InitializeComponent(); InitializeComponent();
// a dirty hack // a dirty hack
this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill; this.ServersListBox.Dock = DockStyle.Fill;
this.tableLayoutPanel5.Dock = DockStyle.Fill;
this.PerformLayout(); this.PerformLayout();
UpdateTexts(); UpdateTexts();
@@ -52,6 +54,7 @@ namespace Shadowsocks.View
PluginOptionsLabel.Text = I18N.GetString("Plugin Options"); PluginOptionsLabel.Text = I18N.GetString("Plugin Options");
PluginArgumentsLabel.Text = I18N.GetString("Plugin Arguments"); PluginArgumentsLabel.Text = I18N.GetString("Plugin Arguments");
ProxyPortLabel.Text = I18N.GetString("Proxy Port"); ProxyPortLabel.Text = I18N.GetString("Proxy Port");
TempFolderLabel.Text = I18N.GetString("Temp Folder");
RemarksLabel.Text = I18N.GetString("Remarks"); RemarksLabel.Text = I18N.GetString("Remarks");
TimeoutLabel.Text = I18N.GetString("Timeout(Sec)"); TimeoutLabel.Text = I18N.GetString("Timeout(Sec)");
ServerGroupBox.Text = I18N.GetString("Server"); ServerGroupBox.Text = I18N.GetString("Server");
@@ -109,6 +112,7 @@ namespace Shadowsocks.View
return false; return false;
} }
int localPort = int.Parse(ProxyPortTextBox.Text); int localPort = int.Parse(ProxyPortTextBox.Text);
Configuration.CheckTempFolder(TempFolderTextBox.Text);
Configuration.CheckServer(server); Configuration.CheckServer(server);
Configuration.CheckLocalPort(localPort); Configuration.CheckLocalPort(localPort);
_modifiedConfiguration.configs[_lastSelectedIndex] = server; _modifiedConfiguration.configs[_lastSelectedIndex] = server;
@@ -163,6 +167,7 @@ namespace Shadowsocks.View
ServersListBox.SelectedIndex = _lastSelectedIndex; ServersListBox.SelectedIndex = _lastSelectedIndex;
UpdateMoveUpAndDownButton(); UpdateMoveUpAndDownButton();
LoadSelectedServer(); LoadSelectedServer();
TempFolderTextBox.Text = _modifiedConfiguration.tempFolder;
} }
private void ConfigForm_Load(object sender, EventArgs e) private void ConfigForm_Load(object sender, EventArgs e)
@@ -231,14 +236,14 @@ namespace Shadowsocks.View
_lastSelectedIndex = ServersListBox.SelectedIndex; _lastSelectedIndex = ServersListBox.SelectedIndex;
} }
private void DuplicateButton_Click( object sender, EventArgs e ) private void DuplicateButton_Click(object sender, EventArgs e)
{ {
if (!SaveOldSelectedServer()) if (!SaveOldSelectedServer())
{ {
return; return;
} }
Server currServer = _modifiedConfiguration.configs[_lastSelectedIndex]; Server currServer = _modifiedConfiguration.configs[_lastSelectedIndex];
var currIndex = _modifiedConfiguration.configs.IndexOf( currServer ); var currIndex = _modifiedConfiguration.configs.IndexOf(currServer);
_modifiedConfiguration.configs.Insert(currIndex + 1, currServer); _modifiedConfiguration.configs.Insert(currIndex + 1, currServer);
LoadConfiguration(_modifiedConfiguration); LoadConfiguration(_modifiedConfiguration);
ServersListBox.SelectedIndex = currIndex + 1; ServersListBox.SelectedIndex = currIndex + 1;
@@ -275,6 +280,7 @@ namespace Shadowsocks.View
return; return;
} }
controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.localPort); controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.localPort);
controller.SaveTempFolder(TempFolderTextBox.Text);
// SelectedIndex remains valid // SelectedIndex remains valid
// We handled this in event handlers, e.g. Add/DeleteButton, SelectedIndexChanged // We handled this in event handlers, e.g. Add/DeleteButton, SelectedIndexChanged
// and move operations // and move operations
-132
View File
@@ -117,139 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="tableLayoutPanel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PluginOptionsLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="PluginTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RemarksTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="IPLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ServerPortLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PasswordLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="IPTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ServerPortTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PasswordTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="EncryptionLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="EncryptionSelect.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TimeoutLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TimeoutTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PluginLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PluginOptionsTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ShowPasswdCheckBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PluginArgumentsTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PluginArgumentsLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="RemarksLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="OKButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MyCancelButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DeleteButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="AddButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ServerGroupBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ServersListBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tableLayoutPanel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tableLayoutPanel6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MoveDownButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MoveUpButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tableLayoutPanel5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ProxyPortTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ProxyPortLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tableLayoutPanel3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tableLayoutPanel4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DuplicateButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MoveDownButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MoveUpButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ProxyPortTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ProxyPortLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DuplicateButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>