private async Task <KeyValuePair <IDevOpsField, IdentityField> > ManageField(IDevOpsField field, IdentityField identityField) { KeyValuePair <IDevOpsField, IdentityField> result = new KeyValuePair <IDevOpsField, IdentityField>(null, null); var connector = DevOpsManager.GetConnector(_model); if (connector != null) { var fieldsAsync = await connector.GetWorkItemDevOpsFieldsAsync(); var fields = fieldsAsync?.ToArray(); if (fields?.Any() ?? false) { var dialog = new FieldAssociationDialog(); dialog.Initialize(_model, fields); if (field != null && identityField != null) { dialog.SetField(field, identityField); } if (dialog.ShowDialog(this) == DialogResult.OK) { field = dialog.Field; identityField = dialog.IdentityField; if (field != null && identityField != null) { connector.SetWorkItemFieldMapping(field, identityField); DevOpsManager.UpdateConfig(_model); result = new KeyValuePair <IDevOpsField, IdentityField>(field, identityField); } } } } return(result); }
private async void FieldButtonClick(object sender, EventArgs e) { if (sender is GridButtonXEditControl bc && bc.EditorCell is GridCell cell && cell.GridRow is GridRow row && row.Tag is IDevOpsField field && cell.Value is IdentityField identityField) { var connector = DevOpsManager.GetConnector(_model); if (connector != null) { var fieldsAsync = await connector.GetWorkItemDevOpsFieldsAsync(); var fields = fieldsAsync?.ToArray(); if (fields?.Any() ?? false) { var dialog = new FieldAssociationDialog(); dialog.Initialize(_model, fields); dialog.SetField(field, identityField); if (dialog.ShowDialog(this) == DialogResult.OK) { connector.SetWorkItemFieldMapping(field, null); field = dialog.Field; identityField = dialog.IdentityField; if (field != null && identityField != null) { connector.SetWorkItemFieldMapping(field, identityField); row.Cells["Field"].Value = field.Label; cell.Value = identityField; row.Tag = field; } } } } } }