예제 #1
0
        // Filters a subset of images based on the active radio button (Not needed if your input is not already filtered in some way, there are functions for that)
        private string[] FilterImages(string[] imagesToFilter)
        {
            List <string> imagesToSelect = new List <string>();

            if (radioButtonAll.Checked) // All
            {
                foreach (string imagePath in imagesToFilter)
                {
                    imagesToSelect.Add(imagePath);
                }
            }
            else if (radioButtonUnranked.Checked) // Unranked
            {
                foreach (string imagePath in imagesToFilter)
                {
                    if (WallpaperData.GetImageRank(imagePath) == 0)
                    {
                        imagesToSelect.Add(imagePath);
                    }
                }
            }
            else if (radioButtonRanked.Checked) // Ranked
            {
                foreach (string imagePath in imagesToFilter)
                {
                    if (WallpaperData.GetImageRank(imagePath) != 0)
                    {
                        imagesToSelect.Add(imagePath);
                    }
                }
            }

            return(imagesToSelect.ToArray());
        }
예제 #2
0
        private static void ConflictResolveIdenticalRanks(ref string[] reorderedWallpapers)
        {
            bool conflictFound = false;
            Dictionary <int, List <string> > rankConflicts = new Dictionary <int, List <string> >();

            foreach (string wallpaper in reorderedWallpapers)
            {
                int wallpaperRank = WallpaperData.GetImageRank(wallpaper);
                if (!rankConflicts.ContainsKey(wallpaperRank))
                {
                    rankConflicts.Add(wallpaperRank, new List <string> {
                        wallpaper
                    });
                }
                else // more than one wallpaper contains the same rank, they'll have to have their conflicts resolved below
                {
                    rankConflicts[wallpaperRank].Add(wallpaper);
                    conflictFound = true;
                }
            }

            if (conflictFound) // if this is false then nothing will happen and the original reorderedWallpapers value will persist
            {
                List <string> conflictResolvedOrder = new List <string>();
                foreach (int rank in rankConflicts.Keys)
                {
                    if (rankConflicts[rank].Count > 1) // conflict present, fix it by comparing image sizes and placing the largest image first
                    {
                        string[] conflictResolvedRank = LargestImagesWithCustomFilePath(rankConflicts[rank].ToArray());
                        foreach (string wallpaper in conflictResolvedRank)
                        {
                            conflictResolvedOrder.Add(wallpaper);
                        }
                    }
                    else
                    {
                        conflictResolvedOrder.Add(rankConflicts[rank][0]);
                    }
                }

                reorderedWallpapers = conflictResolvedOrder.ToArray();
            }
        }
예제 #3
0
        private static void ModifyWallpaperOrder(ref string[] wallpapersToModify)
        {
            /* TODO
             * // request next 3 wallpapers, determine their preferred setting
             * // set first display with said preferred setting
             * // request next 3 wallpapers
             * // set second display with preferred setting
             * // no request
             * // set first wallpaper to next wallpaper (Using second set of requested wallpapers)
             * // request next 3 wallpapers, this changes the third wallpaper setting
             * // set third display, this will use the *second* preferred setting (Using third set of requested wallpapers)
             * // essentially, there will always be an upcoming set of preferred wallpapers, once that set surpassed, a new set will be made that all displays will have to follow
             */

            if (IsWallpapersValid(wallpapersToModify))
            {
                string[] reorderedWallpapers = new string[0];
                if (OptionsData.ThemeOptions.HigherRankedImagesOnLargerDisplays || OptionsData.ThemeOptions.LargerImagesOnLargerDisplays)
                {
                    int[] largestMonitorIndexOrder = DisplayData.GetLargestDisplayIndexOrder();

                    if (OptionsData.ThemeOptions.HigherRankedImagesOnLargerDisplays)
                    {
                        reorderedWallpapers = (from f in wallpapersToModify orderby WallpaperData.GetImageRank(f) descending select f).ToArray();

                        // both ranking and size are now a factor so first an image's rank will determine their index and then afterwards
                        // any ranking conflicts have their indexes determined by size rather than being random
                        if (OptionsData.ThemeOptions.LargerImagesOnLargerDisplays)
                        {
                            ConflictResolveIdenticalRanks(ref reorderedWallpapers);
                        }
                    }
                    else if (OptionsData.ThemeOptions.LargerImagesOnLargerDisplays)
                    {
                        reorderedWallpapers = LargestImagesWithCustomFilePath(wallpapersToModify);
                    }

                    //? Applies the final modification
                    wallpapersToModify = ApplyModifiedPathOrder(reorderedWallpapers, largestMonitorIndexOrder);
                }
            }
        }