/// <summary> User has requested that we open a <see cref="Menu"/> file from disk. Ask user for file, save current, then load. </summary> private void OpenFile() { OpenFileDialog ofd = new OpenFileDialog(); ofd.ValidateNames = true; ofd.Filter = "Debug Menu Files (*.dat)|*.dat|All Files (*.*)|*.*"; if(ofd.ShowDialog() == true) { ConfirmSaveDesireAndSave(); ApplicationStatus = string.Format("Loading {0}...", ofd.SafeFileName); string folderName = Path.GetDirectoryName(ofd.FileName); string fileName = Path.GetFileName(ofd.FileName); Menu newMenu = new Menu(); newMenu.FileName = fileName; newMenu.FolderPath = folderName; try { using(EndianBinaryReader reader = new EndianBinaryReader(File.Open(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Endian.Big)) { newMenu.Load(reader); LoadedFile = newMenu; } } catch (Exception ex) { Console.WriteLine("Exception while loading: {0}", ex.ToString()); ApplicationStatus = string.Format("Exception while loading: {0}", ex.ToString()); } ApplicationStatus = string.Format("Loaded {0}", ofd.SafeFileName); } }
/// <summary> User has requested that we create a new <see cref="Menu"/> file from scratch. Save current, then create new. </summary> private void CreateNewFile() { ConfirmSaveDesireAndSave(); LoadedFile = new Menu(); ApplicationStatus = string.Format("Created {0}", LoadedFile.FileName); }