//======================================================================================== // DoExport() // The open/save dialog boxes reset the current working directory. We need // to preserve the working directory prior to invoking these dialogs and // restore it afterwards to ensure that System.Activator keeps working. //======================================================================================== private void DoExport(object sender, EventArgs e) { string curdir = Directory.GetCurrentDirectory(); DialogResult result = saveDialog.ShowDialog(this); if (result == DialogResult.OK) { XDocument doc = UserOptions.OptionsDoc; InternalSave(); try { UserOptions.Save(saveDialog.FileName); } catch (Exception) { MessageBox.Show( translator.GetString("ExportError"), translator.GetString("ExportErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { UserOptions.OptionsDoc = doc; } } Directory.SetCurrentDirectory(curdir); }
private void InternalSave() { IDictionaryEnumerator en = sheets.GetEnumerator(); SheetBase sheet; while (en.MoveNext()) { sheet = (SheetBase)en.Value; sheet.SaveOptions(); } UserOptions.Save(); }