void ShowExport() { ExportData data = ExportData.DataFromDBs(); ImportExportDialog ied = new ImportExportDialog(this, data, true); ied.Show(); ied.DialogComplete += (sender, e) => { FileDialog.CheckFilePermission(this, () => { FileDialog fd = new FileDialog(this, new List <string>() { ".cmx" }, false); fd.Text = "export.cmx"; fd.Show(); fd.DialogComplete += (object s, FileDialog.FileDialogEventArgs ea) => { string name = ea.Filename; string fullname = Path.Combine(fd.Folder, name); FileInfo file = new FileInfo(fullname); fullname = fullname.TrimEnd('.') + ".cmx"; XmlLoader <ExportData> .Save(e.Data, fullname); }; }); }; }
void ShowImportDialog(String filename) { try { ExportData data = XmlLoader <ExportData> .Load(filename); ImportExportDialog ied = new ImportExportDialog(this, data, true); ied.Show(); ied.DialogComplete += (sender, e) => { foreach (Monster m in e.Data.Monsters) { m.DBLoaderID = 0; MonsterDB.DB.AddMonster(m); Monster.Monsters.Add(m); } foreach (Spell s in e.Data.Spells) { s.DBLoaderID = 0; Spell.AddCustomSpell(s); } foreach (Feat s in e.Data.Feats) { s.DBLoaderID = 0; Feat.AddCustomFeat(s); } foreach (Condition s in e.Data.Conditions) { Condition.CustomConditions.Add(s); } if (e.Data.Conditions.Count > 0) { Condition.SaveCustomConditions(); } RefreshForImport(e.Data); }; } catch (Exception ex) { DebugLogger.WriteLine(ex.ToString()); } }