Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DirectoryInfo dirinfo   = new DirectoryInfo(txtPath.Text);
            int           attempts  = 0;
            int           successes = 0;

            FileInfo [] files = dirinfo.GetFiles("*.avi", (chkRecursive.Checked ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));

            pbParseProgress.ProgressBar.Minimum = 0;
            pbParseProgress.ProgressBar.Maximum = files.Length;
            MediaFileNameParser parser    = new MediaFileNameParser();
            List <MediaFile>    fileInfos = new List <MediaFile>();

            foreach (FileInfo fileInfo in files)
            {
                if (fileInfo.FullName.Contains("Documentaries"))
                {
                    continue;
                }
                attempts++;
                lblStatus.Text = "Processing: " + fileInfo.Name;

                pbParseProgress.ProgressBar.Value = attempts;
                MediaFile actual = parser.Parse(fileInfo.FullName);
                fileInfos.Add(actual);
                if (actual.FileType == MediaFileType.TvEpisode)
                {
                    successes++;
                }
            }
            grdResults.DataSource = fileInfos;
            lblStatus.Text        = "Attempts: " + attempts + ". Successes: " + successes + ". Failures: " + (attempts - successes) + ". Accuracy: " + ((double)successes / (double)attempts) * 100.0d;
        }
        /// <summary>
        /// called at the completion of a drop operation. we grab the list of media files
        /// and
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EpisodeMaintenance_DragDrop(object sender, DragEventArgs e)
        {
            MediaFileNameParser parser     = new MediaFileNameParser();
            List <MediaFile>    mediaItems = new List <MediaFile>();

            foreach (string fileName in GetMediaFiles(e))
            {
                MediaFile mfi = parser.Parse(fileName);
                if (mfi.FileType == MediaFileType.TvEpisode)
                {
                    if (IsCompatible(mfi, showDetails))
                    {
                        mediaItems.Add(mfi);
                    }
                }
            }
            TvEpisodeImportDialog importDialog = new TvEpisodeImportDialog();

            importDialog.MediaItemsSelected += new SelectedMediaItemsHandler(importDialog_MediaItemsSelected);
            importDialog.MediaItems          = mediaItems;
            importDialog.Show(this);
        }