提交 7d055604 authored 作者: Mitch Capper's avatar Mitch Capper

Make accounts default to 0 last rather than after 1, add a proper remove…

Make accounts default to 0 last rather than after 1,  add a proper remove account function and kill it out of sofia first, don't add a new account if a user clicks cancel.
上级 9c4002cb
...@@ -125,7 +125,11 @@ namespace FSClient { ...@@ -125,7 +125,11 @@ namespace FSClient {
account.guid = ""; account.guid = "";
account.guid = old_guid; account.guid = old_guid;
} }
public static void RemoveAccount(Account account){
account.KillGateway();
accounts.Remove(account);
ReloadSofia();
}
public static void create_gateway_nodes(XmlNode gateways_node) { public static void create_gateway_nodes(XmlNode gateways_node) {
foreach (Account account in accounts) { foreach (Account account in accounts) {
...@@ -170,9 +174,10 @@ namespace FSClient { ...@@ -170,9 +174,10 @@ namespace FSClient {
_guid.PropertyChanged += (s, e) => { _guid.PropertyChanged += (s, e) => {
if (!guid_ok(this, _guid.value) || String.IsNullOrEmpty(_guid.value)) { if (!guid_ok(this, _guid.value) || String.IsNullOrEmpty(_guid.value)) {
for (int i = 0; i < 10; i++) { for (int i = 1; i <= 10; i++){
if (guid_ok(this, i.ToString())) { int val = i == 10 ? 0 : i; // want 0 checked last.
_guid.value = i.ToString(); if (guid_ok(this, val.ToString())) {
_guid.value = val.ToString();
return; return;
} }
} }
...@@ -329,13 +334,16 @@ namespace FSClient { ...@@ -329,13 +334,16 @@ namespace FSClient {
KillGateway(); KillGateway();
ReloadSofia(); ReloadSofia();
} }
public void edit() { public bool edit() {
current_editing_account = this; current_editing_account = this;
GenericEditor editor = new GenericEditor(); GenericEditor editor = new GenericEditor();
editor.Init("Editing Account", values); editor.Init("Editing Account", values);
editor.ShowDialog(); editor.ShowDialog();
if (editor.DialogResult == true) if (editor.DialogResult == true)
ReloadAccount(); ReloadAccount();
else
return false;
return true;
} }
} }
} }
...@@ -228,7 +228,7 @@ namespace FSClient { ...@@ -228,7 +228,7 @@ namespace FSClient {
} }
public void DialString(String str){ public void DialString(String str){
if (string.IsNullOrWhiteSpace(str)) if (string.IsNullOrWhiteSpace(str))
return; return;
MainWindowRemoveFocus(true); MainWindowRemoveFocus(true);
if (str.StartsWith("#") && str.Length > 2) { if (str.StartsWith("#") && str.Length > 2) {
...@@ -572,8 +572,8 @@ namespace FSClient { ...@@ -572,8 +572,8 @@ namespace FSClient {
public OurAutoCompleteBox GetContactSearchBox() { public OurAutoCompleteBox GetContactSearchBox() {
return MainWindow.get_instance().GetContactSearchBox(); return MainWindow.get_instance().GetContactSearchBox();
} }
public void MainWindowRemoveFocus(bool ResetContactSearchText=false){ public void MainWindowRemoveFocus(bool ResetContactSearchText=false){
MainWindow.get_instance().RemoveFocus(ResetContactSearchText); MainWindow.get_instance().RemoveFocus(ResetContactSearchText);
} }
private delegate void BroadcastEventDel(FSEvent evt); private delegate void BroadcastEventDel(FSEvent evt);
BroadcastEventDel BroadcastHandler; BroadcastEventDel BroadcastHandler;
......
...@@ -365,7 +365,8 @@ namespace FSClient { ...@@ -365,7 +365,8 @@ namespace FSClient {
private void AccountNew_Click(object sender, RoutedEventArgs e) { private void AccountNew_Click(object sender, RoutedEventArgs e) {
Account acct = new Account(); Account acct = new Account();
Account.AddAccount(acct); Account.AddAccount(acct);
acct.edit(); if (!acct.edit())
Account.RemoveAccount(acct);
} }
...@@ -387,7 +388,7 @@ namespace FSClient { ...@@ -387,7 +388,7 @@ namespace FSClient {
Account acct = gridAccounts.SelectedItem as Account; Account acct = gridAccounts.SelectedItem as Account;
if (acct == null) if (acct == null)
return; return;
Account.accounts.Remove(acct); Account.RemoveAccount(acct);
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论