示例#1
0
        // Picks ranks based on their default percentiles (Where the highest rank is the most likely to appear and it goes down from there)
        private static int GetRandomRank(ref Random rand, ImageType imageType)
        {
            Debug.WriteLine("Searching for: " + imageType);
            // the percentiles for weighted ranks change everytime an image's rank is altered or if the image type is not none
            if ((WallpaperData.potentialWeightedRankUpdate && OptionsData.ThemeOptions.WeightedRanks) || WallpaperData.potentialRegularRankUpdate || imageType != ImageType.None)
            {
                WallpaperData.UpdateRankPercentiles(imageType); //? this method sets the above booleans to false
            }

            Dictionary <int, double> modifiedRankPercentiles = WallpaperData.GetRankPercentiles(imageType);

            return(rand.NextInWeightedArray(modifiedRankPercentiles.Keys.ToArray(), modifiedRankPercentiles.Values.ToArray()));
        }
示例#2
0
        private void SaveOptionsData(object sender, FormClosedEventArgs e)
        {
            //-----Theme Settings-----
            ThemeOptions.LargerImagesOnLargerDisplays        = checkBoxLargerImagesOnLargerDisplays.Checked;
            ThemeOptions.HigherRankedImagesOnLargerDisplays  = checkBoxHigherRankedImagesOnLargerDisplays.Checked;
            ThemeOptions.EnableDetectionOfInactiveImages     = checkBoxEnableDetectionOfInactiveImages.Checked;
            ThemeOptions.AllowTagBasedRenamingForMovedImages = checkBoxAllowTagNamingMoved.Checked;

            ThemeOptions.ExcludeRenamingStatic = checkBoxExcludeStatic.Checked;
            ThemeOptions.ExcludeRenamingGif    = checkBoxExcludeGif.Checked;
            ThemeOptions.ExcludeRenamingVideo  = checkBoxExcludeVideo.Checked;

            //? This will tell the program to update rank percentiles on the next wallpaper change
            bool updateRankPercentiles = ThemeOptions.WeightedRanks != checkBoxWeightedRanks.Checked || ThemeOptions.WeightedFrequency != checkBoxWeightedFrequency.Checked;

            ThemeOptions.WeightedRanks     = checkBoxWeightedRanks.Checked;
            ThemeOptions.WeightedFrequency = checkBoxWeightedFrequency.Checked;

            //--Video Options--
            ThemeOptions.VideoOptions.MuteIfAudioPlaying         = checkBoxAudioPlaying.Checked;
            ThemeOptions.VideoOptions.MuteIfApplicationMaximized = checkBoxApplicationMaximized.Checked;
            ThemeOptions.VideoOptions.MuteIfApplicationFocused   = checkBoxApplicationFocused.Checked;
            SetMinimumVideoLoops(); // lost focus won't trigger on closing the window
            SetMaximumVideoTime();  // lost focus won't trigger on closing the window

            // note that frequency settings had their opportunity to be changed throughout the form's lifespan

            OptionsData.ThemeOptions = ThemeOptions;

            //! This won't work unless OptionsData.ThemeOptions is updated first | Used to alter weighted rank changes
            if (updateRankPercentiles)
            {
                WallpaperData.UpdateRankPercentiles(ImageType.None);                        //! Now that image types exist this preemptive change may not be worth it
            }
            //-----Global Settings-----
            if (File.Exists(OptionsData.DefaultTheme))
            {
                OptionsData.DefaultTheme                       = labelDefaultThemePath.Text;
                OptionsData.EnableDefaultThemeHotkey           = checkBoxEnableGlobalHotkey.Checked;
                Properties.Settings.Default.DefaultTheme       = labelDefaultThemePath.Text;
                Properties.Settings.Default.DefaultThemeHotkey = checkBoxEnableGlobalHotkey.Checked;
            }

            Properties.Settings.Default.Save();
        }