示例#1
0
        private void HandleImageRenaming(bool allowTagBasedNaming, DirectoryInfo moveDirectory = null)
        {
            List <ImageType> filter = new List <ImageType>();

            if (OptionsData.ThemeOptions.ExcludeRenamingStatic)
            {
                filter.Add(ImageType.Static);
            }
            if (OptionsData.ThemeOptions.ExcludeRenamingGif)
            {
                filter.Add(ImageType.GIF);
            }
            if (OptionsData.ThemeOptions.ExcludeRenamingVideo)
            {
                filter.Add(ImageType.Video);
            }

            switch (WallpaperManagerTools.ChooseSelectionType())
            {
            case SelectionType.Active:
                if (InspectedImage != "")
                {
                    if (WallpaperData.ContainsImage(InspectedImage))
                    {
                        int      imageIndex = selectedImages.IndexOf(InspectedImage);
                        string[] newName    = ImagePathing.RenameImage(InspectedImage, moveDirectory, allowTagBasedNaming);
                        if (newName != null && newName.Length > 0)     // this can occur if the given image is not able to be named
                        {
                            selectedImages[imageIndex] = newName[0];   // there will only be one entry in this array, the renamed image
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid image");
                    }
                }
                else
                {
                    MessageBox.Show("There is no image selected");
                }
                break;

            case SelectionType.All:
                if (MessageBox.Show("Are you sure you want to rename ALL " + selectedImages.Length + " selected images?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // Doing this will require a rebuild of the image selector to keep it in tact
                    RebuildImageSelector(ImagePathing.RenameImages(selectedImages, moveDirectory, allowTagBasedNaming), false);
                }
                break;
            }
        }
示例#2
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());
            }
        }