private void RefreshDataSet() { //refresh dataset StoredSaves = FileService.LoadStoredSaves(); //refresh activesave variable ActiveSave = null; StoredSave storedActive = FileService.readActive(); if (storedActive != null) { ActiveSave = StoredSaves.FirstOrDefault(x => x.Name.Equals(storedActive.Name)); } }
public static void SaveActive(StoredSave active) { FileInfo file = new FileInfo(_activeSavePath); using (StreamWriter outputFile = file.CreateText()) { outputFile.WriteLine(active != null? active.Name : ""); if (active != null) { outputFile.WriteLine(active.LastChangedDate); } } }
public MainWindow() { InitializeComponent(); DataContext = this; ToggleProcess("Initializing", true); StoredSaves = FileService.LoadStoredSaves(); SteamAvailableGames = RegistryService.GetAvailableGames(); string[] paths = FileService.readPath(); GamePath = paths[0]; SavePath = paths[1]; SteamGameSelected = Boolean.Parse(paths[2]); if (SteamAvailableGames.FirstOrDefault(x => x.SteamGameId.Equals(paths[3])) != null) { SteamPath = paths[3]; } LaunchEnabled = true; AutoSyncChecked = true; StoredSave storedActive = FileService.readActive(); if (storedActive != null && new DirectoryInfo(SavePath).Exists) { ActiveSave = StoredSaves.FirstOrDefault(x => x.Name.Equals(storedActive.Name)); if (new DirectoryInfo(SavePath).LastWriteTime > ActiveSave.LastChangedDate) { //MessageBox.Show(new DirectoryInfo(SavePath).LastWriteTime +" " + ActiveSave.LastChangedDate); string tmpName = FileService.FindNewProfileName("Online_Save"); try { FileService.StoreSaveFile(SavePath, tmpName); RefreshDataSet(); ActiveSave = StoredSaves.FirstOrDefault(x => x.Name.Equals(tmpName)); FileService.SaveActive(ActiveSave); DialogName = tmpName.ToString(); _dialogBackupName = tmpName.ToString(); DialogSaveEnabled = false; DialogLabelText = "Active save seems to be newer than stored backup. \nProbably due to online synchronyzation. \nSelect a profile name for the found data \nor click away for automatic naming."; IsDialogOpen = true; } catch (FileNotFoundException e) { MessageBox.Show(e.Message); ActiveSave = null; } } } else if (!new DirectoryInfo(SavePath).Exists) { DrawerHost.IsTopDrawerOpen = true; if (storedActive != null) { MessageBox.Show("Warning: \nSavegame directory '" + SavePath + "' does not seem to exist."); FileService.SaveActive(null); } } ToggleProcess(); }