private void QuickSave(string path) { lblStatus.Text = string.Empty; txtFolder.Text = path; if (String.IsNullOrEmpty(path)) { lblStatus.Text = "Please choose a destination folder."; btnDir.Focus(); return; } if (this.pgc.Chapters.Count == 0) { lblStatus.Text = "No chapters to save."; btnOK.Focus(); return; } try { string name = (pgc.Title ?? pgc.SourceName ?? "Chapters"); name = Pathing.FileNameUtils.MakeValidFileName(name); path = Path.Combine(path, name); lblStatus.Text += "Saving to '" + path + ".chapters" + "'" + Environment.NewLine; pgc.Save(path + ".chapters"); lblStatus.Text += "Saving XML to '" + path + ".xml" + "'" + Environment.NewLine; pgc.SaveXml(path + ".xml"); lblStatus.Text += "Saving text to '" + path + ".chapters.txt" + "'" + Environment.NewLine; pgc.SaveText(path + ".chapters.txt"); lblStatus.Text += "Saving QP to '" + path + ".txt" + "'" + Environment.NewLine; pgc.SaveQpfile(path + ".txt"); lblStatus.Text += "Done."; } catch (UnauthorizedAccessException) { lblStatus.Text = "The folder is read-only. Please choose a different folder."; btnDir.Focus(); } catch (Exception ex) { lblStatus.Text += ex.Message; } }
private void menuFileSave_Click(object sender, System.EventArgs e) { string ext; saveFileDialog.Filter = "Chapters File (*.chapters)|*.chapters|" + "Chapters Text File (*.txt)|*.txt|" + "Matroska Chapter XML File (*.xml)|*.xml|" + "TsMuxeR Meta Text File (*.txt)|*.txt|" + "Celltimes Text File (*.txt)|*.txt|" + "x264 QP File (*.txt)|*.txt|" + "Timecodes Text File (*.txt)|*.txt|" + "All Files (*.*)|*.*"; if (Settings.Default.LastSaveFilterIndex < 1 || Settings.Default.LastSaveFilterIndex > 7) { Settings.Default.LastSaveFilterIndex = 0; } saveFileDialog.FilterIndex = Settings.Default.LastSaveFilterIndex; //Note: filter index is one based (dumb) switch (saveFileDialog.FilterIndex) { case 1: ext = ".chapters"; break; case 3: ext = ".xml"; break; case 2: case 4: case 5: case 6: case 7: ext = ".txt"; break; default: ext = ""; saveFileDialog.FilterIndex = 8; break; } saveFileDialog.RestoreDirectory = true; saveFileDialog.FileName = (pgc.Title == null ? pgc.SourceName : pgc.Title) + ext; if (saveFileDialog.ShowDialog() == DialogResult.OK) { ext = Path.GetExtension(saveFileDialog.FileName).ToLower(); if (ext == ".xml") { pgc.SaveXml(saveFileDialog.FileName); } else if (ext == ".txt") { switch (saveFileDialog.FilterIndex) { case 4: pgc.SaveTsmuxerMeta(saveFileDialog.FileName); break; case 5: pgc.SaveCelltimes(saveFileDialog.FileName); break; case 6: pgc.SaveQpfile(saveFileDialog.FileName); break; case 7: pgc.SaveTimecodes(saveFileDialog.FileName); break; default: pgc.SaveText(saveFileDialog.FileName); break; } } else { pgc.Save(saveFileDialog.FileName); } Settings.Default.LastSaveExt = ext; Settings.Default.LastSaveFilterIndex = saveFileDialog.FilterIndex; Settings.Default.Save(); } }