public bool AttemptRestore() { Dictionary <string, string> loadedFiles = new Dictionary <string, string>(); lock (this) { string basePath = GetBasePath(); if (!Directory.Exists(basePath)) { return(false); } if (MessageBox.Show("HaCreator was shut down unexpectedly, and can attempt to recover from a backed up state automatically. Proceed?\r\n\r\n(To start from scratch, press \"No\")", "Recovery", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { ClearBackups(); return(false); } foreach (FileInfo file in new DirectoryInfo(basePath).GetFiles()) { loadedFiles.Add(file.Name.ToLower(), File.ReadAllText(file.FullName)); } } if (loadedFiles.Count == 0) { return(false); } lock (multiBoard) { if (loadedFiles.ContainsKey(userObjsFileName)) { multiBoard.UserObjects.DeserializeObjects(loadedFiles[userObjsFileName]); loadedFiles.Remove(userObjsFileName); } foreach (KeyValuePair <string, string> file in loadedFiles) { if (Path.GetExtension(file.Key) != ".ham") { continue; } MapLoader.CreateMapFromHam(multiBoard, tabs, file.Value, hcsm.MakeRightClickHandler()); } } ClearBackups(); hcsm.LoadMap(); return(true); }