Пример #1
0
 private static MediaWizardOptions ShowMediaWizard(ref MediaWizardOptions mwo, List<string> FileOrDirPaths)
 {
     MediaWizard mw = new MediaWizard(FileOrDirPaths);
     mwo.DialogResult = mw.ShowDialog();
     if (mwo.DialogResult == DialogResult.OK)
     {
         mwo = mw.Options;
     }
     mwo.PromptShown = true;
     return mwo;
 }
Пример #2
0
        private void AnalyzeMedia(WorkerTask wt)
        {
            if (!ValidateInput()) return;

            DialogResult dlgResult = DialogResult.OK;
            List<MediaInfo2> miList = new List<MediaInfo2>();

            MediaWizardOptions mwo = Adapter.GetMediaType(wt.FileOrDirPaths);

            if (mwo.ShowWizard)
            {
                ShowMediaWizard(ref mwo, wt.FileOrDirPaths);
            }

            wt.MediaOptions = mwo;
            if (mwo.PromptShown)
            {
                wt.MediaOptions = mwo;
                dlgResult = mwo.DialogResult;
            }
            else
            {
                // fill previous settings
                wt.MediaOptions.CreateTorrent = App.Settings.ProfileActive.CreateTorrent;
                wt.MediaOptions.CreateScreenshots = App.Settings.ProfileActive.CreateScreenshots;
                wt.MediaOptions.UploadScreenshots = App.Settings.ProfileActive.UploadScreenshots;
            }

            if (!mwo.PromptShown && App.Settings.ShowMediaWizardAlways)
            {
                MediaWizard mw = new MediaWizard(wt);
                dlgResult = mw.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    wt.MediaOptions = mw.Options;
                }
            }

            if (dlgResult == DialogResult.OK)
            {
                if (wt.MediaOptions.MediaTypeChoice == MediaType.MediaCollection)
                {
                    wt.FileOrDirPaths.Sort();
                    string firstPath = wt.FileOrDirPaths[0];
                    MediaInfo2 mi = this.PrepareNewMedia(wt, File.Exists(firstPath) ? Path.GetDirectoryName(wt.FileOrDirPaths[0]) : firstPath);
                    foreach (string p in wt.FileOrDirPaths)
                    {
                        if (File.Exists(p))
                        {
                            mi.FileCollection.Add(p);
                        }
                    }
                    miList.Add(mi);
                }
                else
                {
                    foreach (string fd in wt.FileOrDirPaths)
                    {
                        if (File.Exists(fd) || Directory.Exists(fd))
                        {
                            MakeGuiReadyForAnalysis();

                            MediaInfo2 mi = this.PrepareNewMedia(wt, fd);

                            mi.DiscType = MediaHelper.GetSourceType(fd);

                            if (mi.DiscType == SourceType.Bluray)
                            {
                                mi.Overall = new MediaFile(FileSystemHelper.GetLargestFilePathFromDir(fd), cboSource.Text);
                                mi.Overall.Summary = BDInfo(fd);
                            }

                            if (wt.IsSingleTask() && !string.IsNullOrEmpty(txtTitle.Text))
                            {
                                mi.SetTitle(txtTitle.Text);
                            }
                            miList.Add(mi);
                        }
                    }
                }

                // Attach the MediaInfo2 object in to TorrentInfo
                var tiList = miList.Select(mi => new TorrentInfo(bwApp, mi)).ToList();
                wt.MediaList = tiList;

                if (!bwApp.IsBusy)
                {
                    bwApp.RunWorkerAsync(wt);
                }

                UpdateGuiControls();
            }
        }
Пример #3
0
        private void AnalyzeMedia(WorkerTask wt)
        {
            if (!ValidateInput()) return;

            DialogResult dlgResult = DialogResult.OK;
            List<MediaInfo2> miList = new List<MediaInfo2>();

            MediaWizardOptions mwo = Adapter.GetMediaType(wt.FileOrDirPaths);

            wt.MediaTypeChoice = mwo.MediaTypeChoice;
            if (mwo.PromptShown)
            {
                wt.TorrentCreateAuto = mwo.CreateTorrent;
                wt.UploadScreenshot = mwo.ScreenshotsInclude;
                dlgResult = mwo.DialogResultMy;
            }
            else
            {
                // fill previous settings
                wt.TorrentCreateAuto = Program.Settings.TorrentCreateAuto;
                wt.UploadScreenshot = Program.Settings.ScreenshotsUpload;
            }

            if (!mwo.PromptShown && Program.Settings.ShowMediaWizardAlways)
            {
                MediaWizard mw = new MediaWizard(wt);
                dlgResult = mw.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    wt.TorrentCreateAuto = mw.Options.CreateTorrent;
                    wt.UploadScreenshot = mw.Options.ScreenshotsInclude;
                    wt.MediaTypeChoice = mw.Options.MediaTypeChoice;
                }
            }

            if (dlgResult == DialogResult.OK)
            {
                if (wt.MediaTypeChoice == MediaType.MediaCollection)
                {
                    wt.FileOrDirPaths.Sort();
                    string firstPath = wt.FileOrDirPaths[0];
                    MediaInfo2 mi = this.PrepareNewMedia(wt, File.Exists(firstPath) ? Path.GetDirectoryName(wt.FileOrDirPaths[0]) : firstPath);
                    foreach (string p in wt.FileOrDirPaths)
                    {
                        if (File.Exists(p))
                        {
                            mi.FileCollection.Add(p);
                        }
                    }
                    miList.Add(mi);
                }
                else
                {
                    foreach (string fd in wt.FileOrDirPaths)
                    {
                        if (File.Exists(fd) || Directory.Exists(fd))
                        {
                            MakeGUIReadyForAnalysis();

                            MediaInfo2 mi = this.PrepareNewMedia(wt, fd);

                            mi.DiscType = MediaHelper.GetSourceType(fd);

                            if (mi.DiscType == SourceType.Bluray)
                            {
                                mi.Overall = new MediaFile(FileSystemHelper.GetLargestFilePathFromDir(fd), cboSource.Text);
                                mi.Overall.Summary = BDInfo(fd);
                            }

                            if (wt.IsSingleTask() && !string.IsNullOrEmpty(txtTitle.Text))
                            {
                                mi.SetTitle(txtTitle.Text);

                                // if it is a DVD, set the title to be name of the folder.
                                this.Text = string.Format("{0} - {1}", Program.GetProductName(), MediaHelper.GetMediaName(mi.Location));
                            }
                            miList.Add(mi);
                        }
                    }
                }

                // Attach the MediaInfo2 object in to TorrentInfo
                List<TorrentInfo> tiList = new List<TorrentInfo>();
                foreach (MediaInfo2 mi in miList)
                {
                    TorrentInfo ti = new TorrentInfo(bwApp, mi);
                    tiList.Add(ti);
                }
                wt.MediaList = tiList;

                if (!bwApp.IsBusy)
                {
                    bwApp.RunWorkerAsync(wt);
                }

                UpdateGuiControls();
            }
        }