private void btnImport_Click(object sender, EventArgs e) { string file; using (OpenFileDialog dialog = new OpenFileDialog { AutoUpgradeEnabled = true, DereferenceLinks = true, Title = "Import " + Program.BrandName + " Settings", Filter = Program.BrandName + " Settings (*.tdsettings)|*.tdsettings" }){ if (dialog.ShowDialog() != DialogResult.OK) { return; } file = dialog.FileName; } ExportManager manager = new ExportManager(file, plugins); ExportFileFlags flags; using (DialogSettingsExport dialog = DialogSettingsExport.Import(manager.GetImportFlags())){ if (dialog.ShowDialog() != DialogResult.OK) { return; } flags = dialog.Flags; } if (manager.Import(flags)) { if (!manager.IsRestarting) { ((FormSettings)ParentForm).ReloadUI(); } } else { Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing " + Program.BrandName + " settings.", true, manager.LastException); } }
private void btnExport_Click(object sender, EventArgs e) { ExportFileFlags flags; using (DialogSettingsExport dialog = DialogSettingsExport.Export()){ if (dialog.ShowDialog() != DialogResult.OK) { return; } flags = dialog.Flags; } string file; using (SaveFileDialog dialog = new SaveFileDialog { AddExtension = true, AutoUpgradeEnabled = true, OverwritePrompt = true, DefaultExt = "tdsettings", FileName = Program.BrandName + ".tdsettings", Title = "Export " + Program.BrandName + " Settings", Filter = Program.BrandName + " Settings (*.tdsettings)|*.tdsettings" }){ if (dialog.ShowDialog() != DialogResult.OK) { return; } file = dialog.FileName; } Program.UserConfig.Save(); ExportManager manager = new ExportManager(file, plugins); if (!manager.Export(flags)) { Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting " + Program.BrandName + " settings.", true, manager.LastException); } }