示例#1
0
 private void FixRightToLeft(Subtitle subtitle)
 {
     if (checkBoxRightToLeft.Checked)
     {
         for (var index = 0; index < subtitle.Paragraphs.Count; index++)
         {
             var paragraph = subtitle.Paragraphs[index];
             if (LanguageAutoDetect.ContainsRightToLeftLetter(paragraph.Text))
             {
                 paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text);
             }
         }
     }
 }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            buttonOK.Enabled = false;
            using (var saveDialog = new SaveFileDialog {
                FileName = string.Empty, Filter = "MP4|*.mp4|Matroska|*.mkv|WebM|*.webm"
            })
            {
                if (saveDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                VideoFileName = saveDialog.FileName;
            }

            if (File.Exists(VideoFileName))
            {
                File.Delete(VideoFileName);
            }

            if (numericUpDownFontSize.Visible)
            {
                var fontSize = (int)numericUpDownFontSize.Value;
                var style    = AdvancedSubStationAlpha.GetSsaStyle("Default", _assaSubtitle.Header);
                style.FontSize = fontSize;
                var styleLine = style.ToRawAss();
                _assaSubtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("Style", styleLine, "[V4+ Styles]", _assaSubtitle.Header);
            }

            if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle))
            {
                for (var index = 0; index < _assaSubtitle.Paragraphs.Count; index++)
                {
                    var paragraph = _assaSubtitle.Paragraphs[index];
                    if (LanguageAutoDetect.ContainsRightToLeftLetter(paragraph.Text))
                    {
                        paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text);
                    }
                }
            }

            SubtitleFormat format           = new AdvancedSubStationAlpha();
            var            assaTempFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".ass");

            File.WriteAllText(assaTempFileName, format.ToText(_assaSubtitle, null));

            progressBar1.Style      = ProgressBarStyle.Marquee;
            progressBar1.Visible    = true;
            labelPleaseWait.Visible = true;
            var process = VideoPreviewGenerator.GenerateHardcodedVideoFile(
                _inputVideoFileName,
                assaTempFileName,
                VideoFileName);

            process.Start();
            while (!process.HasExited)
            {
                System.Threading.Thread.Sleep(100);
                Application.DoEvents();
                if (_abort)
                {
                    process.Kill();
                }
            }

            progressBar1.Visible    = false;
            labelPleaseWait.Visible = false;

            try
            {
                File.Delete(assaTempFileName);
            }
            catch
            {
                // ignore
            }

            DialogResult = _abort ? DialogResult.Cancel : DialogResult.OK;
        }