private bool HasNotes(string s) { bool result; try { string[] f = File.ReadAllLines(s); if (Path.GetExtension(s).Equals(PerformanceFileListView.fileTypes[1], StringComparison.OrdinalIgnoreCase) && new Performance(string.Join(",", f)).Sheet.Count > 0) { result = true; } else { ImplementedPlayer mml = new ImplementedPlayer(); for (int i = 0; i < f.Length; i++) { f[i] = f[i].RemoveLineComments(); } string fmml = string.Join(string.Empty, f).RemoveBlockComments(); mml.Load(fmml); result = mml.Tracks.Any((MMLPlayerTrack x) => x.notes.Any <Note>()); } } catch (Exception e) { LogHost.Default.WarnException("HasNotes Could not read file: " + s, e); result = false; } return(result); }
private bool HasNotes(string s) { try { var f = File.ReadAllLines(s); if (Path.GetExtension(s) == fileTypes[1]) { if (new Performance(string.Join(",", f)).Sheet.Count > 0) { return(true); } } var mml = new ImplementedPlayer(); for (int i = 0; i < f.Length; i++) { f[i] = f[i].RemoveLineComments(); } var fmml = string.Join(string.Empty, f).RemoveBlockComments(); mml.Load(fmml); return(mml.Tracks.Any(x => x.notes.Any())); }catch (Exception e) { LogHost.Default.WarnException($"{nameof(HasNotes)} Could not read file: {s}", e); return(false); } }
//Asumes file extension is already set to either .txt or .mml private void TryMML(string pathname) { var mml = new ImplementedPlayer(); var mmls = File.ReadAllLines(pathname); for (int i = 0; i < mmls.Length; i++) { mmls[i] = mmls[i].RemoveLineComments(); } var fmml = string.Join(string.Empty, mmls).RemoveBlockComments(); mml.Load(fmml); _ = Program.mem.PlayMML(mml, cts.Token); }