示例#1
0
        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
        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;
        }