/**************************************************************************/ private void CallbackExportListViewToCsvReport(object sender, EventArgs e) { KeyValuePair <string, ListView> SelectedListView; SaveFileDialog Dialog = new SaveFileDialog(); Dialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; Dialog.FilterIndex = 2; Dialog.RestoreDirectory = true; Dialog.DefaultExt = "csv"; Dialog.AddExtension = true; Dialog.FileName = "Macroscope-Report.csv"; this.Enabled = false; SelectedListView = this.GetTabPageListView(); if (SelectedListView.Value != null) { if (Dialog.ShowDialog() == DialogResult.OK) { string Path = Dialog.FileName; MacroscopeCsvExportListViewReport CsvReport; CsvReport = new MacroscopeCsvExportListViewReport(SelectedListView: SelectedListView.Value); try { CsvReport.WriteCsv(this.JobMaster, Path); } catch (MacroscopeSaveCsvFileException ex) { this.DialogueBoxError("Error saving CSV Report", ex.Message); } catch (Exception ex) { this.DialogueBoxError("Error saving CSV Report", ex.Message); } } } else { this.DialogueBoxError("Error saving CSV Report", "Cannot export this view type"); } if (Dialog != null) { Dialog.Dispose(); } this.Enabled = true; }
/**************************************************************************/ private void CallbackExportListViewToCsvReport(object sender, EventArgs e) { KeyValuePair <string, ListView> SelectedListView = this.GetTabPageListView(); SaveFileDialog Dialog = new SaveFileDialog(); Dialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; Dialog.FilterIndex = 2; Dialog.RestoreDirectory = true; Dialog.DefaultExt = "csv"; Dialog.AddExtension = true; Dialog.FileName = "Macroscope-Report.csv"; if (Dialog.ShowDialog() == DialogResult.OK) { string Path = Dialog.FileName; MacroscopeCsvExportListViewReport CsvReport; CsvReport = new MacroscopeCsvExportListViewReport(SelectedListView: SelectedListView.Value); try { if (Macroscope.MemoryGuard(RequiredMegabytes: CsvReportMegabytesRamRequired)) { CsvReport.WriteCsv(this.JobMaster, Path); } } catch (MacroscopeInsufficientMemoryException ex) { this.DialogueBoxError("Error saving CSV Report", ex.Message); } catch (MacroscopeSaveCsvFileException ex) { this.DialogueBoxError("Error saving CSV Report", ex.Message); } catch (Exception ex) { this.DialogueBoxError("Error saving CSV Report", ex.Message); } } Dialog.Dispose(); }