Change the first letter of function to upper case letter to fit C# code styletags/2.3
@@ -13,7 +13,7 @@ namespace Shadowsocks.Controller | |||||
{ | { | ||||
private Server config; | private Server config; | ||||
//private Encryptor encryptor; | //private Encryptor encryptor; | ||||
Socket listener; | |||||
Socket _listener; | |||||
public Local(Server config) | public Local(Server config) | ||||
{ | { | ||||
this.config = config; | this.config = config; | ||||
@@ -25,24 +25,24 @@ namespace Shadowsocks.Controller | |||||
try | try | ||||
{ | { | ||||
// Create a TCP/IP socket. | // Create a TCP/IP socket. | ||||
listener = new Socket(AddressFamily.InterNetwork, | |||||
_listener = new Socket(AddressFamily.InterNetwork, | |||||
SocketType.Stream, ProtocolType.Tcp); | SocketType.Stream, ProtocolType.Tcp); | ||||
IPEndPoint localEndPoint = new IPEndPoint(0, config.local_port); | IPEndPoint localEndPoint = new IPEndPoint(0, config.local_port); | ||||
// Bind the socket to the local endpoint and listen for incoming connections. | // Bind the socket to the local endpoint and listen for incoming connections. | ||||
listener.Bind(localEndPoint); | |||||
listener.Listen(100); | |||||
_listener.Bind(localEndPoint); | |||||
_listener.Listen(100); | |||||
// Start an asynchronous socket to listen for connections. | // Start an asynchronous socket to listen for connections. | ||||
Console.WriteLine("Shadowsocks started"); | Console.WriteLine("Shadowsocks started"); | ||||
listener.BeginAccept( | |||||
_listener.BeginAccept( | |||||
new AsyncCallback(AcceptCallback), | new AsyncCallback(AcceptCallback), | ||||
listener); | |||||
_listener); | |||||
} | } | ||||
catch(SocketException) | catch(SocketException) | ||||
{ | { | ||||
listener.Close(); | |||||
_listener.Close(); | |||||
throw; | throw; | ||||
} | } | ||||
@@ -50,7 +50,7 @@ namespace Shadowsocks.Controller | |||||
public void Stop() | public void Stop() | ||||
{ | { | ||||
listener.Close(); | |||||
_listener.Close(); | |||||
} | } | ||||
@@ -90,7 +90,7 @@ namespace Shadowsocks.Controller | |||||
//handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, | //handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, | ||||
// new AsyncCallback(ReadCallback), state); | // new AsyncCallback(ReadCallback), state); | ||||
} | } | ||||
catch (Exception) | |||||
catch | |||||
{ | { | ||||
//Console.WriteLine(e.Message); | //Console.WriteLine(e.Message); | ||||
} | } | ||||
@@ -141,7 +141,7 @@ namespace Shadowsocks.Controller | |||||
// Connect to the remote endpoint. | // Connect to the remote endpoint. | ||||
remote.BeginConnect(remoteEP, | remote.BeginConnect(remoteEP, | ||||
new AsyncCallback(connectCallback), null); | |||||
new AsyncCallback(ConnectCallback), null); | |||||
} | } | ||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
@@ -182,7 +182,7 @@ namespace Shadowsocks.Controller | |||||
((IDisposable)encryptor).Dispose(); | ((IDisposable)encryptor).Dispose(); | ||||
} | } | ||||
private void connectCallback(IAsyncResult ar) | |||||
private void ConnectCallback(IAsyncResult ar) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -192,7 +192,7 @@ namespace Shadowsocks.Controller | |||||
//Console.WriteLine("Socket connected to {0}", | //Console.WriteLine("Socket connected to {0}", | ||||
// remote.RemoteEndPoint.ToString()); | // remote.RemoteEndPoint.ToString()); | ||||
handshakeReceive(); | |||||
HandshakeReceive(); | |||||
} | } | ||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
@@ -201,12 +201,12 @@ namespace Shadowsocks.Controller | |||||
} | } | ||||
} | } | ||||
private void handshakeReceive() | |||||
private void HandshakeReceive() | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
connection.BeginReceive(connetionRecvBuffer, 0, 256, 0, | connection.BeginReceive(connetionRecvBuffer, 0, 256, 0, | ||||
new AsyncCallback(handshakeReceiveCallback), null); | |||||
new AsyncCallback(HandshakeReceiveCallback), null); | |||||
} | } | ||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
@@ -215,7 +215,7 @@ namespace Shadowsocks.Controller | |||||
} | } | ||||
} | } | ||||
private void handshakeReceiveCallback(IAsyncResult ar) | |||||
private void HandshakeReceiveCallback(IAsyncResult ar) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -33,7 +33,7 @@ namespace Shadowsocks.Controller | |||||
new AsyncCallback(AcceptCallback), | new AsyncCallback(AcceptCallback), | ||||
listener); | listener); | ||||
watchPACFile(); | |||||
WatchPacFile(); | |||||
} | } | ||||
public string TouchPACFile() | public string TouchPACFile() | ||||
@@ -61,7 +61,7 @@ namespace Shadowsocks.Controller | |||||
Socket conn = listener.EndAccept(ar); | Socket conn = listener.EndAccept(ar); | ||||
conn.BeginReceive(new byte[1024], 0, 1024, 0, | conn.BeginReceive(new byte[1024], 0, 1024, 0, | ||||
new AsyncCallback(receiveCallback), conn); | |||||
new AsyncCallback(ReceiveCallback), conn); | |||||
} | } | ||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
@@ -69,7 +69,7 @@ namespace Shadowsocks.Controller | |||||
} | } | ||||
} | } | ||||
private string getPACContent() | |||||
private string GetPACContent() | |||||
{ | { | ||||
if (File.Exists(PAC_FILE)) | if (File.Exists(PAC_FILE)) | ||||
{ | { | ||||
@@ -92,17 +92,17 @@ namespace Shadowsocks.Controller | |||||
return System.Text.Encoding.UTF8.GetString(buffer, 0, n); | return System.Text.Encoding.UTF8.GetString(buffer, 0, n); | ||||
} | } | ||||
} | } | ||||
watchPACFile(); | |||||
WatchPacFile(); | |||||
} | } | ||||
private void receiveCallback(IAsyncResult ar) | |||||
private void ReceiveCallback(IAsyncResult ar) | |||||
{ | { | ||||
Socket conn = (Socket)ar.AsyncState; | Socket conn = (Socket)ar.AsyncState; | ||||
try | try | ||||
{ | { | ||||
int bytesRead = conn.EndReceive(ar); | int bytesRead = conn.EndReceive(ar); | ||||
string pac = getPACContent(); | |||||
string pac = GetPACContent(); | |||||
string proxy = "PROXY 127.0.0.1:8123;"; | string proxy = "PROXY 127.0.0.1:8123;"; | ||||
@@ -118,7 +118,7 @@ Connection: Close | |||||
", System.Text.Encoding.UTF8.GetBytes(pac).Length) + pac; | ", System.Text.Encoding.UTF8.GetBytes(pac).Length) + pac; | ||||
byte[] response = System.Text.Encoding.UTF8.GetBytes(text); | byte[] response = System.Text.Encoding.UTF8.GetBytes(text); | ||||
conn.BeginSend(response, 0, response.Length, 0, new AsyncCallback(sendCallback), conn); | |||||
conn.BeginSend(response, 0, response.Length, 0, new AsyncCallback(SendCallback), conn); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -132,13 +132,13 @@ Connection: Close | |||||
} | } | ||||
} | } | ||||
private void sendCallback(IAsyncResult ar) | |||||
private void SendCallback(IAsyncResult ar) | |||||
{ | { | ||||
Socket conn = (Socket)ar.AsyncState; | Socket conn = (Socket)ar.AsyncState; | ||||
conn.Shutdown(SocketShutdown.Send); | conn.Shutdown(SocketShutdown.Send); | ||||
} | } | ||||
private void watchPACFile() | |||||
private void WatchPacFile() | |||||
{ | { | ||||
if (watcher != null) | if (watcher != null) | ||||
{ | { | ||||
@@ -147,14 +147,14 @@ Connection: Close | |||||
watcher = new FileSystemWatcher(Directory.GetCurrentDirectory()); | watcher = new FileSystemWatcher(Directory.GetCurrentDirectory()); | ||||
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; | watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; | ||||
watcher.Filter = PAC_FILE; | watcher.Filter = PAC_FILE; | ||||
watcher.Changed += watcher_Changed; | |||||
watcher.Created += watcher_Changed; | |||||
watcher.Deleted += watcher_Changed; | |||||
watcher.Renamed += watcher_Changed; | |||||
watcher.Changed += Watcher_Changed; | |||||
watcher.Created += Watcher_Changed; | |||||
watcher.Deleted += Watcher_Changed; | |||||
watcher.Renamed += Watcher_Changed; | |||||
watcher.EnableRaisingEvents = true; | watcher.EnableRaisingEvents = true; | ||||
} | } | ||||
void watcher_Changed(object sender, FileSystemEventArgs e) | |||||
private void Watcher_Changed(object sender, FileSystemEventArgs e) | |||||
{ | { | ||||
if (PACFileChanged != null) | if (PACFileChanged != null) | ||||
{ | { | ||||
@@ -11,11 +11,11 @@ namespace Shadowsocks.Controller | |||||
{ | { | ||||
class PolipoRunner | class PolipoRunner | ||||
{ | { | ||||
private Process process; | |||||
private Process _process; | |||||
public void Start(Server config) | public void Start(Server config) | ||||
{ | { | ||||
if (process == null) | |||||
if (_process == null) | |||||
{ | { | ||||
Process[] existingPolipo = Process.GetProcessesByName("ss_polipo"); | Process[] existingPolipo = Process.GetProcessesByName("ss_polipo"); | ||||
foreach (Process p in existingPolipo) | foreach (Process p in existingPolipo) | ||||
@@ -36,34 +36,34 @@ namespace Shadowsocks.Controller | |||||
FileManager.ByteArrayToFile(temppath + "/polipo.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig)); | FileManager.ByteArrayToFile(temppath + "/polipo.conf", System.Text.Encoding.UTF8.GetBytes(polipoConfig)); | ||||
FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe); | FileManager.UncompressFile(temppath + "/ss_polipo.exe", Resources.polipo_exe); | ||||
process = new Process(); | |||||
_process = new Process(); | |||||
// Configure the process using the StartInfo properties. | // Configure the process using the StartInfo properties. | ||||
process.StartInfo.FileName = temppath + "/ss_polipo.exe"; | |||||
process.StartInfo.Arguments = "-c \"" + temppath + "/polipo.conf\""; | |||||
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | |||||
process.StartInfo.UseShellExecute = false; | |||||
process.StartInfo.CreateNoWindow = true; | |||||
process.StartInfo.RedirectStandardOutput = true; | |||||
process.StartInfo.RedirectStandardError = true; | |||||
_process.StartInfo.FileName = temppath + "/ss_polipo.exe"; | |||||
_process.StartInfo.Arguments = "-c \"" + temppath + "/polipo.conf\""; | |||||
_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | |||||
_process.StartInfo.UseShellExecute = false; | |||||
_process.StartInfo.CreateNoWindow = true; | |||||
_process.StartInfo.RedirectStandardOutput = true; | |||||
_process.StartInfo.RedirectStandardError = true; | |||||
//process.StandardOutput | //process.StandardOutput | ||||
process.Start(); | |||||
_process.Start(); | |||||
} | } | ||||
} | } | ||||
public void Stop() | public void Stop() | ||||
{ | { | ||||
if (process != null) | |||||
if (_process != null) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
process.Kill(); | |||||
process.WaitForExit(); | |||||
_process.Kill(); | |||||
_process.WaitForExit(); | |||||
} | } | ||||
catch (InvalidOperationException) | catch (InvalidOperationException) | ||||
{ | { | ||||
// do nothing | // do nothing | ||||
} | } | ||||
process = null; | |||||
_process = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -14,7 +14,7 @@ namespace Shadowsocks.Controller | |||||
private Local local; | private Local local; | ||||
private PACServer pacServer; | private PACServer pacServer; | ||||
private Configuration config; | |||||
private Configuration _config; | |||||
private PolipoRunner polipoRunner; | private PolipoRunner polipoRunner; | ||||
private bool stopped = false; | private bool stopped = false; | ||||
@@ -31,10 +31,10 @@ namespace Shadowsocks.Controller | |||||
public ShadowsocksController() | public ShadowsocksController() | ||||
{ | { | ||||
config = Configuration.Load(); | |||||
_config = Configuration.Load(); | |||||
polipoRunner = new PolipoRunner(); | polipoRunner = new PolipoRunner(); | ||||
polipoRunner.Start(config.GetCurrentServer()); | |||||
local = new Local(config.GetCurrentServer()); | |||||
polipoRunner.Start(_config.GetCurrentServer()); | |||||
local = new Local(_config.GetCurrentServer()); | |||||
try | try | ||||
{ | { | ||||
local.Start(); | local.Start(); | ||||
@@ -47,20 +47,20 @@ namespace Shadowsocks.Controller | |||||
Console.WriteLine(e.Message); | Console.WriteLine(e.Message); | ||||
} | } | ||||
updateSystemProxy(); | |||||
UpdateSystemProxy(); | |||||
} | } | ||||
public void SaveConfig(Configuration newConfig) | public void SaveConfig(Configuration newConfig) | ||||
{ | { | ||||
Configuration.Save(newConfig); | Configuration.Save(newConfig); | ||||
// some logic in configuration updated the config when saving, we need to read it again | // some logic in configuration updated the config when saving, we need to read it again | ||||
config = Configuration.Load(); | |||||
_config = Configuration.Load(); | |||||
local.Stop(); | local.Stop(); | ||||
polipoRunner.Stop(); | polipoRunner.Stop(); | ||||
polipoRunner.Start(config.GetCurrentServer()); | |||||
polipoRunner.Start(_config.GetCurrentServer()); | |||||
local = new Local(config.GetCurrentServer()); | |||||
local = new Local(_config.GetCurrentServer()); | |||||
local.Start(); | local.Start(); | ||||
if (ConfigChanged != null) | if (ConfigChanged != null) | ||||
@@ -71,7 +71,7 @@ namespace Shadowsocks.Controller | |||||
public Server GetCurrentServer() | public Server GetCurrentServer() | ||||
{ | { | ||||
return config.GetCurrentServer(); | |||||
return _config.GetCurrentServer(); | |||||
} | } | ||||
// always return copy | // always return copy | ||||
@@ -83,9 +83,9 @@ namespace Shadowsocks.Controller | |||||
public void ToggleEnable(bool enabled) | public void ToggleEnable(bool enabled) | ||||
{ | { | ||||
config.enabled = enabled; | |||||
updateSystemProxy(); | |||||
SaveConfig(config); | |||||
_config.enabled = enabled; | |||||
UpdateSystemProxy(); | |||||
SaveConfig(_config); | |||||
if (EnableStatusChanged != null) | if (EnableStatusChanged != null) | ||||
{ | { | ||||
EnableStatusChanged(this, new EventArgs()); | EnableStatusChanged(this, new EventArgs()); | ||||
@@ -101,7 +101,7 @@ namespace Shadowsocks.Controller | |||||
stopped = true; | stopped = true; | ||||
local.Stop(); | local.Stop(); | ||||
polipoRunner.Stop(); | polipoRunner.Stop(); | ||||
if (config.enabled) | |||||
if (_config.enabled) | |||||
{ | { | ||||
SystemProxy.Disable(); | SystemProxy.Disable(); | ||||
} | } | ||||
@@ -124,9 +124,9 @@ namespace Shadowsocks.Controller | |||||
return "ss://" + base64; | return "ss://" + base64; | ||||
} | } | ||||
private void updateSystemProxy() | |||||
private void UpdateSystemProxy() | |||||
{ | { | ||||
if (config.enabled) | |||||
if (_config.enabled) | |||||
{ | { | ||||
SystemProxy.Enable(); | SystemProxy.Enable(); | ||||
} | } | ||||
@@ -138,7 +138,7 @@ namespace Shadowsocks.Controller | |||||
private void pacServer_PACFileChanged(object sender, EventArgs e) | private void pacServer_PACFileChanged(object sender, EventArgs e) | ||||
{ | { | ||||
updateSystemProxy(); | |||||
UpdateSystemProxy(); | |||||
} | } | ||||
} | } | ||||
@@ -1,16 +1,16 @@ | |||||
| | ||||
namespace Shadowsocks.Encrypt | |||||
{ | |||||
public static class EncryptorFactory | |||||
{ | |||||
public static IEncryptor GetEncryptor(string method, string password) | |||||
{ | |||||
if (string.IsNullOrEmpty(method) || method.ToLowerInvariant() == "table") | |||||
{ | |||||
return new TableEncryptor(method, password); | |||||
} | |||||
return new PolarSSLEncryptor(method, password); | |||||
} | |||||
} | |||||
} | |||||
namespace Shadowsocks.Encrypt | |||||
{ | |||||
public static class EncryptorFactory | |||||
{ | |||||
public static IEncryptor GetEncryptor(string method, string password) | |||||
{ | |||||
if (string.IsNullOrEmpty(method) || method.ToLowerInvariant() == "table") | |||||
{ | |||||
return new TableEncryptor(method, password); | |||||
} | |||||
return new PolarSSLEncryptor(method, password); | |||||
} | |||||
} | |||||
} |
@@ -33,11 +33,11 @@ namespace Shadowsocks.Model | |||||
public static void CheckServer(Server server) | public static void CheckServer(Server server) | ||||
{ | { | ||||
checkPort(server.local_port); | |||||
checkPort(server.server_port); | |||||
checkPassword(server.password); | |||||
checkServer(server.server); | |||||
checkRemark(server.remarks); | |||||
CheckPort(server.local_port); | |||||
CheckPort(server.server_port); | |||||
CheckPassword(server.password); | |||||
CheckServer(server.server); | |||||
CheckRemark(server.remarks); | |||||
} | } | ||||
public static Configuration Load() | public static Configuration Load() | ||||
@@ -106,7 +106,7 @@ namespace Shadowsocks.Model | |||||
}; | }; | ||||
} | } | ||||
private static void assert(bool condition) | |||||
private static void Assert(bool condition) | |||||
{ | { | ||||
if (!condition) | if (!condition) | ||||
{ | { | ||||
@@ -114,7 +114,7 @@ namespace Shadowsocks.Model | |||||
} | } | ||||
} | } | ||||
private static void checkPort(int port) | |||||
private static void CheckPort(int port) | |||||
{ | { | ||||
if (port <= 0 || port > 65535) | if (port <= 0 || port > 65535) | ||||
{ | { | ||||
@@ -122,7 +122,7 @@ namespace Shadowsocks.Model | |||||
} | } | ||||
} | } | ||||
private static void checkPassword(string password) | |||||
private static void CheckPassword(string password) | |||||
{ | { | ||||
if (string.IsNullOrEmpty(password)) | if (string.IsNullOrEmpty(password)) | ||||
{ | { | ||||
@@ -130,7 +130,7 @@ namespace Shadowsocks.Model | |||||
} | } | ||||
} | } | ||||
private static void checkServer(string server) | |||||
private static void CheckServer(string server) | |||||
{ | { | ||||
if (string.IsNullOrEmpty(server)) | if (string.IsNullOrEmpty(server)) | ||||
{ | { | ||||
@@ -138,7 +138,7 @@ namespace Shadowsocks.Model | |||||
} | } | ||||
} | } | ||||
private static void checkRemark(string remark) | |||||
private static void CheckRemark(string remark) | |||||
{ | { | ||||
//remark is optional | //remark is optional | ||||
} | } | ||||
@@ -29,12 +29,12 @@ namespace Shadowsocks.View | |||||
controller.ConfigChanged += controller_ConfigChanged; | controller.ConfigChanged += controller_ConfigChanged; | ||||
controller.PACFileReadyToOpen += controller_PACFileReadyToOpen; | controller.PACFileReadyToOpen += controller_PACFileReadyToOpen; | ||||
loadCurrentConfiguration(); | |||||
LoadCurrentConfiguration(); | |||||
} | } | ||||
private void controller_ConfigChanged(object sender, EventArgs e) | private void controller_ConfigChanged(object sender, EventArgs e) | ||||
{ | { | ||||
loadCurrentConfiguration(); | |||||
LoadCurrentConfiguration(); | |||||
} | } | ||||
private void controller_EnableStatusChanged(object sender, EventArgs e) | private void controller_EnableStatusChanged(object sender, EventArgs e) | ||||
@@ -50,14 +50,14 @@ namespace Shadowsocks.View | |||||
} | } | ||||
private void showWindow() | |||||
private void ShowWindow() | |||||
{ | { | ||||
this.Opacity = 1; | this.Opacity = 1; | ||||
this.Show(); | this.Show(); | ||||
IPTextBox.Focus(); | IPTextBox.Focus(); | ||||
} | } | ||||
private bool saveOldSelectedServer() | |||||
private bool SaveOldSelectedServer() | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -89,7 +89,7 @@ namespace Shadowsocks.View | |||||
return false; | return false; | ||||
} | } | ||||
private void loadSelectedServer() | |||||
private void LoadSelectedServer() | |||||
{ | { | ||||
if (ServersListBox.SelectedIndex >= 0 && ServersListBox.SelectedIndex < modifiedConfiguration.configs.Count) | if (ServersListBox.SelectedIndex >= 0 && ServersListBox.SelectedIndex < modifiedConfiguration.configs.Count) | ||||
{ | { | ||||
@@ -110,7 +110,7 @@ namespace Shadowsocks.View | |||||
} | } | ||||
} | } | ||||
private void loadConfiguration(Configuration configuration) | |||||
private void LoadConfiguration(Configuration configuration) | |||||
{ | { | ||||
ServersListBox.Items.Clear(); | ServersListBox.Items.Clear(); | ||||
foreach (Server server in modifiedConfiguration.configs) | foreach (Server server in modifiedConfiguration.configs) | ||||
@@ -119,19 +119,19 @@ namespace Shadowsocks.View | |||||
} | } | ||||
} | } | ||||
private void loadCurrentConfiguration() | |||||
private void LoadCurrentConfiguration() | |||||
{ | { | ||||
modifiedConfiguration = controller.GetConfiguration(); | modifiedConfiguration = controller.GetConfiguration(); | ||||
loadConfiguration(modifiedConfiguration); | |||||
LoadConfiguration(modifiedConfiguration); | |||||
oldSelectedIndex = modifiedConfiguration.index; | oldSelectedIndex = modifiedConfiguration.index; | ||||
ServersListBox.SelectedIndex = modifiedConfiguration.index; | ServersListBox.SelectedIndex = modifiedConfiguration.index; | ||||
loadSelectedServer(); | |||||
LoadSelectedServer(); | |||||
updateServersMenu(); | |||||
UpdateServersMenu(); | |||||
enableItem.Checked = modifiedConfiguration.enabled; | enableItem.Checked = modifiedConfiguration.enabled; | ||||
} | } | ||||
private void updateServersMenu() | |||||
private void UpdateServersMenu() | |||||
{ | { | ||||
var items = ServersItem.MenuItems; | var items = ServersItem.MenuItems; | ||||
@@ -178,25 +178,25 @@ namespace Shadowsocks.View | |||||
// we are moving back to oldSelectedIndex or doing a force move | // we are moving back to oldSelectedIndex or doing a force move | ||||
return; | return; | ||||
} | } | ||||
if (!saveOldSelectedServer()) | |||||
if (!SaveOldSelectedServer()) | |||||
{ | { | ||||
// why this won't cause stack overflow? | // why this won't cause stack overflow? | ||||
ServersListBox.SelectedIndex = oldSelectedIndex; | ServersListBox.SelectedIndex = oldSelectedIndex; | ||||
return; | return; | ||||
} | } | ||||
loadSelectedServer(); | |||||
LoadSelectedServer(); | |||||
oldSelectedIndex = ServersListBox.SelectedIndex; | oldSelectedIndex = ServersListBox.SelectedIndex; | ||||
} | } | ||||
private void AddButton_Click(object sender, EventArgs e) | private void AddButton_Click(object sender, EventArgs e) | ||||
{ | { | ||||
if (!saveOldSelectedServer()) | |||||
if (!SaveOldSelectedServer()) | |||||
{ | { | ||||
return; | return; | ||||
} | } | ||||
Server server = Configuration.GetDefaultServer(); | Server server = Configuration.GetDefaultServer(); | ||||
modifiedConfiguration.configs.Add(server); | modifiedConfiguration.configs.Add(server); | ||||
loadConfiguration(modifiedConfiguration); | |||||
LoadConfiguration(modifiedConfiguration); | |||||
ServersListBox.SelectedIndex = modifiedConfiguration.configs.Count - 1; | ServersListBox.SelectedIndex = modifiedConfiguration.configs.Count - 1; | ||||
oldSelectedIndex = ServersListBox.SelectedIndex; | oldSelectedIndex = ServersListBox.SelectedIndex; | ||||
} | } | ||||
@@ -214,14 +214,14 @@ namespace Shadowsocks.View | |||||
oldSelectedIndex = modifiedConfiguration.configs.Count - 1; | oldSelectedIndex = modifiedConfiguration.configs.Count - 1; | ||||
} | } | ||||
ServersListBox.SelectedIndex = oldSelectedIndex; | ServersListBox.SelectedIndex = oldSelectedIndex; | ||||
loadConfiguration(modifiedConfiguration); | |||||
LoadConfiguration(modifiedConfiguration); | |||||
ServersListBox.SelectedIndex = oldSelectedIndex; | ServersListBox.SelectedIndex = oldSelectedIndex; | ||||
loadSelectedServer(); | |||||
LoadSelectedServer(); | |||||
} | } | ||||
private void Config_Click(object sender, EventArgs e) | private void Config_Click(object sender, EventArgs e) | ||||
{ | { | ||||
showWindow(); | |||||
ShowWindow(); | |||||
} | } | ||||
private void Quit_Click(object sender, EventArgs e) | private void Quit_Click(object sender, EventArgs e) | ||||
@@ -229,7 +229,7 @@ namespace Shadowsocks.View | |||||
this.Close(); | this.Close(); | ||||
} | } | ||||
private void showFirstTimeBalloon() | |||||
private void ShowFirstTimeBalloon() | |||||
{ | { | ||||
if (isFirstRun) | if (isFirstRun) | ||||
{ | { | ||||
@@ -242,7 +242,7 @@ namespace Shadowsocks.View | |||||
private void OKButton_Click(object sender, EventArgs e) | private void OKButton_Click(object sender, EventArgs e) | ||||
{ | { | ||||
if (!saveOldSelectedServer()) | |||||
if (!SaveOldSelectedServer()) | |||||
{ | { | ||||
return; | return; | ||||
} | } | ||||
@@ -253,14 +253,14 @@ namespace Shadowsocks.View | |||||
} | } | ||||
controller.SaveConfig(modifiedConfiguration); | controller.SaveConfig(modifiedConfiguration); | ||||
this.Hide(); | this.Hide(); | ||||
showFirstTimeBalloon(); | |||||
ShowFirstTimeBalloon(); | |||||
} | } | ||||
private void CancelButton_Click(object sender, EventArgs e) | private void CancelButton_Click(object sender, EventArgs e) | ||||
{ | { | ||||
this.Hide(); | this.Hide(); | ||||
loadCurrentConfiguration(); | |||||
showFirstTimeBalloon(); | |||||
LoadCurrentConfiguration(); | |||||
ShowFirstTimeBalloon(); | |||||
} | } | ||||
private void ConfigForm_FormClosed(object sender, FormClosedEventArgs e) | private void ConfigForm_FormClosed(object sender, FormClosedEventArgs e) | ||||
@@ -275,7 +275,7 @@ namespace Shadowsocks.View | |||||
private void notifyIcon1_DoubleClick(object sender, EventArgs e) | private void notifyIcon1_DoubleClick(object sender, EventArgs e) | ||||
{ | { | ||||
showWindow(); | |||||
ShowWindow(); | |||||
} | } | ||||