Added duplicate button to config form.

This commit is contained in:
Logan Zhou
2016-09-18 00:43:45 +08:00
parent 50b601c6e5
commit 333ccb6d1f
5 changed files with 60 additions and 9 deletions
+20
View File
@@ -42,6 +42,7 @@ namespace Shadowsocks.View
{
AddButton.Text = I18N.GetString("&Add");
DeleteButton.Text = I18N.GetString("&Delete");
DuplicateButton.Text = I18N.GetString("Dupli&cate");
IPLabel.Text = I18N.GetString("Server Addr");
ServerPortLabel.Text = I18N.GetString("Server Port");
PasswordLabel.Text = I18N.GetString("Password");
@@ -327,5 +328,24 @@ namespace Shadowsocks.View
MoveConfigItem(+1); // +1 means move forward
}
}
private void Duplicate_Click(object sender, EventArgs e)
{
if (!SaveOldSelectedServer())
{
return;
}
if (ServersListBox.SelectedIndex >= 0 && ServersListBox.SelectedIndex < _modifiedConfiguration.configs.Count)
{
Server selectedServer = _modifiedConfiguration.configs[ServersListBox.SelectedIndex];
Server clone = (Server)selectedServer.Clone();
_modifiedConfiguration.configs.Add(clone);
LoadConfiguration(_modifiedConfiguration);
ServersListBox.SelectedIndex = _modifiedConfiguration.configs.Count - 1;
_lastSelectedIndex = ServersListBox.SelectedIndex;
}
}
}
}