private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter = "IFO Files (*.ifo)|*.ifo|MPLS Files (*.mpls)|*.mpls|Text Files (*.txt)|*.txt|All Files supported (*.ifo,*.mpls,*.txt)|*.ifo;*.mpls;*.txt";
                openFileDialog.FilterIndex = 4;

               if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLower().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new IfoExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLower().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description = "Select DVD, BluRay disc, or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                              Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                              new DvdExtractor() as ChapterExtractor :
                              Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                              new BlurayExtractor() as ChapterExtractor :
                              null;

                            if (ex == null)
                                throw new Exception("The location was not detected as DVD, or Blu-Ray.");

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                    frm.Text = "Select your PGC";
                                else
                                    frm.Text = "Select your Playlist";
                                ex.GetStreams(input.Text);
                                if (frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    pgc = frm.ProgramChain;
                                    if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = 25.0;
                                    if (pgc.LangCode == null) pgc.LangCode = "und";
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
                chapterListView.Items[0].Selected = true;
        }
Beispiel #2
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO files (*.ifo)|*.ifo|MKV files (*.mkv)|*.mkv|MPLS files (*.mpls)|*.mpls|Text files (*.txt)|*.txt|All supported files (*.ifo,*.mkv,*.mpls,*.txt)|*.ifo;*.mkv;*.mpls;*.txt";
                openFileDialog.FilterIndex = 5;

                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLowerInvariant().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new DvdExtractor();
                        using (frmStreamSelect frm = new frmStreamSelect(ex))
                        {
                            if (ex is DvdExtractor)
                            {
                                frm.Text = "Select your PGC";
                            }
                            else
                            {
                                frm.Text = "Select your Playlist";
                            }
                            ex.GetStreams(input.Text);
                            if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                            {
                                if (frm.ChapterCount == 0)
                                {
                                    if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                    {
                                        MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                    }
                                    else
                                    {
                                        MessageBox.Show("No titles found.");
                                    }
                                    return;
                                }
                                else
                                {
                                    pgc = frm.SelectedSingleChapterInfo;
                                    if (pgc.FramesPerSecond == 0)
                                    {
                                        MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                        pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                    }
                                    if (String.IsNullOrEmpty(pgc.LangCode))
                                    {
                                        pgc.LangCode = "und";
                                    }
                                }
                            }
                        }
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("txt"))
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mkv"))
                    {
                        ChapterExtractor ex = new MkvExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        MessageBox.Show("The input file is not supported.");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD, BluRay disc or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                                Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                                new DvdExtractor() as ChapterExtractor :
                                File.Exists(Path.Combine(input.Text, "VIDEO_TS.IFO")) ?
                                new DvdExtractor() as ChapterExtractor :
                                Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                                new BlurayExtractor() as ChapterExtractor :
                                null;

                            if (ex == null)
                            {
                                MessageBox.Show("The input folder is not supported.");
                                return;
                            }

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                {
                                    frm.Text = "Select your Title";
                                }
                                else
                                {
                                    frm.Text = "Select your Playlist";
                                }
                                ex.GetStreams(input.Text);
                                if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    if (frm.ChapterCount == 0)
                                    {
                                        if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                        {
                                            MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                        }
                                        else
                                        {
                                            MessageBox.Show("No titles found.");
                                        }
                                        return;
                                    }
                                    else
                                    {
                                        pgc = frm.SelectedSingleChapterInfo;
                                        if (pgc.FramesPerSecond == 0)
                                        {
                                            MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                            pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                        }
                                        if (String.IsNullOrEmpty(pgc.LangCode))
                                        {
                                            pgc.LangCode = "und";
                                        }
                                    }
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }

            if (pgc.FramesPerSecond > 0)
            {
                fpsChooser.Value = (decimal)pgc.FramesPerSecond;
                bFPSKnown        = true;
            }
            else
            {
                bFPSKnown = false;
            }

            string path = String.Empty;

            if (Directory.Exists(MainForm.Instance.Settings.DefaultOutputDir) && FileUtil.IsDirWriteable(MainForm.Instance.Settings.DefaultOutputDir))
            {
                path = MainForm.Instance.Settings.DefaultOutputDir;
            }
            else if (!String.IsNullOrEmpty(input.Text) && Directory.Exists(Path.GetDirectoryName(input.Text)) && FileUtil.IsDirWriteable(Path.GetDirectoryName(input.Text)))
            {
                path = Path.GetDirectoryName(input.Text);
            }

            string file = String.Empty;

            if (String.IsNullOrEmpty(Path.GetFileNameWithoutExtension(input.Text)))
            {
                file = "Chapter Information.txt";
            }
            else
            {
                file = Path.GetFileNameWithoutExtension(input.Text) + " - Chapter Information.txt";
            }
            if (rbXML.Checked)
            {
                Path.ChangeExtension(file, "xml");
            }
            else if (rbQPF.Checked)
            {
                Path.ChangeExtension(file, "qpf");
            }

            if (String.IsNullOrEmpty(path))
            {
                output.Text = file;
            }
            else
            {
                output.Text = Path.Combine(path, file);
            }
        }