Esempio n. 1
0
        public static void SaveState()
        {
            // Save state to state file
            StateFields stateData = new StateFields();

            stateData.DaysElapsed            = DaysElapsed;
            stateData.ImagesUsed             = ImagesUsed;
            stateData.OriginalWallpaperPath  = OriginalWallpaperPath;
            stateData.OriginalWallpaperStyle = OriginalWallpaperStyle;
            stateData.OriginalWallpaperTile  = OriginalWallpaperTileValue;
            string stateJson = JsonSerializer.Serialize <StateFields>(stateData);

            File.WriteAllText(StateFilePath, stateJson);
        }
Esempio n. 2
0
 public static void LoadState()
 {
     // Load data from state file
     using (FileStream stateFile = File.OpenRead(StateFilePath))
     {
         byte[] fileContent = new byte[stateFile.Length];
         stateFile.Read(fileContent, 0, fileContent.Length);
         StateFields stateData = JsonSerializer.Deserialize <StateFields>(fileContent);
         DaysElapsed                = stateData.DaysElapsed;
         ImagesUsed                 = stateData.ImagesUsed;
         OriginalWallpaperPath      = stateData.OriginalWallpaperPath;
         OriginalWallpaperStyle     = stateData.OriginalWallpaperStyle;
         OriginalWallpaperTileValue = stateData.OriginalWallpaperTile;
     }
 }