private void saveAsMetadataToolStripMenuItem_Click(object sender, EventArgs e) { StartClick(null); var cfg = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Metadata]; using (var sfd = new SaveFileDialog()) { sfd.InitialDirectory = cfg.Path; sfd.FileName = cfg.File; sfd.Filter = "CSV|*.csv|Excel 97-2003|*.xls"; if (!string.IsNullOrEmpty(cfg.File)) { sfd.FilterIndex = cfg.File.EndsWith("csv") ? 1 : 2; } if (sfd.ShowDialog() == DialogResult.OK) { IMetadataWriter mw = null; switch (Path.GetExtension(sfd.FileName)) { case ".csv": mw = new MetadataCsvWriter(sfd.FileName); break; case ".xls": case ".xlsx": mw = new MetadataExcelOleDbWriter(sfd.FileName); var saveForm = new MetadataSave(); saveForm.MetadataWriter = mw; if (saveForm.ShowDialog() != DialogResult.OK) { EndClick(null); return; } break; default: throw new NotImplementedException(); } mw.ProgressStatusChanged += new ProgressStatusHandler(ProgressStatus); mw.Write(Metadata); mw.ProgressStatusChanged -= new ProgressStatusHandler(ProgressStatus); cfg.FullFileName = sfd.FileName; } } EndClick(null); }
private void saveAsMetadataToolStripMenuItem_Click(object sender, EventArgs e) { StartClick(null); var cfg = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Metadata]; using (var sfd = new SaveFileDialog()) { sfd.InitialDirectory =cfg.Path; sfd.FileName = cfg.File; sfd.Filter = "CSV|*.csv|Excel 97-2003|*.xls"; if(!string.IsNullOrEmpty(cfg.File)) sfd.FilterIndex = cfg.File.EndsWith("csv") ? 1 : 2; if (sfd.ShowDialog() == DialogResult.OK) { IMetadataWriter mw = null; switch (Path.GetExtension(sfd.FileName)) { case ".csv": mw = new MetadataCsvWriter(sfd.FileName); break; case ".xls": case ".xlsx": mw = new MetadataExcelOleDbWriter(sfd.FileName); var saveForm = new MetadataSave(); saveForm.MetadataWriter = mw; if (saveForm.ShowDialog() != DialogResult.OK) { EndClick(null); return; } break; default: throw new NotImplementedException(); } mw.ProgressStatusChanged += new ProgressStatusHandler(ProgressStatus); mw.Write(Metadata); mw.ProgressStatusChanged -= new ProgressStatusHandler(ProgressStatus); cfg.FullFileName = sfd.FileName; } } EndClick(null); }