Example #1
0
        public static void SaveConfig()
        {
            // Save settings to config file
            ConfigFields configData = new ConfigFields();

            configData.StartDate = StartDate.ToString("yyyy-MM-dd");
            configData.EndDate   = EndDate.ToString("yyyy-MM-dd");
            configData.Images    = Images;
            configData.BaseImage = BaseImage;
            string configJson = JsonSerializer.Serialize <ConfigFields>(configData);

            File.WriteAllText(ConfigFilePath, configJson);
        }
Example #2
0
        public static string OriginalWallpaperTileValue;  // The number representing whether the wallpaper should tile, before it was changed

        public static void LoadConfig()
        {
            // Load data from config file
            using (FileStream configFile = File.OpenRead(ConfigFilePath))
            {
                byte[] fileContent = new byte[configFile.Length];
                configFile.Read(fileContent, 0, fileContent.Length);
                ConfigFields configData = JsonSerializer.Deserialize <ConfigFields>(fileContent);
                StartDate = DateTime.Parse(configData.StartDate);
                EndDate   = DateTime.Parse(configData.EndDate);
                Images    = configData.Images;
                BaseImage = configData.BaseImage;

                // Program does not take year into account, so change year to current year
                int currentYear = DateTime.Now.Year;
                StartDate = new DateTime(currentYear, StartDate.Month, StartDate.Day);
                EndDate   = new DateTime(currentYear, EndDate.Month, EndDate.Day).AddHours(23).AddMinutes(59).AddSeconds(59); // Time for end date should be 23:59:59
            }
        }