private void linkDialogLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { NewTagDialog dialog = new NewTagDialog(_tags); if (dialog.ShowDialog() == DialogResult.OK) { _tags = dialog.GetSelectedTags(); UpdateList(); DrawSelf(null, new Rectangle(0, 0, _panel.Width, _panel.Height), false); } }
protected override void ExecuteCore(SelectedItemCollection selection) { List<string> tags = new List<string>(); List<string> indeterminateTags = new List<string>(); Dictionary<IXenObject, List<string>> d = new Dictionary<IXenObject, List<string>>(); foreach (SelectedItem item in selection) { d[item.XenObject] = new List<string>(Tags.GetTags(item.XenObject)); } foreach (string tag in Tags.GetAllTags()) { bool contained = false; bool notContained = false; foreach (IXenObject x in d.Keys) { if (d[x].Contains(tag)) { contained = true; } else { notContained = true; } } if (contained && notContained) { indeterminateTags.Add(tag); } else if (contained) { tags.Add(tag); } } // show dialog modally NewTagDialog newTagDialog = new NewTagDialog(tags, indeterminateTags); if (DialogResult.OK == newTagDialog.ShowDialog(Parent)) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (IXenObject xenObject in selection.AsXenObjects()) { // rebuild tabs lists as tags can be deleted in the dialog. List<string> newTags = new List<string>(Tags.GetTags(xenObject)); for (int i = newTags.Count - 1; i >= 0; i--) { // remove any tags from this xenobject which aren't either checked or indeterminate if (!newTagDialog.GetSelectedTags().Contains(newTags[i]) && !newTagDialog.GetIndeterminateTags().Contains(newTags[i])) { newTags.RemoveAt(i); } } // now add any new tags foreach (string t in newTagDialog.GetSelectedTags()) { if (!newTags.Contains(t)) { newTags.Add(t); } } actions.Add(new GeneralEditPageAction(xenObject, xenObject.Clone(), xenObject.Path, newTags, true)); } RunMultipleActions(actions, Messages.ACTION_SAVING_TAGS_TITLE, Messages.ACTION_SAVING_TAGS_DESCRIPTION, Messages.ACTION_SAVING_TAGS_DESCRIPTION, true); } }