private void bEdit_Click(object sender, RoutedEventArgs e) { if (lbAccounts.SelectedItem != null) { Account acc = (Account)lbAccounts.SelectedItem; AccountDialog dialog = new AccountDialog(); dialog.EditAccount(acc); if (dialog.ShowModalDialog()) { //QSTN: Can this copy be done better? acc.Url = dialog.Account.Url; acc.UserName = dialog.Account.UserName; acc.Password = dialog.Account.Password; if (dialog.Account.IsDefault) { Account oldDefault = AccountManager.FindCurrentDefault(); if (oldDefault != null) oldDefault.IsDefault = false; acc.IsDefault = true; } } } }
private void bNew_Click(object sender, RoutedEventArgs e) { var dialog = new AccountDialog(); if (dialog.ShowModalDialog()) { AccountManager.AddNewAccount(dialog.Account); lbAccounts.SelectedIndex = lbAccounts.Items.Count - 1; } }