private void UpdatePreview([NotNull] List <TVSettings.FilenameProcessorRE> rel) { lvPreview.BeginUpdate(); DirectoryInfo d = new DirectoryInfo(txtFolder.Text); foreach (FileInfo fi in d.GetFiles()) { if (!TVSettings.Instance.FileHasUsefulExtension(fi, true)) { continue; // move on } ShowItem si = cbShowList.SelectedIndex >= 0 ? shows[cbShowList.SelectedIndex] : null; bool r = FinderHelper.FindSeasEp(fi, out int seas, out int ep, out int maxEp, si, rel, false, out TVSettings.FilenameProcessorRE matchRex); IEnumerable <ShowItem> matchingShows = FinderHelper.FindMatchingShows(fi, shows); string bestShowName = FinderHelper.FindBestMatchingShow(fi, shows)?.ShowName; string otherShowNames = string.Join(", ", matchingShows.Select(item => item.ShowName).Where(s => s != bestShowName)); string showDisplayString = otherShowNames.Any() ? bestShowName + " - (" + otherShowNames + ")" : bestShowName; ListViewItem lvi = new ListViewItem { Text = fi.Name }; lvi.SubItems.Add(showDisplayString); lvi.SubItems.Add(seas == -1 ? "-" : seas.ToString()); lvi.SubItems.Add(ep == -1 ? "-" : ep + (maxEp != -1 ? "-" + maxEp : "")); lvi.SubItems.Add(matchRex is null ? "-" : matchRex.Notes); if (!r) { lvi.BackColor = Helpers.WarningColor(); } lvPreview.Items.Add(lvi); } lvPreview.EndUpdate(); }
private void AddItemToListView(string filename, int seas, int ep, int maxEp, TVSettings.FilenameProcessorRE?matchRex, bool r) { IEnumerable <ShowConfiguration> matchingShows = FinderHelper.FindMatchingShows(filename, shows); string bestShowName = FinderHelper.FindBestMatchingShow(filename, shows)?.ShowName; string otherShowNames = matchingShows.Select(item => item.ShowName).Where(s => s != bestShowName).ToCsv(); string showDisplayString = otherShowNames.Any() ? bestShowName + " - (" + otherShowNames + ")" : bestShowName; ListViewItem lvi = new ListViewItem { Text = filename }; lvi.SubItems.Add(showDisplayString); lvi.SubItems.Add(seas == -1 ? "-" : seas.ToString()); lvi.SubItems.Add(ep == -1 ? "-" : ep + (maxEp != -1 ? "-" + maxEp : "")); lvi.SubItems.Add(matchRex is null ? "-" : matchRex.Notes); if (!r) { lvi.BackColor = Helpers.WarningColor(); } lvPreview.Items.Add(lvi); }