private static bool importPLS(List <Track> Tracks, System.IO.StreamReader sr, bool MaxOneURL) { bool urlsFound = false; List <string> lines = new List <string>(); while (!sr.EndOfStream) { lines.Add(sr.ReadLine()); } string noe = lines.FirstOrDefault(l => l.StartsWith("numberofentries=", StringComparison.OrdinalIgnoreCase)); if (noe != null) { int numLines; if (Int32.TryParse(noe.Substring("numberofentries=".Length), out numLines)) { for (int i = 1; i <= numLines; i++) { string prefix = "file" + i.ToString() + "="; string line = lines.FirstOrDefault(l => l.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)); if (line == null) { return(urlsFound); } line = line.Substring(prefix.Length).Trim(); if (line.StartsWith("http://")) { if (!urlsFound || !MaxOneURL) { string prefix2 = "title" + i.ToString() + "="; string line2 = lines.FirstOrDefault(l => l.StartsWith(prefix2, StringComparison.OrdinalIgnoreCase)); if (line2 != null) { Radio.AddStation(line, line2.Substring(prefix2.Length), MaxOneURL); } else { Radio.AddStation(line, String.Empty, MaxOneURL); } urlsFound = true; } } else if (File.Exists(line) && Track.IsValidExtension(Path.GetExtension(line))) { Track t = Track.Load(line); if (t != null) { Tracks.Add(t); } } } } } return(urlsFound); }
private bool onDragDrop(DragEventArgs drgevent, bool Play) { base.OnDragDrop(drgevent); string url; if ( (drgevent.Data.GetDataPresent(DataFormats.Text) && (url = drgevent.Data.GetData(DataFormats.Text).ToString()).StartsWith("http", StringComparison.OrdinalIgnoreCase))) { Radio.AddStation(url, String.Empty, Play); return(true); } else { return(false); } }