public static void ExportPlaylistToVegas(this Playlist p) { if (p.Count == 0) { ShowMessage("Unable to export: there are no files playing."); return; } string code; using (var str = new StreamReader(CurrentDirectory + "\\VegasScript.cs")) using (var mem = new MemoryStream()) { var dir = XmlWriter.Create(mem); dir.WriteStartElement("root"); foreach (var si in p) { dir.WriteStartElement("song"); dir.WriteAttributeString("FilePath", si.filePath); dir.WriteAttributeString("SongName", si.songName); dir.WriteAttributeString("Artist", si.artist); dir.WriteEndElement(); } dir.WriteEndElement(); dir.Close(); mem.Position = 0; string xml = new StreamReader(mem).ReadToEnd().Replace(@"""", @""""""); code = str.ReadToEnd().Replace("{FILLER}", xml); } string main = "c:/Program Files", cFol; foreach (var pFolP in new[] { "", " (x86)" }) { if (Directory.Exists(cFol = "c:/Program Files" + pFolP) && Directory.Exists(cFol += "/VEGAS")) { foreach (var vDir in Directory.GetDirectories(cFol)) { if (Directory.Exists(cFol = vDir + "/Script Menu")) { main = cFol; } } } } using (var d = new SaveFileDialog() { InitialDirectory = main, FileName = vegasCodeName + ".cs", Filter = "C# code file|*.cs", }) { while (true) { try { d.ShowDialog(); File.WriteAllText(d.FileName, code); break; } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.Message); } } new VegasExportPopup(d.FileName).ShowDialog(); } }
public void PlayPlaylist(Playlist p) => PlayPlaylist(p, reversed);