using ApplicationServices; using System; using System.Linq; namespace LibationWinForms.AvaloniaUI.Views { //DONE public partial class MainWindow { private void Configure_Export() { } public void exportLibraryToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) { try { var saveFileDialog = new System.Windows.Forms.SaveFileDialog { Title = "Where to export Library", Filter = "Excel Workbook (*.xlsx)|*.xlsx|CSV files (*.csv)|*.csv|JSON files (*.json)|*.json" // + "|All files (*.*)|*.*" }; if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; // FilterIndex is 1-based, NOT 0-based switch (saveFileDialog.FilterIndex) { case 1: // xlsx default: LibraryExporter.ToXlsx(saveFileDialog.FileName); break; case 2: // csv LibraryExporter.ToCsv(saveFileDialog.FileName); break; case 3: // json LibraryExporter.ToJson(saveFileDialog.FileName); break; } MessageBox.Show("Library exported to:\r\n" + saveFileDialog.FileName); } catch (Exception ex) { MessageBox.ShowAdminAlert(this, "Error attempting to export your library.", "Error exporting", ex); } } } }