private void ApplicationsEdit() { var application = (AadApplication)applicationsGrid.SelectedRows[0].DataBoundItem; try { if (application.Secret != string.Empty) { application.Secret = EncryptDecrypt.Decrypt(application.Secret); } } catch { application.Secret = string.Empty; MessageBox.Show(Resources.Existing_application_secret_could_not_be_decrypted); } using (AadApplicationForm form = new AadApplicationForm { AadApplication = application }) { var index = Properties.Settings.Default.AadApplications.IndexOf( (AadApplication)applicationsGrid.SelectedRows[0].DataBoundItem); if (form.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.AadApplications.RemoveAt(index); application = form.AadApplication; if ((application != null) && (application.Secret != string.Empty)) { application.Secret = EncryptDecrypt.Encrypt(application.Secret); } Properties.Settings.Default.AadApplications.Insert(index, application); } else { try { application.Secret = EncryptDecrypt.Encrypt(application.Secret); } catch { application.Secret = string.Empty; MessageBox.Show(Resources.Existing_application_secret_could_not_be_encrypted); } } applicationsGrid.Rows[index].Selected = true; } }
private void ApplicationsAddButton_Click(object sender, EventArgs e) { using AadApplicationForm form = new AadApplicationForm(); if (form.ShowDialog() != DialogResult.OK) { return; } var application = form.AadApplication; if ((application != null) && (application.Secret != string.Empty)) { application.Secret = EncryptDecrypt.Encrypt(application.Secret); } Properties.Settings.Default.AadApplications.Add(application); }