private void btnDelete_Click(object sender, EventArgs e) { CustomFieldDefinition customFieldDefinition = lbCustomFields.SelectedItem as CustomFieldDefinition; if (customFieldDefinition == null) { return; } string name = customFieldDefinition.Name.Ellipsise(50); if (!MainWindow.Confirm(connection, Program.MainWindow, Messages.MESSAGEBOX_CONFIRM, Messages.MESSAGEBOX_DELETE_CUSTOM_FIELD, name)) { return; } int selIdx = lbCustomFields.SelectedIndex; lbCustomFields.Items.RemoveAt(selIdx); DelegatedAsyncAction action = new DelegatedAsyncAction(connection, String.Format(Messages.DELETE_CUSTOM_FIELD, name), String.Format(Messages.DELETING_CUSTOM_FIELD, name), String.Format(Messages.DELETED_CUSTOM_FIELD, name), delegate(Session session) { CustomFieldsManager.RemoveCustomField(session, connection, customFieldDefinition); }); action.RunAsync(); }
private void btnDelete_Click(object sender, EventArgs e) { CustomFieldDefinition customFieldDefinition = lbCustomFields.SelectedItem as CustomFieldDefinition; if (customFieldDefinition == null) { return; } string name = customFieldDefinition.Name.Ellipsise(50); if (!Program.RunInAutomatedTestMode) { using (var dialog = new WarningDialog(string.Format(Messages.MESSAGEBOX_DELETE_CUSTOM_FIELD, name), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo) { WindowTitle = Messages.MESSAGEBOX_CONFIRM }) { if (dialog.ShowDialog(Program.MainWindow) != DialogResult.Yes) { return; } } } if (connection != null && !connection.IsConnected) { MainWindow.ShowDisconnectedMessage(Program.MainWindow); return; } int selIdx = lbCustomFields.SelectedIndex; lbCustomFields.Items.RemoveAt(selIdx); DelegatedAsyncAction action = new DelegatedAsyncAction(connection, String.Format(Messages.DELETE_CUSTOM_FIELD, name), String.Format(Messages.DELETING_CUSTOM_FIELD, name), String.Format(Messages.DELETED_CUSTOM_FIELD, name), delegate(Session session) { CustomFieldsManager.RemoveCustomField(session, connection, customFieldDefinition); }); action.RunAsync(); }