private void CopyTextAndHtml(IEnumerable <IEditor> editors, IDataObject dataObj) { var textExporter = new PlainTextExporter(); dataObj.SetData(DataFormats.UnicodeText, textExporter.ExportText(editors)); var htmlExporter = new HtmlExporter(); var html = htmlExporter.ExportHtml(editors); dataObj.SetData(DataFormats.Html, ClipboardUtil.GetCFHtmlMemoryStream(html)); }
void ExportHtml_Click(object sender, RoutedEventArgs e) { //what to export bool inclAllPersons = eIncludeAllPeople.IsChecked == true, inclCatPersons = eIncludeCatPeople.IsChecked == true, inclTasks = eIncludeSchedule.IsChecked == true, inclNotes = eIncludeNotes.IsChecked == true, inclPasswords = eIncludePasswords.IsChecked == true; //abort if not rational string message = null; if (inclCatPersons && CatId == null) { message = "Select a category before exporting"; } if (inclAllPersons && inclCatPersons) { message = "Choose one type of person export, not both"; } if (!inclAllPersons && !inclCatPersons && !inclTasks && !inclNotes) { message = "Select something to export"; } if (message != null) { VisualUtils.ShowMessageDialog(message); return; } //get filename string filename = AskForExportFileName(true); if (filename == null) { return; } //export HtmlExporter.ExportHtml(filename, inclAllPersons, inclCatPersons ? CatId : null, inclTasks, inclNotes, inclPasswords); VisualUtils.ShowMessageDialog("Export complete"); }