public string ExportDeck(string category, string name, DeckExportParameters parameters) { string raw = string.Empty; if(DeckExists(category, name)) { DeckItem deck = LoadDeck(category, name, parameters.Language); switch(parameters.Format) { case DeckExportFormat.Text: raw = ExportDeckToText(deck, parameters.IncludeTags); break; } } return raw; }
void btnExport_Click(object sender, EventArgs e) { ExportParametersView view = new ExportParametersView(); if(view.ShowDialog() == DialogResult.OK) { bool export = true; if(view.SelectedDestination == DeckExportDestination.File) { switch(view.SelectedFormat) { case DeckExportFormat.Text: saveFileDialog.Filter = "Text format|*.txt"; break; } export = saveFileDialog.ShowDialog() == DialogResult.OK; } if(export) { string raw = string.Empty; Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { DeckExportParameters parameters = new DeckExportParameters() { Language = view.SelectedLanguage, Format = view.SelectedFormat, IncludeTags = view.SelectedIncludeTag }; raw = controller.ExportDeck(parameters); } finally { Cursor.Current = currentCursor; } if(view.SelectedDestination == DeckExportDestination.File) File.WriteAllText(saveFileDialog.FileName, raw); else Clipboard.SetText(raw); Program.InfoBox(this, Program.LogicHandler.ServicesProvider.SystemStringsService.GetString("DECK_ROOM_DIALOG", "MSG_EXPORTCOMPLETED")); } } }