public void VobSubWriteAndReadTwoBitmaps()
        {
            string fileName = Guid.NewGuid() + ".sub";
            using (var writer = new VobSubWriter(fileName, 800, 600, 10, 10, 32, Color.White, Color.Black, true, "English", "en"))
            {
                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;
            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(string.Format("{0} (0x{1:x})", comboBoxLanguages.Items[k], k + 32));

            buttonStartRipping.Text = _language.StartRipping;
            buttonStartRipping.Enabled = true;
            DialogResult = DialogResult.OK;
        }
        /// <summary>
        /// The button start ripping click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void ButtonStartRippingClick(object sender, EventArgs e)
        {
            if (this.buttonStartRipping.Text == this._language.Abort)
            {
                this._abort = true;
                this.buttonStartRipping.Text = this._language.StartRipping;
                return;
            }

            this._abort = false;
            this.buttonStartRipping.Text = this._language.Abort;
            this._lastPresentationTimestamp = 0;
            this._lastVobPresentationTimestamp = 0;
            this._lastNavEndPts = 0;
            this._accumulatedPresentationTimestamp = 0;

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

                if (!this._abort)
                {
                    this.RipSubtitles(vobFileName, ms, i - 1); // Rip/demux subtitle vob packs
                }
            }

            this.progressBarRip.Visible = false;
            TaskbarList.SetProgressState(this._taskbarFormHandle, TaskbarButtonProgressFlags.NoProgress);
            this.buttonStartRipping.Enabled = false;
            if (this._abort)
            {
                this.labelStatus.Text = this._language.AbortedByUser;
                this.buttonStartRipping.Text = this._language.StartRipping;
                this.buttonStartRipping.Enabled = true;
                return;
            }

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

            this.MergedVobSubPacks = vobSub.MergeVobSubPacks(); // Merge splitted-packs to whole-packs
            if (this.MergedVobSubPacks.Count == 0)
            {
                MessageBox.Show(Configuration.Settings.Language.Main.NoSubtitlesFound);
                this.buttonStartRipping.Text = this._language.StartRipping;
                this.buttonStartRipping.Enabled = true;
                return;
            }

            this.Languages = new List<string>();
            for (int k = 0; k < this.comboBoxLanguages.Items.Count; k++)
            {
                this.Languages.Add(this.comboBoxLanguages.Items[k].ToString());
            }

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