private void ShowNewAccountDialog() { using (var accountForm = new AccountForm(true, accountManager.Accounts.Any())) { if (accountForm.ShowDialog() != DialogResult.OK) { if (!accountManager.Accounts.Any()) { Close(); } return; } btnNewConnection.Visible = false; var info = new AccountInfo { AccountName = accountForm.AccountName, StorageAccessKeyId = accountForm.StorageAccessTokenId, StorageSecretAccessKey = accountForm.StorageSecretAccessKey, StorageVault = accountForm.GlacierVault, StorageRegionSystemName = accountForm.StorageRegionSystemName, }; info.Drives.Clear(); info.Drives.AddRange(accountForm.GetDrives()); accountManager.Add(info); var node = treeView1.Nodes.Add("", info.AccountName, AccountImageKey); node.SelectedImageKey = AccountImageKey; node.Tag = new NodeInfo(info); accountManager.Save(); DisconnectAccount(node); } }
/// <summary> /// Change Account menu item. /// </summary> private async void changeAccountToolStripMenuItem_Click(object sender, EventArgs e) { var node = treeView1.SelectedNode; if (node == null) { return; } using (var accountForm = new AccountForm(false)) { var nodeInfo = ((NodeInfo)node.Tag); var account = accountManager.Get(nodeInfo.AccountInfo.AccountName); accountForm.AccountName = account.AccountName; accountForm.StorageAccessTokenId = account.StorageAccessKeyId; accountForm.StorageSecretAccessKey = account.StorageSecretAccessKey; accountForm.StorageRegionSystemName = account.StorageRegionSystemName; accountForm.GlacierVault = account.StorageVault; accountForm.AddDrives(account.Drives); if (accountForm.ShowDialog() != DialogResult.OK) { return; } account.OldAccountName = accountForm.AccountName == account.AccountName ? null : account.AccountName; account.AccountName = accountForm.AccountName; account.StorageAccessKeyId = accountForm.StorageAccessTokenId; account.StorageSecretAccessKey = accountForm.StorageSecretAccessKey; account.StorageRegionSystemName = accountForm.StorageRegionSystemName; account.StorageVault = accountForm.GlacierVault; node.Text = account.AccountName; node.Tag = new NodeInfo(account); account.Drives.Clear(); account.Drives.AddRange(accountForm.GetDrives()); accountManager.Save(); DisconnectAccount(node); await ConnectAccountAsync(node); } }
/// <summary> /// Change Account menu item. /// </summary> private async void changeAccountToolStripMenuItem_Click(object sender, EventArgs e) { var node = treeView1.SelectedNode; if (node == null) return; using (var accountForm = new AccountForm(false)) { var nodeInfo = ((NodeInfo)node.Tag); var account = accountManager.Get(nodeInfo.AccountInfo.AccountName); accountForm.AccountName = account.AccountName; accountForm.StorageAccessTokenId = account.StorageAccessKeyId; accountForm.StorageSecretAccessKey = account.StorageSecretAccessKey; accountForm.StorageRegionSystemName = account.StorageRegionSystemName; accountForm.GlacierVault = account.StorageVault; accountForm.AddDrives(account.Drives); if (accountForm.ShowDialog() != DialogResult.OK) return; account.OldAccountName = accountForm.AccountName == account.AccountName ? null : account.AccountName; account.AccountName = accountForm.AccountName; account.StorageAccessKeyId = accountForm.StorageAccessTokenId; account.StorageSecretAccessKey = accountForm.StorageSecretAccessKey; account.StorageRegionSystemName = accountForm.StorageRegionSystemName; account.StorageVault = accountForm.GlacierVault; node.Text = account.AccountName; node.Tag = new NodeInfo(account); account.Drives.Clear(); account.Drives.AddRange(accountForm.GetDrives()); accountManager.Save(); DisconnectAccount(node); await ConnectAccountAsync(node); } }
private void addNewAccountToolStripMenuItem_Click(object sender, EventArgs e) { using (var accountForm = new AccountForm(true)) { if (accountForm.ShowDialog() != DialogResult.OK) return; btnNewConnection.Visible = false; var info = new AccountInfo { AccountName = accountForm.AccountName, StorageAccessKeyId = accountForm.StorageAccessTokenId, StorageSecretAccessKey = accountForm.StorageSecretAccessKey, StorageVault = accountForm.GlacierVault, StorageRegionSystemName = accountForm.StorageRegionSystemName, }; info.Drives.Clear(); info.Drives.AddRange(accountForm.GetDrives()); accountManager.Add(info); var node = treeView1.Nodes.Add("", info.AccountName, AccountImageKey); node.SelectedImageKey = AccountImageKey; node.Tag = new NodeInfo(info); accountManager.Save(); DisconnectAccount(node); } }