// Add Tag private void buttonAddTag_Click(object sender, EventArgs e) { string tagName = Interaction.InputBox("Enter the name of the tag you'd like to add to the " + ActiveCategory.Name + " category", "Add Tag", "", -1, -1); if (tagName.Contains('(') || tagName.Contains(')')) { MessageBox.Show("Tags cannot contain parenthesis"); return; } char[] nums = "0123456789".ToCharArray(); if (tagName.IndexOfAny(nums) != -1) { MessageBox.Show("Tags cannot contain numbers"); return; } if (tagName != "") { TagData newTag = new TagData(tagName, ActiveCategory); if (newTag.Initialize()) { TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).InsertTag(newTag); UpdateCategoryControls(); } else { MessageBox.Show(newTag.Name + " already exists in the " + ActiveCategory.Name + " category"); } } }
public void MoveTag(string tagName, string categoryName) { TagData origTag = WallpaperData.TaggingInfo.GetTag(ActiveCategory.Name, tagName); TagData newTag = new TagData(origTag); //! Do NOT move the call to remove tag up here as that prevents you from keep the tag in the event of not wanting to remove it if (!WallpaperData.TaggingInfo.GetCategory(categoryName).ContainsTag(newTag)) { RemoveTag(TabControlImageTagger.selectedButton); newTag.Initialize(categoryName); //! this must be done after the call to RemoveTag above | Also ensure that this only happens when you've confirmed that the tag is new! AddTag(newTag); } else if (MessageBox.Show("The tag " + tagName + " already exists in the " + categoryName + " category. " + "Would you like to merge these two tags instead?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes) { RemoveTag(TabControlImageTagger.selectedButton); TagData dupTag = WallpaperData.TaggingInfo.GetTag(categoryName, tagName); newTag.CopyLinkedImagesToTag(dupTag); TaggingTools.GetCategoryTagContainer(WallpaperData.TaggingInfo.GetCategory(categoryName), TabControlImageTagger)?.UpdateTagButtonImageCount(dupTag); //xRemoveTag(TabControlImageTagger.selectedButton); } UpdateCategoryControls(); }