public void Unmute() { if (player != null && activeVideoImagePath != null) { player.Volume = WallpaperData.GetImageData(activeVideoImagePath).VideoSettings.Volume; } }
// Add Tag To Images private void AddTagToImages(string[] targetImages) { if (targetImages.Length > 0) { string unincludedImages = "The following images you attempted to tag are not included:"; foreach (string image in targetImages) { if (WallpaperData.ContainsImage(image)) { WallpaperData.GetImageData(image).AddTag(WallpaperData.TaggingInfo.GetTagParentCategory(activeTag), activeTag.Name); } else { unincludedImages += "\n" + image; } } if (unincludedImages.Contains("\n")) { MessageBox.Show(unincludedImages); } } else { MessageBox.Show("There are no images to tag"); } }
// Remove Tag From Images private void RemoveTagFromImages(string[] targetImages, Button tagButton) { if (MessageBox.Show("Remove tag from all selected images?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (targetImages.Length > 0) { string unincludedImages = "The following images you attempted to remove a tag from are not included:"; foreach (string image in targetImages) { if (WallpaperData.ContainsImage(image)) { WallpaperData.GetImageData(image).RemoveTag(activeTag); } else { unincludedImages += "\n" + image; } } if (unincludedImages.Contains("\n")) { MessageBox.Show(unincludedImages); } } else { MessageBox.Show("There are no images selected to remove this tag from"); } } }
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(); } }
public static string[] RenameImages(string[] images, DirectoryInfo moveDirectory, bool allowTagBaseNaming) { ///-----Filtering & Initial Processing----- // Convert string array to WallpaperData.ImageData array and remove images that conflict with the user's filter List <WallpaperData.ImageData> imagesData = new List <WallpaperData.ImageData>(); ImageType[] filter = GetFilter(); foreach (string image in images) { bool filterBreached = false; foreach (ImageType imageType in filter) // allows for the filtering of an image type, i.e. Static, GIF, & Video { if (WallpaperData.GetAllImagesOfType(imageType).Contains(image)) { filterBreached = true; break; } } if (filterBreached) { continue; } imagesData.Add(WallpaperData.GetImageData(image)); } WallpaperData.ImageData[] imagesToRename = imagesData.ToArray(); //? This checks if all images were filtered out if (imagesToRename.Length == 0) { MessageBox.Show("None of the given images were able to be renamed"); return(null); } //-----Begin Renaming Process----- //! Don't forget to save the theme after renaming! (Take note of the return statements) //! Don't forget to save the theme after renaming! (Take note of the return statements) //! Don't forget to save the theme after renaming! (Take note of the return statements) if (allowTagBaseNaming) { return(TagBasedNaming(imagesToRename, moveDirectory)); } else { // regardless of if an image is tagged are not, all images in this code block will be directly MOVED (this only applies to moved images) // read the TODOs below for some related comments, although there should still be yet another renaming segment below for directly renamed images } // TODO for all images that won't be renamed based on tags, you should gather a collection of all tag-based renamed images so that they won't be processed a second time // TODO See if you can use hashSet's union()/unionWith()/intersectWith() system for this // TODO Considering that the filter doesn't highlight the possibility of moving naming-disabled images, the user should be warned of this option with a prompt return(null); }
// Add Tag To Image private void AddTagToImage(string targetImage) { if (WallpaperData.ContainsImage(targetImage)) { WallpaperData.GetImageData(targetImage).AddTag(WallpaperData.TaggingInfo.GetTagParentCategory(activeTag), activeTag.Name); } else { MessageBox.Show("The image you attempted to tag is not included"); } }
private static bool RandomizeWallpapers() { Random rand = new Random(); // Gather potential wallpapers string[] potentialWallpapers = new string[DisplayData.Displays.Length]; for (int i = 0; i < DisplayData.Displays.Length; i++) { ImageType imageTypeToSearchFor = ImageType.None; double staticChance = OptionsData.GetExactFrequency(ImageType.Static); double gifChance = OptionsData.GetExactFrequency(ImageType.GIF); double videoChance = OptionsData.GetExactFrequency(ImageType.Video); ImageType[] imageTypeIndexes = { ImageType.Static, ImageType.GIF, ImageType.Video }; double[] imageTypePercentages = { staticChance, gifChance, videoChance }; imageTypeToSearchFor = rand.NextInWeightedArray(imageTypeIndexes, imageTypePercentages); if (WallpaperData.IsAllImagesOfTypeUnranked(imageTypeToSearchFor)) { MessageBox.Show("Attempted to set a wallpaper to an image type with no valid/ranked images. Wallpaper Change Cancelled [IMAGE TYPE: " + imageTypeToSearchFor + "]" + "\n\nEither change relative frequency chance of the above image type to 0% (Under Frequency in the options menu)" + "or activate some wallpapers of the above image type (Unranked images with a rank of 0 are inactive"); return(false); } int randomRank = GetRandomRank(ref rand, imageTypeToSearchFor); // Find random image path if (randomRank != -1) { Debug.WriteLine("Setting Wallpaper: " + i); potentialWallpapers[i] = WallpaperData.GetRandomImageOfRank(randomRank, ref rand, imageTypeToSearchFor); if (!WallpaperData.GetImageData(potentialWallpapers[i]).Active) { //! This shouldn't happen, if this does you have a bug to fix MessageBox.Show("ERROR: Attempted to set display " + i + " to an inactive wallpaper | A new wallpaper has been chosen"); i--; // find another wallpaper, the selected wallpaper is inactive } } else { Debug.WriteLine("-1 rank selected | Fix Code | This will occur if all ranks are 0"); } } ModifyWallpaperOrder(ref potentialWallpapers); UpcomingWallpapers.Enqueue(potentialWallpapers); return(true); }
// Remove Tag From Image private void RemoveTagFromImage(string targetImage, Button tagButton) { if (MessageBox.Show("Remove tag from active image?", "Choose an option", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (WallpaperData.ContainsImage(targetImage)) { WallpaperData.GetImageData(targetImage).RemoveTag(activeTag); } else { MessageBox.Show("The image you attempted to remove a tag from is not included"); } } }
private static bool FinalizeImagePathUpdate(string oldPath, string newPath) { try { //? Since File.Move is case insensitive, first we need to check if oldPath and newPath has the same letters when cases are ignored if (string.Equals(oldPath, newPath, StringComparison.CurrentCultureIgnoreCase)) { Debug.WriteLine("Cases ignored"); // If oldPath and newPath have the same letters, move the file to a temporary location then move it back to the intended location File.Move(oldPath, TempImageLocation); File.Move(TempImageLocation, newPath); } else // otherwise, if the cases do not matter, move the file normally { File.Move(oldPath, newPath); } WallpaperData.GetImageData(oldPath).UpdatePath(newPath); return(true); } catch (Exception e) { // Most likely cause of an error is that the file was being used by another process List <Process> processes = FileUtil.WhoIsLocking(oldPath); if (processes.Count > 0) { string processOutput = oldPath + "\nThe above image is being used by the following process: "; for (int i = 0; i < processes.Count; i++) { processOutput += "\n" + processes[i].ProcessName; } MessageBox.Show(processOutput); } else { MessageBox.Show("Image not changed: \n[" + oldPath + "] " + "\n\nIntended new path: \n[" + newPath + "] " + "\n\nError: " + e.Message); } } return(false); }
private void timerAudioFixer_Tick(object sender, EventArgs e) { if (IsPlayingVideo && !AudioManager.IsWallpapersMuted) { // TODO For whatever reason videos randomly use the audio of a previous video, find a more permanent solution to this fix // TODO The commented fix did not solve this // TODO The occurence is 'rare' enough for me to not know if the below fix has actually done anything yet player.Volume = WallpaperData.GetImageData(activeVideoImagePath).VideoSettings.Volume; /* * WallpaperData.VideoSettings videoSettings = WallpaperData.GetImageData(activeVideoImagePath).VideoSettings; * if (player.Volume != videoSettings.Volume) * { * Debug.WriteLine("Error: Had to fix the volume of a wallpaper with the timerAudioFix control"); * player.Volume = videoSettings.Volume; * } */ } }
//? Using this will cause old wallpapers to remain visible if you aren't filling the entire screen /* * // makes the background transparent to prevent flickering (Only stops the 1 frame flicker when closing, not the one that occurs when loading) * protected override void OnPaintBackground(PaintEventArgs e) * { * var sb = new SolidBrush(Color.FromArgb(0, 0, 0, 0)); * e.Graphics.FillRectangle(sb, this.DisplayRectangle); * } */ // TODO Create a queue that stores pictureBoxes/axWindowMediaPlayers for each wallpaper. This will be used to allow transitions & prevent flickering from // TODO style readjustment when changing wallpapers by *locking* the previous wallpaper in place public void SetWallpaper(string imageLocation) { Loops = 0; WallpaperUptime.Stop(); //! The below conditions were removed but I may consider re-adding this in the future when monitor-specific settings are added, although other methods of handling //! not changing a monitor's wallpaper would probably be better than this //!if (imageLocation == null) return; //? Under certain conditions a wallpaper won't be selected, this prevents the program from crashing over this if (!IsHandleCreated) { return; } if (InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate { SetWallpaperProcess(); }); } else { SetWallpaperProcess(); } async void SetWallpaperProcess() { if (!WallpaperManagerTools.IsSupportedVideoType(imageLocation)) { IsPlayingVideo = false; player.Stop(); panelWallpaper.Visible = false; panelWallpaper.Enabled = false; pictureBoxWallpaper.ImageLocation = imageLocation; pictureBoxWallpaper.Enabled = true; pictureBoxWallpaper.Visible = true; activeVideoImagePath = null; } else { IsPlayingVideo = true; WallpaperUptime.Restart(); pictureBoxWallpaper.Visible = false; pictureBoxWallpaper.Enabled = false; panelWallpaper.Enabled = true; panelWallpaper.Visible = true; activeVideoImagePath = imageLocation; await Task.Run(() => { player.Reload(imageLocation); WallpaperData.VideoSettings videoSettings = WallpaperData.GetImageData(imageLocation).VideoSettings; player.Volume = AudioManager.IsWallpapersMuted ? 0 : videoSettings.Volume; player.Speed = videoSettings.PlaybackSpeed; }).ConfigureAwait(false); } } ResetWallpaperStyle(); // this needs to be readjusted with each image }