I have forked a project with the code below:
var pc = ParentSection.GetService<IPendingChangesExt>();
var model = pc.GetType().GetField("m_workItemsSection", BindingFlags.NonPublic | BindingFlags.Instance);
var t = model.FieldType;
var mm = model.GetValue(pc);
var m = t.GetMethod("AddWorkItemById", BindingFlags.NonPublic | BindingFlags.Instance);
m.Invoke(mm, new object[] { selectedWorkItemId });
That adds an work item by its ID to the current pending changes.
Now, I want to link the work items choosing between "Associate" or "Resolve" (associate and resolve), depending on which button the user clicked on plugin's interface as below:

If the user clicks on 'Associate and resolve', the work item should be associated and marked as resolved upon check-in.
If the user clicks on 'Associate only' the work item must be only linked to changeset, but not resolved.
Any help will be welcome