示例#1
0
        private void FillPreview()
        {
            this.lvPreview.Items.Clear();
            if ((string.IsNullOrEmpty(this.txtFolder.Text)) || (!Directory.Exists(this.txtFolder.Text)))
            {
                this.txtFolder.BackColor = Helpers.WarningColor();
                return;
            }
            else
            {
                this.txtFolder.BackColor = System.Drawing.SystemColors.Window;
            }

            if (this.Grid1.RowsCount <= 1) // 1 for header
            {
                return;                    // empty
            }
            this.lvPreview.Enabled = true;

            List <FilenameProcessorRE> rel = new List <FilenameProcessorRE>();

            if (this.chkTestAll.Checked)
            {
                for (int i = 1; i < this.Grid1.RowsCount; i++)
                {
                    FilenameProcessorRE re = this.REForRow(i);
                    if (re != null)
                    {
                        rel.Add(re);
                    }
                }
            }
            else
            {
                int[] rowsIndex = this.Grid1.Selection.GetSelectionRegion().GetRowsIndex();
                if (rowsIndex.Length == 0)
                {
                    return;
                }

                FilenameProcessorRE re2 = this.REForRow(rowsIndex[0]);
                if (re2 != null)
                {
                    rel.Add(re2);
                }
                else
                {
                    return;
                }
            }

            this.lvPreview.BeginUpdate();
            DirectoryInfo d = new DirectoryInfo(this.txtFolder.Text);

            foreach (FileInfo fi in d.GetFiles())
            {
                int seas;
                int ep;

                if (!this.TheSettings.UsefulExtension(fi.Extension, true))
                {
                    continue; // move on
                }
                ShowItem     si  = this.cbShowList.SelectedIndex >= 0 ? this.SIL[this.cbShowList.SelectedIndex] : null;
                bool         r   = TVDoc.FindSeasEp(fi, out seas, out ep, si, rel, false);
                ListViewItem lvi = new ListViewItem();
                lvi.Text = fi.Name;
                lvi.SubItems.Add((seas == -1) ? "-" : seas.ToString());
                lvi.SubItems.Add((ep == -1) ? "-" : ep.ToString());
                if (!r)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }
                this.lvPreview.Items.Add(lvi);
            }
            this.lvPreview.EndUpdate();
        }
示例#2
0
文件: Helpers.cs 项目: a-s-p/tvrename
 // see if showname is somewhere in filename
 public static bool SimplifyAndCheckFilename(string filename, string showname, bool simplifyfilename, bool simplifyshowname)
 {
     return(Regex.Match(simplifyfilename ? Helpers.SimplifyName(filename) : filename, "\\b" + (simplifyshowname ? Helpers.SimplifyName(showname) : showname) + "\\b", RegexOptions.IgnoreCase).Success);
 }