private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { if ((e.CloseReason == CloseReason.WindowsShutDown)) { if (CurrentSettings.ShutdownAutoSave) { FileHandling.FileSave(FileHandling.GetHandlerClassInstance(SupportedFileHandleFormats.TextUnicodePlain), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "DesktopSave.txt")); if (CurrentSettings.AutoLoadSignIn) { CurrentSettings.SaveShortcut( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "DesktopSave.txt"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "DesktopSave.txt") ); } } } #if DEBUG var debugloc = GetUserDebugConfigFileLocation(); if (File.Exists(debugloc) && (InternalConfig.DisableDebugConfigDeleteOnExit == true)) { File.Delete(debugloc); } CurrentSettings.SaveToFile(debugloc); #else CurrentSettings.SaveToFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HunterNotebook.xml")); #endif }
private void NewToolStripMenuItem_Click(object sender, EventArgs e) { if (CurrentFile.HasChanged) { switch (MessageBox.Show(Path.GetFileName(CurrentFile.CurrentFile) + " has changed. Save Changes?", "Save Changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Cancel: { return; } case DialogResult.Yes: { if (CurrentFile.FileExists) { FileHandling.FileSave(FileHandling.GetHandlerClassInstance(CurrentFile.Format), CurrentFile.CurrentFile); } else { using (var SaveDialog = FileHandling.GetOpenDialogForHandler(CurrentFile.Format)) { } } } break; case DialogResult.No: break; default: throw new Exception("Someone forgot to add code for different DialogResult in File->New"); } } CurrentFile = new ContextFile(); CurrentFile.UpdateContextTitle(this); }