コード例 #1
0
ファイル: VobSubTest.cs プロジェクト: LeonCheung/subtitleedit
        public void VobSubWriteAndReadTwoBitmaps()
        {
            string fileName = Guid.NewGuid() + ".sub";
            using (var writer = new VobSubWriter(fileName, 800, 600, 10, 10, 32, Color.White, Color.Black, true, DvdSubtitleLanguage.English))
            {
                var p1 = new Paragraph("Line1", 0, 1000);
                var p2 = new Paragraph("Line2", 2000, 3000);
                writer.WriteParagraph(p1, new Bitmap(200, 20), ContentAlignment.BottomCenter);
                writer.WriteParagraph(p2, new Bitmap(200, 20), ContentAlignment.BottomCenter);
            }

            var reader = new VobSubParser(true);
            reader.Open(fileName);
            var list = reader.MergeVobSubPacks();

            Assert.IsTrue(list.Count == 2);
        }
コード例 #2
0
ファイル: VobSubOcr.cs プロジェクト: mgziminsky/subtitleedit
        private bool InitializeSubIdx(string vobSubFileName)
        {
            var vobSubParser = new VobSubParser(true);
            string idxFileName = Path.ChangeExtension(vobSubFileName, ".idx");
            vobSubParser.OpenSubIdx(vobSubFileName, idxFileName);
            _vobSubMergedPackist = vobSubParser.MergeVobSubPacks();
            _palette = vobSubParser.IdxPalette;
            vobSubParser.VobSubPacks.Clear();

            var languageStreamIds = new List<int>();
            foreach (var pack in _vobSubMergedPackist)
            {
                if (pack.SubPicture.Delay.TotalMilliseconds > 500 && !languageStreamIds.Contains(pack.StreamId))
                    languageStreamIds.Add(pack.StreamId);
            }
            if (languageStreamIds.Count > 1)
            {
                using (var chooseLanguage = new DvdSubRipChooseLanguage())
                {
                    if (ShowInTaskbar)
                    {
                        chooseLanguage.Icon = (Icon)Icon.Clone();
                        chooseLanguage.ShowInTaskbar = true;
                        chooseLanguage.ShowIcon = true;
                    }
                    chooseLanguage.Initialize(_vobSubMergedPackist, _palette, vobSubParser.IdxLanguages, string.Empty);
                    Form form = _main;
                    if (form == null)
                        form = this;
                    chooseLanguage.Activate();
                    if (chooseLanguage.ShowDialog(form) == DialogResult.OK)
                    {
                        _vobSubMergedPackist = chooseLanguage.SelectedVobSubMergedPacks;
                        SetTesseractLanguageFromLanguageString(chooseLanguage.SelectedLanguageString);
                        _importLanguageString = chooseLanguage.SelectedLanguageString;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return true;
        }
コード例 #3
0
ファイル: DvdSubRip.cs プロジェクト: YangEunYong/subtitleedit
        private void ButtonStartRippingClick(object sender, EventArgs e)
        {
            if (buttonStartRipping.Text == _language.Abort)
            {
                _abort = true;
                buttonStartRipping.Text = _language.StartRipping;
                return;
            }
            _abort = false;
            buttonStartRipping.Text = _language.Abort;
            _lastPresentationTimestamp = 0;
            _lastVobPresentationTimestamp = 0;
            _lastNavEndPts = 0;
            _accumulatedPresentationTimestamp = 0;

            progressBarRip.Visible = true;
            var ms = new MemoryStream();
            int i = 0;
            foreach (string vobFileName in listBoxVobFiles.Items)
            {
                i++;
                labelStatus.Text = string.Format(_language.RippingVobFileXofYZ, Path.GetFileName(vobFileName), i, listBoxVobFiles.Items.Count);
                Refresh();
                Application.DoEvents();

                if (!_abort)
                    RipSubtitles(vobFileName, ms, i - 1); // Rip/demux subtitle vob packs
            }
            progressBarRip.Visible = false;
            TaskbarList.SetProgressState(_taskbarFormHandle, TaskbarButtonProgressFlags.NoProgress);
            buttonStartRipping.Enabled = false;
            if (_abort)
            {
                labelStatus.Text = _language.AbortedByUser;
                buttonStartRipping.Text = _language.StartRipping;
                buttonStartRipping.Enabled = true;
                return;
            }

            labelStatus.Text = string.Format(_language.ReadingSubtitleData);
            Refresh();
            Application.DoEvents();
            var vobSub = new VobSubParser(radioButtonPal.Checked);
            vobSub.Open(ms);
            ms.Close();
            labelStatus.Text = string.Empty;

            MergedVobSubPacks = vobSub.MergeVobSubPacks(); // Merge splitted-packs to whole-packs
            if (MergedVobSubPacks.Count == 0)
            {
                MessageBox.Show(Configuration.Settings.Language.Main.NoSubtitlesFound);
                buttonStartRipping.Text = _language.StartRipping;
                buttonStartRipping.Enabled = true;
                return;
            }
            Languages = new List<string>();
            for (int k = 0; k < comboBoxLanguages.Items.Count; k++)
                Languages.Add(comboBoxLanguages.Items[k].ToString());

            buttonStartRipping.Text = _language.StartRipping;
            buttonStartRipping.Enabled = true;
            DialogResult = DialogResult.OK;
        }