private void btnSwitchTitleArtist_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in gvImportList.SelectedRows) { ImportEntry importEntry = row.DataBoundItem as ImportEntry; if (importEntry != null) { string temp = importEntry.Artist; importEntry.Artist = importEntry.Title; importEntry.Title = temp; } } gvImportList.Refresh(); updateMatchDetails(); enableCommands(); }
public bool matchOnTitle(ImportEntry _singleEntry, bool _checkAll) { bool anyMatched = false; var entries = from entry in m_importFile.Entries where ((_checkAll || !entry.Matched) && !String.IsNullOrEmpty(entry.Title)) && (_singleEntry == null || entry == _singleEntry) select entry; string baseMessage = "Find matches based on title.... "; progressMessage(baseMessage, true); foreach (ImportEntry entry in entries) { progressMessage(entry.Title, false); entry.resetMatches(false); foreach (MainSection mainSection in m_mainSections) { SearchSection searchSection = mainSection.TitleSearchSection(); LibrarySection librarySection = (searchSection != null) ? searchSection.createFromSearch(entry.Title) : null; if (librarySection != null) { librarySection.IsMusic = mainSection.IsMusic; var tracks = from track in PMSServer.getSectionElements(librarySection, false) select track; foreach (XElement trackElement in tracks) { if (entry.AddMatch(new MatchEntry(mainSection, trackElement))) { anyMatched = true; } } } } entry.CheckBestMatch(); } progressMessage("", true); return(anyMatched); }
private void gvImportList_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == MatchIcon.Index) { ImportEntry importEntry = gvImportList.Rows[e.RowIndex].DataBoundItem as ImportEntry; if (importEntry != null) { if (importEntry.Matched) { e.Value = Properties.Resources.OKmark; } else if (importEntry.MatchedOnTitleCount > 0) { e.Value = Properties.Resources.Blue_question_mark_16x16; } else { e.Value = Properties.Resources.Red_stop_16x16; } } } }
public static ImportFileM3U loadM3UFile(string _fileName) { ImportFileM3U importFile = new ImportFileM3U() { FileName = _fileName }; try { Directory.SetCurrentDirectory(Path.GetDirectoryName(_fileName)); using (StreamReader sr = new StreamReader(_fileName)) { string m3uContent = sr.ReadToEnd() + "\n"; // Is this an extended playlist? string extendedIndicator = @"^\s*#EXTM3U"; string whitespaceOnlyLine = @"^\s*?\n"; string extendedInfo = @"^\s*#EXTINF:(?<duration>[0-9]*)\s*?,(?<artist>[^\n-]*)?-?(?<title>[^\n]*)?"; importFile.ExtendedFormat = Regex.IsMatch(m3uContent, extendedIndicator); if (importFile.ExtendedFormat) { m3uContent = Regex.Replace(m3uContent, extendedIndicator, ""); } string m3uContentClean = Regex.Replace(Regex.Replace(m3uContent, whitespaceOnlyLine, "", RegexOptions.Multiline), @"\r", ""); ImportEntry importEntry = null; foreach (Match line in Regex.Matches(m3uContentClean, @"^(.*)$", RegexOptions.Multiline)) { if (!String.IsNullOrEmpty(line.Value)) { Match info = Regex.Match(line.Value, extendedInfo); if (info.Success) { importEntry = new ImportEntry() { Owner = importFile, Artist = info.Groups["artist"].Value.Trim(), Title = info.Groups["title"].Value.Trim() }; try { importEntry.Duration = Convert.ToInt32(info.Groups["duration"].Value); } catch { } } else { // This is the file name for the new entry if (importEntry == null) { importEntry = new ImportEntry() { Owner = importFile }; } importEntry.FileName = line.Value; importFile.Entries.Add(importEntry); importEntry = null; } } } } } catch { } return(importFile); }
public bool matchOnTitle(ImportEntry _singleEntry) { return(matchOnTitle(_singleEntry, true)); }