Пример #1
0
        public void buttonTag_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Unlink tag?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Button  tagButton    = sender as Button;
                string  tagName      = TaggingTools.GetButtonTagName(tagButton);
                string  categoryName = TaggingTools.GetButtonCategoryName(tagButton);
                TagData linkedTag    = WallpaperData.TaggingInfo.GetTag(categoryName, tagName);

                foreach (Tuple <string, string> tagInfo in linkedTag.ChildTags)
                {
                    if (activeTag.ParentTags.Contains(tagInfo))
                    {
                        MessageBox.Show("You cannot unlink " + linkedTag.Name + " while it's child tag " + tagInfo.Item2 + " is also linked");
                        return;
                    }
                }

                if (MessageBox.Show("Would you like to also remove the tag " + tagName + " from images tagged with " + activeTag.Name + "?", "Choose an option", MessageBoxButtons.YesNo)
                    == DialogResult.Yes)
                {
                    foreach (string image in activeTag.GetLinkedImages())
                    {
                        WallpaperData.GetImageData(image).RemoveTag(linkedTag);
                    }
                }

                activeTag.UnlinkTag(linkedTag);
                tagButton.Dispose();
            }
        }
Пример #2
0
        // 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");
                }
            }
        }
Пример #3
0
        public void LoadTagContainer(int categoryIndex)
        {
            CategoryData category    = WallpaperData.TaggingInfo.GetCategory(categoryIndex);
            TabPage      categoryTab = tabControlImageTagger.TabPages[categoryIndex];

            if (categoryTab.Controls.Count == 0) // first time loading this page
            {
                if (TaggingTools.GetCategoryTagContainer(category, this) == null)
                {
                    SuspendLayout();
                    Size         tagContainerSize     = new Size(tabControlImageTagger.Size.Width - 5, tabControlImageTagger.Size.Height - initialItemSize.Height - 10);
                    TagContainer categoryTagContainer = new TagContainer(category, tagContainerSize, this, tagFormStyle, activeImage, activeTag, tagClickEvent)
                    {
                        AllowDrop = true,
                        Location  = new Point(-2, 0)
                    };

                    categoryTab.Controls.Add(categoryTagContainer);
                    ResumeLayout();
                }
            }
            else
            {
                Debug.WriteLine("Validating Sort Options");
                TaggingTools.GetCategoryTagContainer(category, this).ValidateSortOptions();
            }
            if (ParentTagForm != null)
            {
                ParentTagForm.ActiveCategory = category;
            }
        }
Пример #4
0
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);

            // Reload tag data for just in case of potential changes
            TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger)?.RefreshTagCount();
        }
Пример #5
0
        // Remove Tag
        private void buttonRemoveTag_Click(object sender, EventArgs e)
        {
            string tagName = Interaction.InputBox("Enter the name of the tag you'd like to remove from the  " + ActiveCategory.Name + " category", "Remove Tag", "", -1, -1);

            TagData tagToDelete = null;

            foreach (TagData tag in ActiveCategory.Tags)
            {
                if (tagName == tag.Name)
                {
                    tagToDelete = tag;
                    break;
                }
            }

            if (tagToDelete != null)
            {
                Button tagButton = TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).GetTagButton(tagToDelete);
                TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).RemoveTag(tagToDelete, tagButton);
            }
            else if (tagName != "")
            {
                MessageBox.Show("The tag " + tagName + " does not exist in the " + ActiveCategory.Name + " category");
            }
        }
Пример #6
0
        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();
        }
Пример #7
0
        public void UpdateTagButtonImageCount(TagData tag)
        {
            Button tagButton = GetTagButton(tag);

            if (tagButton != null)
            {
                TaggingTools.UpdateTagButton(tagButton, tag);
            }
        }
Пример #8
0
        public Button GetTagButton(TagData tag)
        {
            foreach (Control control in tagContainerFLP.Controls)
            {
                Button tagButton = control as Button;
                if (TaggingTools.GetButtonTagName(tagButton) == tag.Name)
                {
                    return(tagButton);
                }
            }

            return(null);
        }
Пример #9
0
        public void AddTag(TagData tag)
        {
            CategoryData tagParentCategory = WallpaperData.TaggingInfo.GetTagParentCategory(tag);

            if (TaggingTools.GetCategoryTagContainer(tagParentCategory, TabControlImageTagger) != null)
            {
                //xreturn // This used to return the below line of code
                TaggingTools.GetCategoryTagContainer(tagParentCategory, TabControlImageTagger).InsertTag(tag);
            }

            UpdateCategoryControls(); // the above return calls this method inside of it

            //xreturn true; // the tag adds itself and since the TagContainer has not yet been created it'll be loaded when this occurs
        }
Пример #10
0
        public void tagContainerButton_DragDrop(object sender, DragEventArgs e)
        {
            if (selectedButtonPotentialTabPage != null)
            {
                string selectedTag      = TaggingTools.GetButtonTagName(selectedButton);
                string selectedCategory = selectedButtonPotentialTabPage.Text;
                if (MessageBox.Show("Move " + selectedTag + " to " + selectedCategory + "?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    ParentTagForm.MoveTag(selectedTag, selectedCategory);
                }
            }

            selectedButton = null;
            selectedButtonPotentialTabPage = null;
        }
Пример #11
0
        // Rename Tag
        private void buttonRenameTag_Click(object sender, EventArgs e)
        {
            string tagName = Interaction.InputBox("Enter a new name for the " + activeTag.Name + " tag", "Rename Tag", "", -1, -1);

            if (tagName != "" && tagName != activeTag.Name)
            {
                if (!WallpaperData.TaggingInfo.GetCategory(activeTag.ParentCategoryName).ContainsTag(tagName))
                {
                    activeTag.SetName(tagName);
                    labelTagName.Text = tagName;
                    TaggingTools.UpdateTagButton(activeTagButton, activeTag); //! must be placed lower than the call to activeTag.SetName()
                }
                else
                {
                    MessageBox.Show(tagName + " already exists");
                }
            }
        }
Пример #12
0
        // Apply Default Settings
        private void buttonApplyDefaultSettings_Click(object sender, EventArgs e)
        {
            bool          renameAffectedImages = false;
            List <string> imagesToRename       = new List <string>();

            // Loop through and update all tags
            foreach (TagData tag in ActiveCategory.Tags)
            {
                // If the UseForNaming property is changed, queue the tag's images for renaming
                if (tag.UseForNaming != ActiveCategory.UseForNaming)
                {
                    renameAffectedImages = true;

                    foreach (string image in tag.GetLinkedImages())
                    {
                        imagesToRename.Add(image);
                    }
                }

                // Update Tag
                tag.Enabled      = ActiveCategory.Enabled;
                tag.UseForNaming = ActiveCategory.UseForNaming;

                // Update Tag Colors
                Button tagButton = TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).GetTagButton(tag);
                if (tagButton != null)
                {
                    TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).GetTagButton(tag).ForeColor = tag.Enabled ? Color.Black : Color.Red;
                }
            }

            // Ask the user if they want to rename image's impacted by the UseForNaming change
            if (renameAffectedImages)
            {
                ImagePathing.RenameAffectedImagesPrompt(imagesToRename.ToArray());
            }
        }
Пример #13
0
        private Button CreateTagButton(TagData tag)
        {
            Button tagButton = new Button();

            tagButton.AutoSize  = true;
            tagButton.BackColor = SystemColors.ButtonFace;
            TaggingTools.UpdateTagButton(tagButton, tag);

            ApplyTagFormStyle(ref tagButton);

            foreach (Control control in tagContainerFLP.Controls)
            {
                Button curTagButton = control as Button;
                if (tagButton.Text == curTagButton.Text) // this button already exists
                {
                    return(curTagButton);
                }
            }

            tagContainerFLP.Controls.Add(tagButton);
            tagContainerFLP.Controls.SetChildIndex(tagButton, orderedTags.IndexOf(tag));

            return(tagButton);
        }
Пример #14
0
 private TagData GetSelectedTag(Button selectedTagButton)
 {
     return(WallpaperData.TaggingInfo.GetTag(ActiveCategory, TaggingTools.GetButtonTagName(selectedTagButton)));
 }
Пример #15
0
        private void ButtonTagEditor(object sender, EventArgs e)
        {
            Button  selectedTagButton = sender as Button;
            TagData selectedTag       = WallpaperData.TaggingInfo.GetTag(ActiveCategory, TaggingTools.GetButtonTagName(selectedTagButton));

            using (TagEditorForm f = new TagEditorForm(selectedTag, selectedTagButton, this.tagContainerFLP)) f.ShowDialog();
            RefreshTagCount();
        }
Пример #16
0
 public void RemoveTag(Button tagButton)
 {
     TaggingTools.GetCategoryTagContainer(ActiveCategory, TabControlImageTagger).RemoveTagFromActiveCategory(tagButton);
 }
Пример #17
0
 private void UpdateTagButton()
 {
     labelFoundImages.Text = "Found in " + activeTag.GetLinkedImageCount() + " images";
     TaggingTools.UpdateTagButton(activeTagButton, activeTag);
 }