private async void barButtonAdd_ItemClick(object sender, ItemClickEventArgs e) { try { if (applicationControl != null) { await applicationControl.NewItemButtonClicked(); } else { SettingsApplication newApplication = new SettingsApplication(); ApplicationEditForm form = new ApplicationEditForm(newApplication, settingsManager); if (form.ShowDialog() == DialogResult.OK) { if (await settingsManager.CreateApplicationAsync(newApplication.Name, newApplication.Description)) { await GetApplications(); } } } } catch (SettingsException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async Task<bool> ValidateInputAsync() { if (string.IsNullOrWhiteSpace(textName.Text)) { textName.ErrorText = "Enter a Name"; return false; } else { if (application == null) { application = new SettingsApplication(); } if (!string.Equals(application.Name, textName.Text, StringComparison.CurrentCultureIgnoreCase) && await settingsManager.ApplicationExists(textName.Text)) { textName.ErrorText = "Application name already in use."; return false; } application.Name = textName.Text.Trim().Replace(" ", " "); application.Description = textDescription.Text.Trim().Replace(" ", " "); return true; } }
public ApplicationEditForm(SettingsApplication application, SettingsAPIClient.SettingsManager settingsManager) { InitializeComponent(); this.settingsManager = settingsManager; this.application = application; if(application != null) { textName.Text = application.Name; textDescription.Text = application.Description; } }
public async Task CreateApplicationMasterAsync() { settingsManager = new SettingsManager(_url, _masterKey); string applicationName = Util.RandomString(); string description = Util.RandomString(); await settingsManager.CreateApplicationAsync(applicationName, description); currentApplication = await settingsManager.GetApplication(applicationName); Assert.AreEqual(currentApplication.Name, applicationName); Assert.AreEqual(currentApplication.Description, description); currentApplicationName = currentApplication.Name; }
private async Task GetApplication(string applicationName) { try { OnShowProgress(); Application = await settingsManager.GetApplication(applicationName); this.CurrentVersion = Application.Versions.OrderByDescending(v => v.Created).First(); directoryBinding = new BindingList<SettingsDirectory>(Application.Directories); gridControlDirectories.DataSource = directoryBinding; } finally { OnHideProgress(); } }
private async void barButtonItemEdit_ItemClick(object sender, ItemClickEventArgs e) { try { if (applicationControl == null) { var application = gridViewApplications.GetRow(gridViewApplications.FocusedRowHandle) as SettingsApplication; if (application != null) { SettingsApplication editApplication = new SettingsApplication(); editApplication.Name = application.Name; editApplication.Description = application.Description; ApplicationEditForm form = new ApplicationEditForm(editApplication, settingsManager); if (form.ShowDialog() == DialogResult.OK) { if (await settingsManager.UpdateApplicationAsync(application.Name, editApplication.Name, editApplication.Description)) { application.Name = editApplication.Name; application.Description = editApplication.Description; } } } } else { await applicationControl.EditButtonClicked(); } } catch (SettingsException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async Task LoadApplication() { application = await settingsManager.GetApplication(applicationName); highVersion = application.Versions.Max(v => v.Version); gridControlVersions.DataSource = application.Versions; }
public async Task DeleteApplicationVersionMasterAsync() { await CreateApplicationVersionMasterAsync(); try { Assert.IsTrue(currentApplication.Versions.Count == 2); bool isDeleted = await settingsManager.DeleteApplicationVersionAsync(currentApplicationName, 2); currentApplication = await settingsManager.GetApplication(currentApplicationName); Assert.IsTrue(currentApplication.Versions.Count == 1); Assert.IsTrue(isDeleted); } catch (SettingsException ex) { Assert.Fail(ex.Message); } }