예제 #1
0
        public MultipleReplace()
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            openFileDialog1.FileName = string.Empty;
            saveFileDialog1.FileName = string.Empty;

            textBoxReplace.ContextMenu = FindReplaceDialogHelper.GetReplaceTextContextMenu(textBoxReplace);
            buttonUpdate.Enabled       = false;

            Text = Configuration.Settings.Language.MultipleReplace.Title;
            labelFindWhat.Text            = Configuration.Settings.Language.MultipleReplace.FindWhat;
            labelReplaceWith.Text         = Configuration.Settings.Language.MultipleReplace.ReplaceWith;
            radioButtonNormal.Text        = Configuration.Settings.Language.MultipleReplace.Normal;
            radioButtonRegEx.Text         = Configuration.Settings.Language.MultipleReplace.RegularExpression;
            radioButtonCaseSensitive.Text = Configuration.Settings.Language.MultipleReplace.CaseSensitive;
            buttonAdd.Text                  = Configuration.Settings.Language.MultipleReplace.Add;
            buttonUpdate.Text               = Configuration.Settings.Language.MultipleReplace.Update;
            listViewRules.Columns[0].Text   = Configuration.Settings.Language.MultipleReplace.Enabled;
            listViewRules.Columns[1].Text   = Configuration.Settings.Language.MultipleReplace.FindWhat;
            listViewRules.Columns[2].Text   = Configuration.Settings.Language.MultipleReplace.ReplaceWith;
            listViewRules.Columns[3].Text   = Configuration.Settings.Language.MultipleReplace.SearchType;
            groupBoxGroups.Text             = Configuration.Settings.Language.MultipleReplace.Groups;
            groupBoxLinesFound.Text         = string.Empty;
            listViewFixes.Columns[0].Text   = Configuration.Settings.Language.General.Apply;
            listViewFixes.Columns[1].Text   = Configuration.Settings.Language.General.LineNumber;
            listViewFixes.Columns[2].Text   = Configuration.Settings.Language.General.Before;
            listViewFixes.Columns[3].Text   = Configuration.Settings.Language.General.After;
            deleteToolStripMenuItem.Text    = Configuration.Settings.Language.MultipleReplace.Remove;
            toolStripMenuItemRemoveAll.Text = Configuration.Settings.Language.MultipleReplace.RemoveAll;
            toolStripMenuItemImport.Text    = Configuration.Settings.Language.MultipleReplace.Import;
            toolStripMenuItemExport.Text    = Configuration.Settings.Language.MultipleReplace.Export;
            buttonNewGroup.Text             = Configuration.Settings.Language.MultipleReplace.NewGroup;
            buttonOK.Text                       = Configuration.Settings.Language.General.Ok;
            buttonCancel.Text                   = Configuration.Settings.Language.General.Cancel;
            buttonApply.Text                    = Configuration.Settings.Language.General.Apply;
            buttonReplacesSelectAll.Text        = Configuration.Settings.Language.FixCommonErrors.SelectAll;
            buttonReplacesInverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection;
            UiUtil.FixLargeFonts(this, buttonOK);
            splitContainer1.Panel1MinSize = 200;
            splitContainer1.Panel2MinSize = 200;

            moveUpToolStripMenuItem.Text     = Configuration.Settings.Language.DvdSubRip.MoveUp;
            moveDownToolStripMenuItem.Text   = Configuration.Settings.Language.DvdSubRip.MoveDown;
            moveTopToolStripMenuItem.Text    = Configuration.Settings.Language.MultipleReplace.MoveToTop;
            moveBottomToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToBottom;
            newToolStripMenuItem.Text        = Configuration.Settings.Language.MultipleReplace.NewGroup;

            toolStripMenuItemMoveRulesToGroup.Text = Configuration.Settings.Language.MultipleReplace.MoveSelectedRulesToGroup;
            moveUpToolStripMenuItem1.Text          = Configuration.Settings.Language.DvdSubRip.MoveUp;
            moveDownToolStripMenuItem1.Text        = Configuration.Settings.Language.DvdSubRip.MoveDown;
            moveToTopToolStripMenuItem.Text        = Configuration.Settings.Language.MultipleReplace.MoveToTop;
            moveToBottomToolStripMenuItem.Text     = Configuration.Settings.Language.MultipleReplace.MoveToBottom;
            toolStripMenuItemRename.Text           = Configuration.Settings.Language.MultipleReplace.RenameGroup;
            deleteToolStripMenuItem1.Text          = Configuration.Settings.Language.MultipleReplace.Remove;

            radioButtonCaseSensitive.Left = radioButtonNormal.Left + radioButtonNormal.Width + 40;
            radioButtonRegEx.Left         = radioButtonCaseSensitive.Left + radioButtonCaseSensitive.Width + 40;
        }
예제 #2
0
        public DCinemaPropertiesInterop()
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            var l = Configuration.Settings.Language.DCinemaProperties;

            Text = l.Title;
            labelSubtitleID.Text       = l.SubtitleId;
            labelMovieTitle.Text       = l.MovieTitle;
            labelReelNumber.Text       = l.ReelNumber;
            labelLanguage.Text         = l.Language;
            groupBoxFont.Text          = l.Font;
            labelFontId.Text           = l.FontId;
            labelFontUri.Text          = l.FontUri;
            labelFontColor.Text        = l.FontColor;
            buttonFontColor.Text       = l.ChooseColor;
            buttonGenerateID.Text      = l.GenerateId;
            labelEffect.Text           = l.FontEffect;
            labelEffectColor.Text      = l.FontEffectColor;
            buttonFontEffectColor.Text = l.ChooseColor;
            labelFontSize.Text         = l.FontSize;
            labelTopBottomMargin.Text  = l.TopBottomMargin;
            labelZPosition.Text        = l.ZPosition;
            labelZPositionHelp.Text    = l.ZPositionHelp;
            labelFadeUpTime.Text       = l.FadeUpTime;
            labelFadeDownTime.Text     = l.FadeDownTime;

            foreach (CultureInfo x in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
            {
                comboBoxLanguage.Items.Add(x.EnglishName);
            }
            comboBoxLanguage.Sorted = true;

            var ss = Configuration.Settings.SubtitleSettings;

            if (!string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId))
            {
                textBoxSubtitleID.Text = ss.CurrentDCinemaSubtitleId;
                textBoxMovieTitle.Text = ss.CurrentDCinemaMovieTitle;
                int number;
                if (int.TryParse(ss.CurrentDCinemaReelNumber, out number))
                {
                    if (numericUpDownReelNumber.Minimum <= number && numericUpDownReelNumber.Maximum >= number)
                    {
                        numericUpDownReelNumber.Value = number;
                    }
                }
                comboBoxLanguage.Text    = ss.CurrentDCinemaLanguage;
                textBoxFontID.Text       = ss.CurrentDCinemaFontId;
                textBoxFontUri.Text      = ss.CurrentDCinemaFontUri;
                panelFontColor.BackColor = ss.CurrentDCinemaFontColor;
                if (ss.CurrentDCinemaFontEffect == "border")
                {
                    comboBoxFontEffect.SelectedIndex = 1;
                }
                else if (ss.CurrentDCinemaFontEffect == "shadow")
                {
                    comboBoxFontEffect.SelectedIndex = 2;
                }
                else
                {
                    comboBoxFontEffect.SelectedIndex = 0;
                }

                panelFontEffectColor.BackColor = ss.CurrentDCinemaFontEffectColor;
                numericUpDownFontSize.Value    = ss.CurrentDCinemaFontSize;
                if (numericUpDownTopBottomMargin.Minimum <= ss.DCinemaBottomMargin &&
                    numericUpDownTopBottomMargin.Maximum >= ss.DCinemaBottomMargin)
                {
                    numericUpDownTopBottomMargin.Value = ss.DCinemaBottomMargin;
                }
                else
                {
                    numericUpDownTopBottomMargin.Value = 8;
                }

                if (numericUpDownFadeUp.Minimum <= ss.DCinemaFadeUpTime &&
                    numericUpDownFadeUp.Maximum >= ss.DCinemaFadeUpTime)
                {
                    numericUpDownFadeUp.Value = ss.DCinemaFadeUpTime;
                }
                else
                {
                    numericUpDownFadeUp.Value = 0;
                }

                if (numericUpDownFadeDown.Minimum <= ss.DCinemaFadeDownTime &&
                    numericUpDownFadeDown.Maximum >= ss.DCinemaFadeDownTime)
                {
                    numericUpDownFadeDown.Value = ss.DCinemaFadeDownTime;
                }
                else
                {
                    numericUpDownFadeDown.Value = 0;
                }

                decimal zPosition = (decimal)ss.DCinemaZPosition;
                if (numericUpDownZPosition.Minimum <= zPosition &&
                    numericUpDownZPosition.Maximum >= zPosition)
                {
                    numericUpDownZPosition.Value = zPosition;
                }
                else
                {
                    numericUpDownZPosition.Value = 0;
                }
            }
            UiUtil.FixLargeFonts(this, buttonCancel);
        }
예제 #3
0
        private void listViewProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            var idx = listViewProfiles.SelectedItems.Count > 0 ? listViewProfiles.SelectedItems[0].Index : -1;
            if (idx < 0 || idx >= RulesProfiles.Count)
            {
                return;
            }

            var oldEditOn = _editOn;
            _editOn = false;
            var p = RulesProfiles[idx];
            textBoxName.Text = p.Name;
            if (p.SubtitleLineMaximumLength >= numericUpDownSubtitleLineMaximumLength.Minimum && p.SubtitleLineMaximumLength <= numericUpDownSubtitleLineMaximumLength.Maximum)
            {
                numericUpDownSubtitleLineMaximumLength.Value = p.SubtitleLineMaximumLength;
            }
            if (p.SubtitleOptimalCharactersPerSeconds >= numericUpDownOptimalCharsSec.Minimum && p.SubtitleOptimalCharactersPerSeconds <= numericUpDownOptimalCharsSec.Maximum)
            {
                numericUpDownOptimalCharsSec.Value = p.SubtitleOptimalCharactersPerSeconds;
            }
            if (p.SubtitleMaximumCharactersPerSeconds >= numericUpDownMaxCharsSec.Minimum && p.SubtitleMaximumCharactersPerSeconds <= numericUpDownMaxCharsSec.Maximum)
            {
                numericUpDownMaxCharsSec.Value = p.SubtitleMaximumCharactersPerSeconds;
            }
            if (p.SubtitleMinimumDisplayMilliseconds >= numericUpDownDurationMin.Minimum && p.SubtitleMinimumDisplayMilliseconds <= numericUpDownDurationMin.Maximum)
            {
                numericUpDownDurationMin.Value = p.SubtitleMinimumDisplayMilliseconds;
            }
            if (p.SubtitleMaximumDisplayMilliseconds >= numericUpDownDurationMax.Minimum && p.SubtitleMaximumDisplayMilliseconds <= numericUpDownDurationMax.Maximum)
            {
                numericUpDownDurationMax.Value = p.SubtitleMaximumDisplayMilliseconds;
            }
            if (p.MinimumMillisecondsBetweenLines >= numericUpDownMinGapMs.Minimum && p.MinimumMillisecondsBetweenLines <= numericUpDownMinGapMs.Maximum)
            {
                numericUpDownMinGapMs.Value = p.MinimumMillisecondsBetweenLines;
            }
            if (p.MaxNumberOfLines >= numericUpDownMaxNumberOfLines.Minimum && p.MaxNumberOfLines <= numericUpDownMaxNumberOfLines.Maximum)
            {
                numericUpDownMaxNumberOfLines.Value = p.MaxNumberOfLines;
            }
            else
            {
                numericUpDownMaxNumberOfLines.Value = numericUpDownMaxNumberOfLines.Minimum;
            }
            if (p.SubtitleMaximumWordsPerMinute >= numericUpDownMaxWordsMin.Minimum && p.SubtitleMaximumWordsPerMinute <= numericUpDownMaxWordsMin.Maximum)
            {
                numericUpDownMaxWordsMin.Value = p.SubtitleMaximumWordsPerMinute;
            }

            SetCpsLineLengthStyle(RulesProfiles[idx].CpsLineLengthStrategy);
            var comboIdx = RulesProfiles[idx].MergeLinesShorterThan - 1;
            if (comboIdx >= 0 && comboIdx < comboBoxMergeShortLineLength.Items.Count)
            {
                try
                {
                    comboBoxMergeShortLineLength.SelectedIndex = comboIdx;
                }
                catch
                {
                    comboBoxMergeShortLineLength.SelectedIndex = 0;
                }
            }
            else
            {
                comboBoxMergeShortLineLength.SelectedIndex = 0;
            }

            comboBoxDialogStyle.Items.Clear();
            comboBoxDialogStyle.Items.Add(LanguageSettings.Current.Settings.DialogStyleDashBothLinesWithSpace);
            comboBoxDialogStyle.Items.Add(LanguageSettings.Current.Settings.DialogStyleDashBothLinesWithoutSpace);
            comboBoxDialogStyle.Items.Add(LanguageSettings.Current.Settings.DialogStyleDashSecondLineWithSpace);
            comboBoxDialogStyle.Items.Add(LanguageSettings.Current.Settings.DialogStyleDashSecondLineWithoutSpace);
            toolTipDialogStylePreview.RemoveAll();
            switch (RulesProfiles[idx].DialogStyle)
            {
                case DialogType.DashBothLinesWithSpace:
                    comboBoxDialogStyle.SelectedIndex = 0;
                    toolTipDialogStylePreview.SetToolTip(comboBoxDialogStyle, DialogSplitMerge.GetDialogStylePreview(DialogType.DashBothLinesWithSpace));
                    break;
                case DialogType.DashBothLinesWithoutSpace:
                    comboBoxDialogStyle.SelectedIndex = 1;
                    toolTipDialogStylePreview.SetToolTip(comboBoxDialogStyle, DialogSplitMerge.GetDialogStylePreview(DialogType.DashBothLinesWithoutSpace));
                    break;
                case DialogType.DashSecondLineWithSpace:
                    comboBoxDialogStyle.SelectedIndex = 2;
                    toolTipDialogStylePreview.SetToolTip(comboBoxDialogStyle, DialogSplitMerge.GetDialogStylePreview(DialogType.DashSecondLineWithSpace));
                    break;
                case DialogType.DashSecondLineWithoutSpace:
                    comboBoxDialogStyle.SelectedIndex = 3;
                    toolTipDialogStylePreview.SetToolTip(comboBoxDialogStyle, DialogSplitMerge.GetDialogStylePreview(DialogType.DashSecondLineWithoutSpace));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            comboBoxContinuationStyle.Items.Clear();
            foreach (var style in ContinuationUtilities.ContinuationStyles)
            {
                comboBoxContinuationStyle.Items.Add(UiUtil.GetContinuationStyleName(style));
            }
            comboBoxContinuationStyle.SelectedIndex = 0;
            toolTipContinuationPreview.RemoveAll();
            toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(RulesProfiles[idx].ContinuationStyle));
            try
            {
                comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(RulesProfiles[idx].ContinuationStyle);
            }
            catch
            { 
                // ignore
            }

            buttonEditCustomContinuationStyle.Visible = RulesProfiles[idx].ContinuationStyle == ContinuationStyle.Custom;
            comboBoxContinuationStyle.Width = RulesProfiles[idx].ContinuationStyle == ContinuationStyle.Custom ? (buttonEditCustomContinuationStyle.Left - comboBoxContinuationStyle.Left - 6) : (comboBoxDialogStyle.Right - comboBoxContinuationStyle.Left);

            _editOn = oldEditOn;
        }
예제 #4
0
 public VobSubNOcrCharacterInspect()
 {
     UiUtil.PreInitialize(this);
     InitializeComponent();
     UiUtil.FixFonts(this);
 }
예제 #5
0
        public AdjustDisplayDuration(bool recalcActive = true)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);
            Icon = Properties.Resources.SEIcon;

            numericUpDownSeconds.Enabled = false;
            numericUpDownPercent.Enabled = false;

            decimal adjustSeconds = Configuration.Settings.Tools.AdjustDurationSeconds;

            if (adjustSeconds >= numericUpDownSeconds.Minimum && adjustSeconds <= numericUpDownSeconds.Maximum)
            {
                numericUpDownSeconds.Value = adjustSeconds;
            }

            int adjustPercent = Configuration.Settings.Tools.AdjustDurationPercent;

            if (adjustPercent >= numericUpDownPercent.Minimum && adjustPercent <= numericUpDownPercent.Maximum)
            {
                numericUpDownPercent.Value = adjustPercent;
            }

            numericUpDownOptimalCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds;
            numericUpDownMaxCharsSec.Value     = (decimal)Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds;

            checkBoxExtendOnly.Checked = Configuration.Settings.Tools.AdjustDurationExtendOnly;

            LanguageStructure.AdjustDisplayDuration language = LanguageSettings.Current.AdjustDisplayDuration;
            Text = language.Title;
            groupBoxAdjustVia.Text          = language.AdjustVia;
            radioButtonSeconds.Text         = language.Seconds;
            radioButtonPercent.Text         = language.Percent;
            radioButtonAutoRecalculate.Text = language.Recalculate;
            labelOptimalCharsSec.Text       = LanguageSettings.Current.Settings.OptimalCharactersPerSecond;
            labelMaxCharsPerSecond.Text     = LanguageSettings.Current.Settings.MaximumCharactersPerSecond;
            labelAddSeconds.Text            = language.AddSeconds;
            labelAddInPercent.Text          = language.SetAsPercent;
            labelNote.Text              = language.Note;
            radioButtonFixed.Text       = language.Fixed;
            labelMillisecondsFixed.Text = language.Milliseconds;
            checkBoxExtendOnly.Text     = language.ExtendOnly;
            buttonOK.Text     = LanguageSettings.Current.General.Ok;
            buttonCancel.Text = LanguageSettings.Current.General.Cancel;
            FixLargeFonts();

            switch (Configuration.Settings.Tools.AdjustDurationLast)
            {
            case Sec:
                radioButtonSeconds.Checked = true;
                break;

            case Per:
                radioButtonPercent.Checked = true;
                break;

            case Recal:
                radioButtonAutoRecalculate.Checked = true;
                break;

            case Fixed:
                radioButtonFixed.Checked = true;
                break;
            }

            if (!recalcActive)
            {
                radioButtonAutoRecalculate.Enabled = false;
                if (radioButtonAutoRecalculate.Checked)
                {
                    radioButtonSeconds.Checked = true;
                }
            }

            FixEnabled();
        }
예제 #6
0
        public ImportCdg(string fileName)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);
            _cdgGraphics       = CdgGraphicsFile.Load(fileName);
            _subtitle          = new Subtitle();
            FileName           = fileName;
            labelStatus.Text   = string.Empty;
            labelFileName.Text = string.Format("File name: {0}", Path.GetFileName(fileName));
            labelDuration.Text = string.Format("Duration: {0}", TimeCode.FromSeconds(_cdgGraphics.DurationInMilliseconds / 1000.0).ToDisplayString());
            buttonCancel.Text  = LanguageSettings.Current.General.Cancel;

            if (fileName != null && fileName.Length > 3)
            {
                var audioFileName = fileName.Substring(0, fileName.Length - 3) + "mp3";
                if (!File.Exists(audioFileName))
                {
                    audioFileName = fileName.Substring(0, fileName.Length - 3) + "ogg";
                }
                if (File.Exists(audioFileName))
                {
                    _audioFileName          = audioFileName;
                    labelAudioFileName.Text = Path.GetFileName(audioFileName);
                }
            }

            textBoxFFmpegPath.Text = Configuration.Settings.General.MkvMergeLocation;

            comboBoxRes.SelectedIndex = 0;

            for (int i = 0; i <= 1000; i++)
            {
                comboBoxLeftRightMargin.Items.Add(i);
                comboBoxBottomMargin.Items.Add(i);
            }

            comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportCdgMarginLeft;
            comboBoxBottomMargin.SelectedIndex    = Configuration.Settings.Tools.ExportCdgMarginBottom;

            if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportCdgBackgroundImage) &&
                File.Exists(Configuration.Settings.Tools.ExportCdgBackgroundImage))
            {
                SetBackgroundImage(Configuration.Settings.Tools.ExportCdgBackgroundImage);
            }

            if (Configuration.Settings.Tools.ExportCdgFormat == "VIDEO")
            {
                radioButtonVideo.Checked = true;
            }
            else
            {
                radioButtonBluRaySup.Checked = true;
            }

            radioButtonBluRaySup_CheckedChanged(null, null);

            buttonDownloadFfmpeg.Text = LanguageSettings.Current.Settings.DownloadFFmpeg;
            var isFfmpegAvailable = !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);

            buttonDownloadFfmpeg.Visible = !isFfmpegAvailable;

            buttonStart.Font = new Font(buttonStart.Font.FontFamily, buttonStart.Font.Size, FontStyle.Bold);
        }
 private void linkLabelVoskWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     UiUtil.OpenUrl("https://alphacephei.com/vosk/models");
 }
예제 #8
0
        public static bool ConvertFromTsToBluRaySup(string fileName, string outputFolder, bool overwrite, StreamWriter stdOutWriter, CommandLineConverter.BatchConvertProgress progressCallback)
        {
            var tsParser = new TransportStreamParser();

            tsParser.Parse(fileName, (position, total) =>
            {
                var percent = (int)Math.Round(position * 100.0 / total);
                stdOutWriter?.Write("\rParsing transport stream: {0}%", percent);
                progressCallback?.Invoke($"{percent}%");
            });
            stdOutWriter?.Write("\r".PadRight(32, ' '));
            stdOutWriter?.Write("\r");
            var videoInfo = UiUtil.GetVideoInfo(fileName);
            int width     = 720;
            int height    = 576;

            if (videoInfo.Success && videoInfo.Width > 0 && videoInfo.Height > 0)
            {
                width  = videoInfo.Width;
                height = videoInfo.Height;
            }

            if (Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
                Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
                Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
            {
                width  = Configuration.Settings.Tools.BatchConvertTsScreenWidth;
                height = Configuration.Settings.Tools.BatchConvertTsScreenHeight;
            }
            using (var form = new ExportPngXml())
            {
                if (tsParser.SubtitlePacketIds.Count == 0)
                {
                    stdOutWriter?.WriteLine($"No subtitles found");
                    progressCallback?.Invoke($"No subtitles found");
                    return(false);
                }
                form.Initialize(new Subtitle(), new SubRip(), BatchConvert.BluRaySubtitle, fileName, videoInfo, fileName);
                foreach (int pid in tsParser.SubtitlePacketIds)
                {
                    var outputFileName = CommandLineConverter.FormatOutputFileNameForBatchConvert(Utilities.GetPathAndFileNameWithoutExtension(fileName) + "-" + pid + Path.GetExtension(fileName), ".sup", outputFolder, overwrite);
                    stdOutWriter?.WriteLine($"Saving PID {pid} to {outputFileName}...");
                    progressCallback?.Invoke($"Save PID {pid}");

                    var sub = tsParser.GetDvbSubtitles(pid);
                    using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))
                    {
                        for (int index = 0; index < sub.Count; index++)
                        {
                            var p    = sub[index];
                            var pos  = p.GetPosition();
                            var bmp  = sub[index].GetBitmap();
                            var nbmp = new NikseBitmap(bmp);
                            pos.Top  += nbmp.CropTopTransparent(0);
                            pos.Left += nbmp.CropSidesAndBottom(0, Color.FromArgb(0, 0, 0, 0), true);
                            bmp.Dispose();
                            bmp = nbmp.GetBitmap();
                            var mp = form.MakeMakeBitmapParameter(index, width, height);
                            mp.Bitmap       = bmp;
                            mp.P            = new Paragraph(string.Empty, p.StartMilliseconds, p.EndMilliseconds);
                            mp.ScreenWidth  = width;
                            mp.ScreenHeight = height;
                            if (Configuration.Settings.Tools.BatchConvertTsOverridePosition ||
                                Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
                                Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
                                Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
                            {
                                mp.BottomMargin = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin;
                                mp.Alignment    = ContentAlignment.BottomCenter;
                            }
                            else
                            {
                                mp.OverridePosition = new Point(pos.Left, pos.Top); // use original position
                            }
                            ExportPngXml.MakeBluRaySupImage(mp);
                            binarySubtitleFile.Write(mp.Buffer, 0, mp.Buffer.Length);
                            if (mp.Bitmap != null)
                            {
                                mp.Bitmap.Dispose();
                                mp.Bitmap = null;
                            }
                        }
                    }
                }
            }
            return(true);
        }
예제 #9
0
 public AddBeterMultiMatch()
 {
     UiUtil.PreInitialize(this);
     InitializeComponent();
     UiUtil.FixFonts(this);
 }
예제 #10
0
 private void lblText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     UiUtil.OpenURL((string)e.Link.LinkData);
 }
예제 #11
0
        public Cavena890SaveOptions(Subtitle subtitle, string subtitleFileName)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
            buttonOK.Text     = Configuration.Settings.Language.General.Ok;

            timeUpDownStartTime.ForceHHMMSSFF();
            timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage));
            textBoxTranslatedTitle.Text  = Configuration.Settings.SubtitleSettings.CurrentCavena89Title;
            textBoxOriginalTitle.Text    = Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle;
            textBoxTranslator.Text       = Configuration.Settings.SubtitleSettings.CurrentCavena890Translator;
            textBoxComment.Text          = Configuration.Settings.SubtitleSettings.CurrentCavena89Comment;
            if (string.IsNullOrWhiteSpace(textBoxComment.Text))
            {
                textBoxComment.Text = "Made with Subtitle Edit";
            }

            if (string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title))
            {
                string title = Path.GetFileNameWithoutExtension(subtitleFileName) ?? string.Empty;
                if (title.Length > 28)
                {
                    title = title.Substring(0, 28);
                }

                textBoxTranslatedTitle.Text = title;
            }

            var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle);

            switch (language)
            {
            case "he":
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew;
                comboBoxLanguage.SelectedIndex = 5;
                break;

            case "ru":
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian;
                comboBoxLanguage.SelectedIndex = 6;
                break;

            case "ro":
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRomanian;
                comboBoxLanguage.SelectedIndex = 7;
                break;

            case "zh":
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified;
                comboBoxLanguage.SelectedIndex = 2;
                break;

            case "da":
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish;
                comboBoxLanguage.SelectedIndex = 1;
                break;

            default:
                Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish;
                comboBoxLanguage.SelectedIndex = 4;
                break;
            }
        }
예제 #12
0
        public void Initialize(bool useSyntaxColoring)
        {
            ContextMenuStrip oldContextMenuStrip = null;
            var oldEnabled = true;

            if (_simpleTextBox != null)
            {
                oldContextMenuStrip = _simpleTextBox.ContextMenuStrip;
                oldEnabled          = _simpleTextBox.Enabled;
            }
            else if (_uiTextBox != null)
            {
                oldContextMenuStrip = _uiTextBox.ContextMenuStrip;
                oldEnabled          = _uiTextBox.Enabled;
            }

            BorderStyle = BorderStyle.None;
            Padding     = new Padding(1);
            BackColor   = SystemColors.WindowFrame;
            Controls.Clear();
            _simpleTextBox?.Dispose();
            _richTextBoxTemp?.Dispose();
            _uiTextBox?.Dispose();
            _simpleTextBox   = null;
            _uiTextBox       = null;
            _richTextBoxTemp = null;
            if (useSyntaxColoring)
            {
                _richTextBoxTemp = new RichTextBox();
                _uiTextBox       = new RichTextBox {
                    BorderStyle = BorderStyle.None, Multiline = true
                };
                InitializeBackingControl(_uiTextBox);

                // avoid selection when centered and clicking to the left
                _uiTextBox.MouseDown += (sender, args) =>
                {
                    var charIndex = _uiTextBox.GetCharIndexFromPosition(args.Location);
                    if (Configuration.Settings.General.CenterSubtitleInTextBox &&
                        _mouseMoveSelectionLength == 0 &&
                        (charIndex == 0 || charIndex >= 0 && _uiTextBox.Text[charIndex - 1] == '\n'))
                    {
                        _uiTextBox.SelectionLength = 0;
                    }
                };
                _uiTextBox.MouseMove += (sender, args) =>
                {
                    _mouseMoveSelectionLength = _uiTextBox.SelectionLength;
                };
                _uiTextBox.KeyDown += (sender, args) =>
                {
                    // fix annoying "beeps" when moving cursor position
                    if ((args.KeyData == Keys.Left || args.KeyData == Keys.PageUp) && _uiTextBox.SelectionStart == 0)
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.Up && _uiTextBox.SelectionStart <= _uiTextBox.Text.IndexOf('\n'))
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.Home && (_uiTextBox.SelectionStart == 0 || _uiTextBox.SelectionStart > 0 && _uiTextBox.Text[_uiTextBox.SelectionStart - 1] == '\n'))
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == (Keys.Home | Keys.Control) && _uiTextBox.SelectionStart == 0)
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.End && (_uiTextBox.SelectionStart >= _uiTextBox.Text.Length || _uiTextBox.SelectionStart + 1 < _uiTextBox.Text.Length && _uiTextBox.Text[_uiTextBox.SelectionStart] == '\n'))
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == (Keys.End | Keys.Control) && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length)
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.Right && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length)
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.Down && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length)
                    {
                        args.SuppressKeyPress = true;
                    }
                    else if (args.KeyData == Keys.PageDown && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length)
                    {
                        args.SuppressKeyPress = true;
                    }
                };
            }
            else
            {
                _simpleTextBox = new SimpleTextBox {
                    BorderStyle = BorderStyle.None, Multiline = true
                };
                _simpleTextBox.KeyDown += (sender, args) =>
                {
                    if (args.KeyData == (Keys.Control | Keys.Back))
                    {
                        UiUtil.ApplyControlBackspace(_simpleTextBox);
                        args.SuppressKeyPress = true;
                    }
                };
                InitializeBackingControl(_simpleTextBox);
            }

            UpdateFontAndColors();
            if (oldContextMenuStrip != null)
            {
                ContextMenuStrip = oldContextMenuStrip;
            }

            Enabled = oldEnabled;
        }
예제 #13
0
        public ImportText()
        {
            InitializeComponent();

            Text = Configuration.Settings.Language.ImportText.Title;
            groupBoxImportText.Text        = Configuration.Settings.Language.ImportText.Title;
            buttonOpenText.Text            = Configuration.Settings.Language.ImportText.OpenTextFile;
            groupBoxImportOptions.Text     = Configuration.Settings.Language.ImportText.ImportOptions;
            groupBoxSplitting.Text         = Configuration.Settings.Language.ImportText.Splitting;
            radioButtonAutoSplit.Text      = Configuration.Settings.Language.ImportText.AutoSplitText;
            radioButtonLineMode.Text       = Configuration.Settings.Language.ImportText.OneLineIsOneSubtitle;
            labelLineBreak.Left            = radioButtonLineMode.Left + radioButtonLineMode.Width + 10;
            labelLineBreak.Text            = Configuration.Settings.Language.ImportText.LineBreak;
            columnHeaderFName.Text         = Configuration.Settings.Language.JoinSubtitles.FileName;
            columnHeaderSize.Text          = Configuration.Settings.Language.General.Size;
            comboBoxLineBreak.Left         = labelLineBreak.Left + labelLineBreak.Width + 3;
            comboBoxLineBreak.Width        = groupBoxSplitting.Width - comboBoxLineBreak.Left - 5;
            checkBoxMultipleFiles.AutoSize = true;
            checkBoxMultipleFiles.Left     = buttonOpenText.Left - checkBoxMultipleFiles.Width - 9;
            checkBoxMultipleFiles.Text     = Configuration.Settings.Language.ImportText.OneSubtitleIsOneFile;
            listViewInputFiles.Visible     = false;

            radioButtonSplitAtBlankLines.Text      = Configuration.Settings.Language.ImportText.SplitAtBlankLines;
            checkBoxMergeShortLines.Text           = Configuration.Settings.Language.ImportText.MergeShortLines;
            checkBoxRemoveEmptyLines.Text          = Configuration.Settings.Language.ImportText.RemoveEmptyLines;
            checkBoxRemoveLinesWithoutLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters;
            checkBoxGenerateTimeCodes.Text         = Configuration.Settings.Language.ImportText.GenerateTimeCodes;
            checkBoxAutoBreak.Text            = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak;
            labelGapBetweenSubtitles.Text     = Configuration.Settings.Language.ImportText.GapBetweenSubtitles;
            numericUpDownGapBetweenLines.Left = labelGapBetweenSubtitles.Left + labelGapBetweenSubtitles.Width + 3;
            groupBoxDuration.Text             = Configuration.Settings.Language.General.Duration;
            radioButtonDurationAuto.Text      = Configuration.Settings.Language.ImportText.Auto;
            radioButtonDurationFixed.Text     = Configuration.Settings.Language.ImportText.Fixed;
            buttonRefresh.Text        = Configuration.Settings.Language.ImportText.Refresh;
            groupBoxTimeCodes.Text    = Configuration.Settings.Language.ImportText.TimeCodes;
            groupBoxImportResult.Text = Configuration.Settings.Language.General.Preview;
            buttonOK.Text             = Configuration.Settings.Language.General.Ok;
            buttonCancel.Text         = Configuration.Settings.Language.General.Cancel;
            SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
            UiUtil.InitializeSubtitleFont(SubtitleListview1);
            SubtitleListview1.AutoSizeAllColumns(this);

            if (string.IsNullOrEmpty(Configuration.Settings.Tools.ImportTextSplitting))
            {
                radioButtonAutoSplit.Checked = true;
            }
            else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("blank lines", StringComparison.OrdinalIgnoreCase))
            {
                radioButtonSplitAtBlankLines.Checked = true;
            }
            else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("line", StringComparison.OrdinalIgnoreCase))
            {
                radioButtonLineMode.Checked = true;
            }
            checkBoxMergeShortLines.Checked = Configuration.Settings.Tools.ImportTextMergeShortLines;
            comboBoxLineBreak.Text          = Configuration.Settings.Tools.ImportTextLineBreak;

            numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked;
            UiUtil.FixLargeFonts(this, buttonOK);
            _refreshTimer.Interval = 400;
            _refreshTimer.Tick    += RefreshTimerTick;
        }
예제 #14
0
        public ModifySelection(Subtitle subtitle, SubtitleFormat format, SubtitleListView subtitleListView)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);
            _loading                   = true;
            _subtitle                  = subtitle;
            _format                    = format;
            _subtitleListView          = subtitleListView;
            labelInfo.Text             = string.Empty;
            comboBoxRule.SelectedIndex = 0;
            Text                                   = LanguageSettings.Current.ModifySelection.Title;
            buttonOK.Text                          = LanguageSettings.Current.General.Ok;
            buttonCancel.Text                      = LanguageSettings.Current.General.Cancel;
            buttonApply.Text                       = LanguageSettings.Current.General.Apply;
            groupBoxRule.Text                      = LanguageSettings.Current.ModifySelection.Rule;
            groupBoxWhatToDo.Text                  = LanguageSettings.Current.ModifySelection.DoWithMatches;
            checkBoxCaseSensitive.Text             = LanguageSettings.Current.ModifySelection.CaseSensitive;
            radioButtonNewSelection.Text           = LanguageSettings.Current.ModifySelection.MakeNewSelection;
            radioButtonAddToSelection.Text         = LanguageSettings.Current.ModifySelection.AddToCurrentSelection;
            radioButtonSubtractFromSelection.Text  = LanguageSettings.Current.ModifySelection.SubtractFromCurrentSelection;
            radioButtonIntersect.Text              = LanguageSettings.Current.ModifySelection.IntersectWithCurrentSelection;
            columnHeaderApply.Text                 = LanguageSettings.Current.General.Apply;
            columnHeaderLine.Text                  = LanguageSettings.Current.General.LineNumber;
            columnHeaderText.Text                  = LanguageSettings.Current.General.Text;
            toolStripMenuItemInverseSelection.Text = LanguageSettings.Current.Main.Menu.Edit.InverseSelection;
            toolStripMenuItemSelectAll.Text        = LanguageSettings.Current.Main.Menu.ContextMenu.SelectAll;

            listViewStyles.Visible = false;

            UiUtil.FixLargeFonts(this, buttonOK);

            comboBoxRule.Items.Clear();
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.Contains);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.StartsWith);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.EndsWith);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.NoContains);
            comboBoxRule.Items.Add(LanguageSettings.Current.ChangeCasing.AllUppercase);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.RegEx);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.OddLines);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.EvenLines);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationLessThan);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationGreaterThan);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.MoreThanTwoLines);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.Bookmarked);
            if (_format.HasStyleSupport)
            {
                comboBoxRule.Items.Add(LanguageSettings.Current.General.Style);
            }
            if (_format.HasStyleSupport && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha)))
            {
                comboBoxRule.Items.Add(LanguageSettings.Current.General.Actor);
            }

            checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive;
            textBoxText.Text = Configuration.Settings.Tools.ModifySelectionText;
            switch (Configuration.Settings.Tools.ModifySelectionRule)
            {
            case StartsWith:
                comboBoxRule.SelectedIndex = FunctionStartsWith;
                break;

            case EndsWith:
                comboBoxRule.SelectedIndex = FunctionEndsWith;
                break;

            case NotContains:
                comboBoxRule.SelectedIndex = FunctionNotContains;
                break;

            case AllUppercase:
                comboBoxRule.SelectedIndex = FunctionAllUppercase;
                break;

            case RegEx:
                comboBoxRule.SelectedIndex = FunctionRegEx;
                break;

            case Odd:
                comboBoxRule.SelectedIndex = FunctionOdd;
                break;

            case Even:
                comboBoxRule.SelectedIndex = FunctionEven;
                break;

            case DurationLessThan:
                comboBoxRule.SelectedIndex = FunctionDurationLessThan;
                break;

            case DurationGreaterThan:
                comboBoxRule.SelectedIndex = FunctionDurationGreaterThan;
                break;

            case MoreThanTwoLines:
                comboBoxRule.SelectedIndex = FunctionMoreThanTwoLines;
                break;

            case Bookmarked:
                comboBoxRule.SelectedIndex = FunctionBookmarked;
                break;

            case Style when _format.HasStyleSupport:
                comboBoxRule.SelectedIndex = FunctionStyle;
                break;

            case Actor when _format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha):
                comboBoxRule.SelectedIndex = FunctionActor;

                break;

            default:
                comboBoxRule.SelectedIndex = FunctionContains;
                break;
            }

            if (!_format.HasStyleSupport)
            {
                listViewFixes.Columns.Remove(columnHeaderStyle);
            }

            _loading = false;
            Preview();
        }
예제 #15
0
        public GenerateVideoWithHardSubs(Subtitle assaSubtitle, string inputVideoFileName, VideoInfo videoInfo, int?fontSize)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            _loading                              = true;
            _videoInfo                            = videoInfo;
            Text                                  = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Title;
            _assaSubtitle                         = new Subtitle(assaSubtitle);
            _inputVideoFileName                   = inputVideoFileName;
            buttonOK.Text                         = LanguageSettings.Current.Watermark.Generate;
            labelPleaseWait.Text                  = LanguageSettings.Current.General.PleaseWait;
            labelResolution.Text                  = LanguageSettings.Current.SubStationAlphaProperties.Resolution;
            labelPreviewPleaseWait.Text           = LanguageSettings.Current.General.PleaseWait;
            labelFontSize.Text                    = LanguageSettings.Current.ExportPngXml.FontSize;
            labelSubtitleFont.Text                = LanguageSettings.Current.ExportPngXml.FontFamily;
            buttonCancel.Text                     = LanguageSettings.Current.General.Cancel;
            labelAudioEnc.Text                    = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Encoding;
            labelVideoEncoding.Text               = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Encoding;
            labelAudioBitRate.Text                = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.BitRate;
            labelAudioSampleRate.Text             = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.SampleRate;
            checkBoxMakeStereo.Text               = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Stereo;
            labelCRF.Text                         = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Crf;
            labelPreset.Text                      = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Preset;
            labelTune.Text                        = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TuneFor;
            buttonPreview.Text                    = LanguageSettings.Current.General.Preview;
            checkBoxRightToLeft.Text              = LanguageSettings.Current.Settings.FixRTLViaUnicodeChars;
            checkBoxAlignRight.Text               = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.AlignRight;
            checkBoxBox.Text                      = LanguageSettings.Current.SubStationAlphaStyles.OpaqueBox;
            progressBar1.Visible                  = false;
            labelPleaseWait.Visible               = false;
            labelPreviewPleaseWait.Visible        = false;
            labelProgress.Text                    = string.Empty;
            labelFileName.Text                    = string.Empty;
            labelPass.Text                        = string.Empty;
            comboBoxVideoEncoding.SelectedIndex   = 0;
            comboBoxCrf.SelectedIndex             = 6;
            comboBoxAudioEnc.SelectedIndex        = 0;
            comboBoxAudioSampleRate.SelectedIndex = 1;
            comboBoxTune.SelectedIndex            = 0;
            comboBoxAudioBitRate.Text             = "128k";
            checkBoxTargetFileSize_CheckedChanged(null, null);
            checkBoxTargetFileSize.Text      = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TargetFileSize;
            labelFileSize.Text               = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.FileSizeMb;
            numericUpDownTargetFileSize.Left = labelFileSize.Left + labelFileSize.Width + 5;
            linkLabelHelp.Text               = LanguageSettings.Current.Main.Menu.Help.Title;
            groupBoxSettings.Text            = LanguageSettings.Current.Settings.Title;
            groupBoxVideo.Text               = LanguageSettings.Current.Main.Menu.Video.Title;
            groupBoxAudio.Text               = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Audio;

            comboBoxVideoEncoding.Text     = Configuration.Settings.Tools.GenVideoEncoding;
            comboBoxCrf.Text               = Configuration.Settings.Tools.GenVideoCrf;
            comboBoxTune.Text              = Configuration.Settings.Tools.GenVideoTune;
            comboBoxAudioEnc.Text          = Configuration.Settings.Tools.GenVideoAudioEncoding;
            comboBoxAudioSampleRate.Text   = Configuration.Settings.Tools.GenVideoAudioSampleRate;
            checkBoxMakeStereo.Checked     = Configuration.Settings.Tools.GenVideoAudioForceStereo;
            checkBoxTargetFileSize.Checked = Configuration.Settings.Tools.GenVideoTargetFileSize;
            checkBoxBox.Checked            = Configuration.Settings.Tools.GenVideoNonAssaBox;
            checkBoxAlignRight.Checked     = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;
            checkBoxRightToLeft.Checked    = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;

            numericUpDownWidth.Value  = _videoInfo.Width;
            numericUpDownHeight.Value = _videoInfo.Height;

            var left = Math.Max(Math.Max(labelResolution.Left + labelResolution.Width, labelFontSize.Left + labelFontSize.Width), labelSubtitleFont.Left + labelSubtitleFont.Width) + 5;

            numericUpDownFontSize.Left = left;
            comboBoxSubtitleFont.Left  = left;
            numericUpDownWidth.Left    = left;
            labelX.Left = numericUpDownWidth.Left + numericUpDownWidth.Width + 3;
            numericUpDownHeight.Left          = labelX.Left + labelX.Width + 3;
            buttonVideoChooseStandardRes.Left = numericUpDownHeight.Left + numericUpDownHeight.Width + 9;
            labelInfo.Text           = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOff;
            checkBoxRightToLeft.Left = left;
            checkBoxAlignRight.Left  = left;
            checkBoxBox.Left         = left;

            var audioLeft = Math.Max(Math.Max(labelAudioEnc.Left + labelAudioEnc.Width, labelAudioSampleRate.Left + labelAudioSampleRate.Width), labelAudioBitRate.Left + labelAudioBitRate.Width) + 5;

            comboBoxAudioEnc.Left        = audioLeft;
            checkBoxMakeStereo.Left      = audioLeft;
            comboBoxAudioSampleRate.Left = audioLeft;
            comboBoxAudioBitRate.Left    = audioLeft;

            linkLabelHelp.Left = Width - linkLabelHelp.Width - 30;

            _isAssa = !fontSize.HasValue;
            if (fontSize.HasValue)
            {
                if (fontSize.Value < numericUpDownFontSize.Minimum)
                {
                    numericUpDownFontSize.Value = numericUpDownFontSize.Minimum;
                }
                else if (fontSize.Value > numericUpDownFontSize.Maximum)
                {
                    numericUpDownFontSize.Value = numericUpDownFontSize.Maximum;
                }
                else
                {
                    numericUpDownFontSize.Value = fontSize.Value;
                }

                checkBoxRightToLeft.Checked = Configuration.Settings.General.RightToLeftMode &&
                                              LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle);
            }
            else
            {
                numericUpDownFontSize.Enabled = false;
                labelFontSize.Enabled         = false;
                labelSubtitleFont.Enabled     = false;
                comboBoxSubtitleFont.Enabled  = false;
                checkBoxRightToLeft.Left      = checkBoxTargetFileSize.Left;
                checkBoxAlignRight.Enabled    = false;
                checkBoxBox.Enabled           = false;
                labelInfo.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOn;
            }

            var initialFont = Configuration.Settings.Tools.ExportBluRayFontName;

            if (string.IsNullOrEmpty(initialFont))
            {
                initialFont = UiUtil.GetDefaultFont().Name;
            }
            foreach (var x in FontFamily.Families)
            {
                if (x.IsStyleAvailable(FontStyle.Regular) || x.IsStyleAvailable(FontStyle.Bold))
                {
                    comboBoxSubtitleFont.Items.Add(x.Name);
                    if (x.Name.Equals(initialFont, StringComparison.OrdinalIgnoreCase))
                    {
                        comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1;
                    }
                }
            }
            if (comboBoxSubtitleFont.SelectedIndex < 0 && comboBoxSubtitleFont.Items.Count > 0)
            {
                comboBoxSubtitleFont.SelectedIndex = 0;
            }

            checkBoxRightToLeft.Checked = Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle);
            textBoxLog.Visible          = false;
        }
예제 #16
0
        private void ExtractAudio()
        {
            try
            {
                _waveFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav");
                Process process;
                try
                {
                    process = GetCommandLineProcess(_videoFileName, -1, _waveFileName, Configuration.Settings.General.VlcWaveTranscodeSettings, out var waveExtractor);
                    _backgroundWorker.ReportProgress(0, string.Format(LanguageSettings.Current.AudioToText.ExtractingAudioUsingX, waveExtractor));
                }
                catch (DllNotFoundException)
                {
                    if (MessageBox.Show(LanguageSettings.Current.AddWaveform.VlcMediaPlayerNotFound + Environment.NewLine +
                                        Environment.NewLine + LanguageSettings.Current.AddWaveform.GoToVlcMediaPlayerHomePage,
                                        LanguageSettings.Current.AddWaveform.VlcMediaPlayerNotFoundTitle,
                                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        UiUtil.OpenUrl("http://www.videolan.org/");
                    }
                    return;
                }

                process.Start();
                while (!process.HasExited && !_abort)
                {
                    Application.DoEvents();
                }

                // check for delay in matroska files
                var mkvAudioTrackNumbers = new Dictionary <int, int>();
                if (_videoFileName.ToLowerInvariant().EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
                {
                    MatroskaFile matroska = null;
                    try
                    {
                        matroska = new MatroskaFile(_videoFileName);

                        if (matroska.IsValid)
                        {
                            foreach (var track in matroska.GetTracks())
                            {
                                if (track.IsAudio)
                                {
                                    var audioTrackNames = new List <string>();
                                    if (track.CodecId != null && track.Language != null)
                                    {
                                        audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty));
                                    }
                                    else
                                    {
                                        audioTrackNames.Add("#" + track.TrackNumber);
                                    }

                                    mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber);
                                }
                            }
                            if (mkvAudioTrackNumbers.Count > 0)
                            {
                                _delayInMilliseconds = (int)matroska.GetTrackStartTime(mkvAudioTrackNumbers[0]);
                            }
                        }
                    }
                    catch
                    {
                        _delayInMilliseconds = 0;
                    }
                    finally
                    {
                        matroska?.Dispose();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #17
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            var finalMkv = string.Empty;

            if (radioButtonVideo.Checked)
            {
                if (string.IsNullOrEmpty(_audioFileName) || !File.Exists(_audioFileName))
                {
                    MessageBox.Show("Please select an audio file!");
                    return;
                }

                if (_originalBackgroundImage == null)
                {
                    MessageBox.Show("Please select a background image file!");
                    return;
                }

                if (Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(textBoxFFmpegPath.Text) || !File.Exists(textBoxFFmpegPath.Text)))
                {
                    MessageBox.Show("mkvmerge.exe not found!");
                    return;
                }

                if (Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) || !File.Exists(Configuration.Settings.General.FFmpegLocation)))
                {
                    MessageBox.Show("ffmpeg not configured!");
                    return;
                }

                saveFileDialog1.Filter   = "Matroska (*.mkv)|*.mkv";
                saveFileDialog1.FileName = FileName.Substring(0, FileName.Length - 3) + "mkv";
                if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                finalMkv = saveFileDialog1.FileName;
            }

            radioButtonBluRaySup.Enabled = false;
            radioButtonVideo.Enabled     = false;
            buttonStart.Enabled          = false;

            var cdgToImageList = new CdgToImageList();
            var bw             = new BackgroundWorker {
                WorkerReportsProgress = true
            };

            bw.DoWork             += (o, args) => { _imageList = cdgToImageList.MakeImageList(_cdgGraphics, _subtitle, (number, unique) => { bw.ReportProgress(number, unique); }); };
            bw.RunWorkerCompleted += (o, args) =>
            {
                if (radioButtonBluRaySup.Checked)
                {
                    using (var exportBdnXmlPng = new ExportPngXml())
                    {
                        exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), ExportPngXml.ExportFormats.BluraySup, FileName, this, "Test123");
                        exportBdnXmlPng.ShowDialog(this);
                    }
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    var tempFolder  = Path.GetTempPath();
                    var supFileName = Path.Combine(tempFolder, Guid.NewGuid() + ".sup");
                    using (var binarySubtitleFile = new FileStream(supFileName, FileMode.Create))
                    {
                        labelStatus.Text = "Generating Blu-ray sup file...";
                        labelStatus.Refresh();

                        var bottomMargin = comboBoxBottomMargin.SelectedIndex;
                        var leftMargin   = comboBoxLeftRightMargin.SelectedIndex;
                        for (var index = 0; index < _subtitle.Paragraphs.Count; index++)
                        {
                            var p     = _subtitle.Paragraphs[index];
                            var image = _imageList[index].GetBitmap();
                            var brSub = new BluRaySupPicture
                            {
                                StartTime         = (long)p.StartTime.TotalMilliseconds,
                                EndTime           = (long)p.EndTime.TotalMilliseconds,
                                Width             = VideoWidth,
                                Height            = VideoHeight,
                                CompositionNumber = p.Number * 2
                            };

                            var buffer = BluRaySupPicture.CreateSupFrame(brSub, image, 25, bottomMargin, leftMargin, ContentAlignment.BottomLeft);
                            binarySubtitleFile.Write(buffer, 0, buffer.Length);
                        }
                    }

                    if (!string.IsNullOrEmpty(supFileName) && File.Exists(supFileName))
                    {
                        labelStatus.Text = "Generating video...";
                        labelStatus.Refresh();
                        var tempImageFileName = Path.Combine(tempFolder, Guid.NewGuid() + ".png");
                        _resizedBackgroundImage.Save(tempImageFileName, ImageFormat.Png);
                        var tempMkv          = Path.Combine(tempFolder, Guid.NewGuid() + ".mkv");
                        var processMakeVideo = GetFFmpegProcess(tempImageFileName, _audioFileName, tempMkv);
                        processMakeVideo.Start();
                        processMakeVideo.WaitForExit();

                        labelStatus.Text = "Adding subtitles to video...";
                        labelStatus.Refresh();
                        var processAddSubtitles = GetMkvMergeProcess(tempMkv, supFileName, finalMkv);
                        processAddSubtitles.Start();
                        processAddSubtitles.WaitForExit();
                        labelStatus.Text = string.Empty;

                        UiUtil.OpenFolderFromFileName(finalMkv);

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

                    DialogResult = DialogResult.OK;
                }
            };
            labelStatus.Text = "Extracting images...";
            labelStatus.Refresh();
            bw.RunWorkerAsync();
        }
예제 #18
0
        public EbuSaveOptions()
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            var language = Configuration.Settings.Language.EbuSaveOptions;

            Text = language.Title;
            tabPageHeader.Text        = language.GeneralSubtitleInformation;
            tabPageTextAndTiming.Text = language.TextAndTimingInformation;
            tabPageErrors.Text        = language.Errors;

            labelCodePageNumber.Text            = language.CodePageNumber;
            labelDiskFormatCode.Text            = language.DiskFormatCode;
            labelDisplayStandardCode.Text       = language.DisplayStandardCode;
            labelColorRequiresTeletext.Text     = language.ColorRequiresTeletext;
            labelCharacterCodeTable.Text        = language.CharacterCodeTable;
            labelLanguageCode.Text              = language.LanguageCode;
            labelOriginalProgramTitle.Text      = language.OriginalProgramTitle;
            labelOriginalEpisodeTitle.Text      = language.OriginalEpisodeTitle;
            labelTranslatedProgramTitle.Text    = language.TranslatedProgramTitle;
            labelTranslatedEpisodeTitle.Text    = language.TranslatedEpisodeTitle;
            labelTranslatorsName.Text           = language.TranslatorsName;
            labelSubtitleListReferenceCode.Text = language.SubtitleListReferenceCode;
            labelCountryOfOrigin.Text           = language.CountryOfOrigin;
            labelTimeCodeStatus.Text            = language.TimeCodeStatus;
            labelTimeCodeStartOfProgramme.Text  = language.TimeCodeStartOfProgramme;
            labelFrameRate.Text = Configuration.Settings.Language.General.FrameRate;

            labelRevisionNumber.Text             = language.RevisionNumber;
            labelMaxNoOfDisplayableChars.Text    = language.MaxNoOfDisplayableChars;
            labelMaxNumberOfDisplayableRows.Text = language.MaxNumberOfDisplayableRows;
            labelDiskSequenceNumber.Text         = language.DiskSequenceNumber;
            labelTotalNumberOfDisks.Text         = language.TotalNumberOfDisks;

            buttonImport.Text = language.Import;

            labelJustificationCode.Text = language.JustificationCode;
            comboBoxJustificationCode.Items.Clear();
            comboBoxJustificationCode.Items.Add(language.TextUnchangedPresentation);
            comboBoxJustificationCode.Items.Add(language.TextLeftJustifiedText);
            comboBoxJustificationCode.Items.Add(language.TextCenteredText);
            comboBoxJustificationCode.Items.Add(language.TextRightJustifiedText);
            groupBoxTeletext.Text         = language.Teletext;
            groupBoxVerticalPosition.Text = language.VerticalPosition;
            labelMarginTop.Text           = language.MarginTop;
            labelMarginBottom.Text        = language.MarginBottom;
            labelNewLineRows.Text         = language.NewLineRows;
            int tempW = labelMarginTop.Left + 9 + Math.Max(Math.Max(labelMarginTop.Width, labelMarginBottom.Width), labelNewLineRows.Width);

            numericUpDownMarginTop.Left       = tempW;
            numericUpDownMarginBottom.Left    = tempW;
            numericUpDownNewLineRows.Left     = tempW;
            checkBoxTeletextBox.Text          = language.UseBox;
            checkBoxTeletextDoubleHeight.Text = language.DoubleHeight;

            labelErrors.Text = language.Errors;

            buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
            buttonOK.Text     = Configuration.Settings.Language.General.Ok;

            timeUpDownStartTime.ForceHHMMSSFF();
        }
예제 #19
0
 private void buttonDownloadMkvToolNix_Click(object sender, EventArgs e)
 {
     UiUtil.OpenUrl("https://mkvtoolnix.download/downloads.html");
 }
예제 #20
0
        public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format)
        {
            ShowBasic = false;
            _subtitle = subtitle;
            if (string.IsNullOrEmpty(fileName))
            {
                textBoxFileName.Text = LanguageSettings.Current.SplitSubtitle.Untitled;
            }
            else
            {
                textBoxFileName.Text = fileName;
            }

            _fileName = fileName;
            foreach (Paragraph p in _subtitle.Paragraphs)
            {
                _totalNumberOfCharacters += HtmlUtil.RemoveHtmlTags(p.Text, true).Length;
            }

            labelLines.Text      = string.Format(LanguageSettings.Current.Split.NumberOfLinesX, _subtitle.Paragraphs.Count);
            labelCharacters.Text = string.Format(LanguageSettings.Current.Split.NumberOfCharactersX, _totalNumberOfCharacters);

            try
            {
                numericUpDownParts.Value = Configuration.Settings.Tools.SplitNumberOfParts;
            }
            catch
            {
                // ignored
            }

            if (Configuration.Settings.Tools.SplitVia.Trim().Equals("lines", StringComparison.OrdinalIgnoreCase))
            {
                RadioButtonLines.Checked = true;
            }
            else if (Configuration.Settings.Tools.SplitVia.Trim().Equals("time", StringComparison.OrdinalIgnoreCase))
            {
                radioButtonTime.Checked = true;
            }
            else
            {
                radioButtonCharacters.Checked = true;
            }

            UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, format.FriendlyName);

            UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding);

            if (numericUpDownParts.Maximum > _subtitle.Paragraphs.Count)
            {
                numericUpDownParts.Maximum = (int)Math.Round(_subtitle.Paragraphs.Count / 2.0);
            }

            if (!string.IsNullOrEmpty(_fileName))
            {
                textBoxOutputFolder.Text = Path.GetDirectoryName(_fileName);
            }
            else if (string.IsNullOrEmpty(Configuration.Settings.Tools.SplitOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.SplitOutputFolder))
            {
                textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            }
            else
            {
                textBoxOutputFolder.Text = Configuration.Settings.Tools.SplitOutputFolder;
            }
        }
예제 #21
0
 private void linkLabelOpenFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     UiUtil.OpenFolder(_folder);
 }
예제 #22
0
        public ImportText(string fileName = null, Form parentForm = null)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            Text = Configuration.Settings.Language.ImportText.Title;
            groupBoxImportText.Text    = Configuration.Settings.Language.ImportText.Title;
            buttonOpenText.Text        = Configuration.Settings.Language.ImportText.OpenTextFile;
            groupBoxImportOptions.Text = Configuration.Settings.Language.ImportText.ImportOptions;
            groupBoxSplitting.Text     = Configuration.Settings.Language.ImportText.Splitting;
            radioButtonAutoSplit.Text  = Configuration.Settings.Language.ImportText.AutoSplitText;
            radioButtonLineMode.Text   = string.Empty;
            comboBoxLineMode.Items.Clear();
            comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.OneLineIsOneSubtitle);
            comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.TwoLinesAreOneSubtitle);
            comboBoxLineMode.SelectedIndex = 0;
            labelLineBreak.Text            = Configuration.Settings.Language.ImportText.LineBreak;
            columnHeaderFName.Text         = Configuration.Settings.Language.JoinSubtitles.FileName;
            columnHeaderSize.Text          = Configuration.Settings.Language.General.Size;
            comboBoxLineBreak.Left         = labelLineBreak.Left + labelLineBreak.Width + 3;
            comboBoxLineBreak.Width        = groupBoxSplitting.Width - comboBoxLineBreak.Left - 5;
            checkBoxMultipleFiles.AutoSize = true;
            checkBoxMultipleFiles.Left     = buttonOpenText.Left - checkBoxMultipleFiles.Width - 9;
            checkBoxMultipleFiles.Text     = Configuration.Settings.Language.ImportText.OneSubtitleIsOneFile;
            listViewInputFiles.Visible     = false;
            labelSubMaxLen.Text            = Configuration.Settings.Language.Settings.SubtitleLineMaximumLength;
            numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3;

            radioButtonSplitAtBlankLines.Text          = Configuration.Settings.Language.ImportText.SplitAtBlankLines;
            checkBoxMergeShortLines.Text               = Configuration.Settings.Language.ImportText.MergeShortLines;
            checkBoxRemoveEmptyLines.Text              = Configuration.Settings.Language.ImportText.RemoveEmptyLines;
            checkBoxRemoveLinesWithoutLetters.Text     = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters;
            checkBoxAutoSplitRemoveLinesNoLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters;
            checkBoxGenerateTimeCodes.Text             = Configuration.Settings.Language.ImportText.GenerateTimeCodes;
            checkBoxAutoBreak.Text            = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak;
            labelGapBetweenSubtitles.Text     = Configuration.Settings.Language.ImportText.GapBetweenSubtitles;
            numericUpDownGapBetweenLines.Left = labelGapBetweenSubtitles.Left + labelGapBetweenSubtitles.Width + 3;
            groupBoxDuration.Text             = Configuration.Settings.Language.General.Duration;
            radioButtonDurationAuto.Text      = Configuration.Settings.Language.ImportText.Auto;
            radioButtonDurationFixed.Text     = Configuration.Settings.Language.ImportText.Fixed;
            buttonRefresh.Text          = Configuration.Settings.Language.ImportText.Refresh;
            groupBoxTimeCodes.Text      = Configuration.Settings.Language.ImportText.TimeCodes;
            groupBoxImportResult.Text   = Configuration.Settings.Language.General.Preview;
            clearToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.Clear;
            startNumberingFromToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Tools.StartNumberingFrom;
            buttonOK.Text     = Configuration.Settings.Language.General.Ok;
            buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
            SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
            UiUtil.InitializeSubtitleFont(SubtitleListview1);
            SubtitleListview1.AutoSizeAllColumns(this);

            if (string.IsNullOrEmpty(Configuration.Settings.Tools.ImportTextSplitting))
            {
                radioButtonAutoSplit.Checked = true;
            }
            else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("blank lines", StringComparison.OrdinalIgnoreCase))
            {
                radioButtonSplitAtBlankLines.Checked = true;
            }
            else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("line", StringComparison.OrdinalIgnoreCase))
            {
                radioButtonLineMode.Checked = true;
            }

            comboBoxLineBreak.Text                        = Configuration.Settings.Tools.ImportTextLineBreak;
            checkBoxMergeShortLines.Checked               = Configuration.Settings.Tools.ImportTextMergeShortLines;
            checkBoxRemoveEmptyLines.Checked              = Configuration.Settings.Tools.ImportTextRemoveEmptyLines;
            checkBoxAutoSplitAtBlankLines.Checked         = Configuration.Settings.Tools.ImportTextAutoSplitAtBlank;
            checkBoxRemoveLinesWithoutLetters.Checked     = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters;
            checkBoxAutoSplitRemoveLinesNoLetters.Checked = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters;
            checkBoxGenerateTimeCodes.Checked             = Configuration.Settings.Tools.ImportTextGenerateTimeCodes;
            checkBoxAutoBreak.Checked                     = Configuration.Settings.Tools.ImportTextAutoBreak;
            textBoxAsEnd.Text = Configuration.Settings.Tools.ImportTextAutoBreakAtEndMarkerText.Replace(" ", string.Empty);
            checkBoxAutoSplitAtEnd.Checked = Configuration.Settings.Tools.ImportTextAutoBreakAtEnd;
            checkBoxAutoSplitAtEnd.Text    = Configuration.Settings.Language.ImportText.SplitAtEndChars;
            textBoxAsEnd.Left = checkBoxAutoSplitAtEnd.Left + checkBoxAutoSplitAtEnd.Width;
            checkBoxAutoSplitAtBlankLines.Text = Configuration.Settings.Language.ImportText.SplitAtBlankLines;

            groupBoxAutoSplitSettings.Text               = Configuration.Settings.Language.Settings.Title;
            labelAutoSplitNumberOfLines.Text             = Configuration.Settings.Language.Settings.MaximumLines;
            numericUpDownSubtitleLineMaximumLength.Left  = labelSubMaxLen.Left + labelSubMaxLen.Width + 3;
            numericUpDownSubtitleLineMaximumLength.Value = Configuration.Settings.General.SubtitleLineMaximumLength;

            if (Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines >= numericUpDownAutoSplitMaxLines.Minimum &&
                Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines <= numericUpDownAutoSplitMaxLines.Maximum)
            {
                numericUpDownAutoSplitMaxLines.Value = Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines;
            }

            if (Configuration.Settings.Tools.ImportTextGap >= numericUpDownGapBetweenLines.Minimum && Configuration.Settings.Tools.ImportTextGap <= numericUpDownGapBetweenLines.Maximum)
            {
                numericUpDownGapBetweenLines.Value = Configuration.Settings.Tools.ImportTextGap;
            }
            if (Configuration.Settings.Tools.ImportTextDurationAuto)
            {
                radioButtonDurationAuto.Checked = true;
            }
            else
            {
                radioButtonDurationFixed.Checked = true;
            }
            numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked;
            if (Configuration.Settings.Tools.ImportTextFixedDuration >= numericUpDownDurationFixed.Minimum &&
                Configuration.Settings.Tools.ImportTextFixedDuration <= numericUpDownDurationFixed.Maximum)
            {
                numericUpDownDurationFixed.Value = Configuration.Settings.Tools.ImportTextFixedDuration;
            }
            UiUtil.FixLargeFonts(this, buttonOK);
            _refreshTimer.Interval = 400;
            _refreshTimer.Tick    += RefreshTimerTick;

            if (fileName != null && File.Exists(fileName))
            {
                if (!LoadSingleFile(fileName, parentForm))
                {
                    _exit = true;
                }
            }
        }
예제 #23
0
 private void GetTime_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         DialogResult = DialogResult.Cancel;
     }
     else if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
     {
         videoPlayerContainer1.Pause();
         e.SuppressKeyPress = true;
     }
     else if (e.KeyCode == Keys.P && e.Control)
     {
         videoPlayerContainer1.VideoPlayer.Pause();
         e.SuppressKeyPress = true;
     }
     else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left)
     {
         GoBackSeconds(0.5, videoPlayerContainer1.VideoPlayer);
         e.SuppressKeyPress = true;
     }
     else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right)
     {
         GoBackSeconds(-0.5, videoPlayerContainer1.VideoPlayer);
         e.SuppressKeyPress = true;
     }
     else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left)
     {
         GoBackSeconds(0.1, videoPlayerContainer1.VideoPlayer);
         e.SuppressKeyPress = true;
     }
     else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right)
     {
         GoBackSeconds(-0.1, videoPlayerContainer1.VideoPlayer);
         e.SuppressKeyPress = true;
     }
     else if (e.KeyData == UiUtil.HelpKeys)
     {
         UiUtil.ShowHelp("#sync");
         e.SuppressKeyPress = true;
     }
     else if (_mainGeneralGoToNextSubtitle == e.KeyData || _mainGeneralGoToNextSubtitlePlayTranslate == e.KeyData)
     {
         int selectedIndex = 0;
         if (subtitleListView1.SelectedItems.Count > 0)
         {
             selectedIndex = subtitleListView1.SelectedItems[0].Index;
             selectedIndex++;
         }
         subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex);
         e.SuppressKeyPress = true;
     }
     else if (_mainGeneralGoToPrevSubtitle == e.KeyData || _mainGeneralGoToPrevSubtitlePlayTranslate == e.KeyData)
     {
         int selectedIndex = 0;
         if (subtitleListView1.SelectedItems.Count > 0)
         {
             selectedIndex = subtitleListView1.SelectedItems[0].Index;
             selectedIndex--;
         }
         subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex);
         e.SuppressKeyPress = true;
     }
 }
예제 #24
0
        private void SETextBox_DragDrop(object sender, DragEventArgs e)
        {
            var pt    = PointToClient(new Point(e.X, e.Y));
            int index = GetCharIndexFromPosition(pt);

            string newText;

            if (e.Data.GetDataPresent(DataFormats.UnicodeText))
            {
                newText = (string)e.Data.GetData(DataFormats.UnicodeText);
            }
            else
            {
                newText = (string)e.Data.GetData(DataFormats.Text);
            }

            if (string.IsNullOrWhiteSpace(Text))
            {
                Text = newText;
            }
            else
            {
                bool         justAppend    = index == Text.Length - 1 && index > 0;
                const string expectedChars = ":;]<.!?";
                if (_dragFromThis)
                {
                    _dragFromThis = false;
                    long milliseconds = (DateTime.UtcNow.Ticks - _dragStartTicks) / 10000;
                    if (milliseconds < 400)
                    {
                        SelectionLength = 0;
                        if (justAppend)
                        {
                            index++;
                        }
                        SelectionStart = index;
                        return; // too fast - nobody can drag'n'drop this fast
                    }

                    if (index >= _dragStartFrom && index <= _dragStartFrom + _dragText.Length)
                    {
                        return; // don't drop same text at same position
                    }
                    if (_dragRemoveOld)
                    {
                        _dragRemoveOld = false;
                        Text           = Text.Remove(_dragStartFrom, _dragText.Length);

                        // fix spaces
                        if (_dragStartFrom == 0 && Text.Length > 0 && Text[0] == ' ')
                        {
                            Text = Text.Remove(0, 1);
                            index--;
                        }
                        else if (_dragStartFrom > 1 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && Text[_dragStartFrom - 1] == ' ')
                        {
                            Text = Text.Remove(_dragStartFrom, 1);
                            if (_dragStartFrom < index)
                            {
                                index--;
                            }
                        }
                        else if (_dragStartFrom > 0 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && expectedChars.Contains(Text[_dragStartFrom + 1]))
                        {
                            Text = Text.Remove(_dragStartFrom, 1);
                            if (_dragStartFrom < index)
                            {
                                index--;
                            }
                        }

                        // fix index
                        if (index > _dragStartFrom)
                        {
                            index -= _dragText.Length;
                        }
                        if (index < 0)
                        {
                            index = 0;
                        }
                    }
                }
                if (justAppend)
                {
                    index = Text.Length;
                    Text += newText;
                }
                else
                {
                    Text = Text.Insert(index, newText);
                }

                // fix start spaces
                int endIndex = index + newText.Length;
                if (index > 0 && !newText.StartsWith(' ') && Text[index - 1] != ' ')
                {
                    Text = Text.Insert(index, " ");
                    endIndex++;
                }
                else if (index > 0 && newText.StartsWith(' ') && Text[index - 1] == ' ')
                {
                    Text = Text.Remove(index, 1);
                    endIndex--;
                }

                // fix end spaces
                if (endIndex < Text.Length && !newText.EndsWith(' ') && Text[endIndex] != ' ')
                {
                    bool lastWord = expectedChars.Contains(Text[endIndex]);
                    if (!lastWord)
                    {
                        Text = Text.Insert(endIndex, " ");
                    }
                }
                else if (endIndex < Text.Length && newText.EndsWith(' ') && Text[endIndex] == ' ')
                {
                    Text = Text.Remove(endIndex, 1);
                }

                SelectionStart = index + 1;
                UiUtil.SelectWordAtCaret(this);
            }

            _dragRemoveOld = false;
            _dragFromThis  = false;
        }
예제 #25
0
 private Encoding GetCurrentEncoding()
 {
     return(UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding));
 }
        public DCinemaPropertiesSmpte()
        {
            InitializeComponent();

            var l = Configuration.Settings.Language.DCinemaProperties;

            Text = l.TitleSmpte;
            labelSubtitleID.Text       = l.SubtitleId;
            labelMovieTitle.Text       = l.MovieTitle;
            labelReelNumber.Text       = l.ReelNumber;
            labelLanguage.Text         = l.Language;
            labelIssueDate.Text        = l.IssueDate;
            labelEditRate.Text         = l.EditRate;
            labelTimeCodeRate.Text     = l.TimeCodeRate;
            labelStartTime.Text        = l.StartTime;
            groupBoxFont.Text          = l.Font;
            labelFontId.Text           = l.FontId;
            labelFontUri.Text          = l.FontUri;
            labelFontColor.Text        = l.FontColor;
            buttonFontColor.Text       = l.ChooseColor;
            labelEffect.Text           = l.FontEffect;
            labelEffectColor.Text      = l.FontEffectColor;
            buttonFontEffectColor.Text = l.ChooseColor;
            labelFontSize.Text         = l.FontSize;
            buttonGenerateID.Text      = l.Generate;
            buttonGenFontUri.Text      = l.Generate;

            foreach (CultureInfo x in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
            {
                comboBoxLanguage.Items.Add(x.TwoLetterISOLanguageName);
            }
            comboBoxLanguage.Sorted = true;

            var ss = Configuration.Settings.SubtitleSettings;

            if (!string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId))
            {
                textBoxSubtitleID.Text = ss.CurrentDCinemaSubtitleId;
                int number;
                if (int.TryParse(ss.CurrentDCinemaReelNumber, out number) &&
                    numericUpDownReelNumber.Minimum <= number && numericUpDownReelNumber.Maximum >= number)
                {
                    numericUpDownReelNumber.Value = number;
                }
                textBoxMovieTitle.Text    = ss.CurrentDCinemaMovieTitle;
                comboBoxLanguage.Text     = ss.CurrentDCinemaLanguage;
                textBoxFontID.Text        = ss.CurrentDCinemaFontId;
                textBoxEditRate.Text      = ss.CurrentDCinemaEditRate;
                comboBoxTimeCodeRate.Text = ss.CurrentDCinemaTimeCodeRate;

                timeUpDownStartTime.ForceHHMMSSFF();
                if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime))
                {
                    ss.CurrentDCinemaStartTime = "00:00:00:00";
                }
                timeUpDownStartTime.MaskedTextBox.Text = ss.CurrentDCinemaStartTime;

                textBoxFontUri.Text      = ss.CurrentDCinemaFontUri;
                textBoxIssueDate.Text    = ss.CurrentDCinemaIssueDate;
                panelFontColor.BackColor = ss.CurrentDCinemaFontColor;
                if (ss.CurrentDCinemaFontEffect == "border")
                {
                    comboBoxFontEffect.SelectedIndex = 1;
                }
                else if (ss.CurrentDCinemaFontEffect == "shadow")
                {
                    comboBoxFontEffect.SelectedIndex = 2;
                }
                else
                {
                    comboBoxFontEffect.SelectedIndex = 0;
                }
                panelFontEffectColor.BackColor = ss.CurrentDCinemaFontEffectColor;
                numericUpDownFontSize.Value    = ss.CurrentDCinemaFontSize;
                if (numericUpDownTopBottomMargin.Minimum <= ss.DCinemaBottomMargin &&
                    numericUpDownTopBottomMargin.Maximum >= ss.DCinemaBottomMargin)
                {
                    numericUpDownTopBottomMargin.Value = ss.DCinemaBottomMargin;
                }
                else
                {
                    numericUpDownTopBottomMargin.Value = 8;
                }
            }
            UiUtil.FixLargeFonts(this, buttonCancel);
        }
예제 #27
0
        public ExportFcpXmlAdvanced(Subtitle subtitle, string videoFileName)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            _subtitle      = new Subtitle(subtitle);
            _videoFileName = videoFileName;

            Text = Configuration.Settings.Language.ExportFcpXmlAdvanced.Title;
            groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings;
            buttonColor.Text           = Configuration.Settings.Language.ExportPngXml.FontColor;
            labelSubtitleFont.Text     = Configuration.Settings.Language.ExportFcpXmlAdvanced.FontName;
            labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportFcpXmlAdvanced.FontSize;
            labelSubtitleFontFace.Text = Configuration.Settings.Language.ExportFcpXmlAdvanced.FontFace;
            labelHorizontalAlign.Text  = Configuration.Settings.Language.ExportFcpXmlAdvanced.Alignment;
            labelBaseline.Text         = Configuration.Settings.Language.ExportFcpXmlAdvanced.Baseline;
            labelFrameRate.Text        = Configuration.Settings.Language.General.FrameRate;
            labelResolution.Text       = Configuration.Settings.Language.ExportPngXml.VideoResolution;
            buttonSave.Text            = Configuration.Settings.Language.ExportCustomText.SaveAs;
            buttonCancel.Text          = Configuration.Settings.Language.General.Cancel;

            comboBoxHAlign.Items.Clear();
            comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Left);
            comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Center);
            comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Right);
            comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustify);

            foreach (var x in FontFamily.Families)
            {
                if (x.IsStyleAvailable(FontStyle.Regular) || x.IsStyleAvailable(FontStyle.Bold))
                {
                    comboBoxFontName.Items.Add(x.Name);
                    if (x.Name.Equals(_fontName, StringComparison.OrdinalIgnoreCase))
                    {
                        comboBoxFontName.SelectedIndex = comboBoxFontName.Items.Count - 1;
                    }
                }
            }

            comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(30.00.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(50.00.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture));
            comboBoxFrameRate.Items.Add(60.00.ToString(CultureInfo.CurrentCulture));

            comboBoxResolution.Items.Clear();
            comboBoxResolution.Items.Add("NTSC-601");
            comboBoxResolution.Items.Add("PAL-601");
            comboBoxResolution.Items.Add("square");
            comboBoxResolution.Items.Add("DVCPROHD-720P");
            comboBoxResolution.Items.Add("HD-(960x720)");
            comboBoxResolution.Items.Add("DVCPROHD-1080i60");
            comboBoxResolution.Items.Add("HD-(1280x1080)");
            comboBoxResolution.Items.Add("FullHD 1920x1080");
            comboBoxResolution.Items.Add("DVCPROHD-1080i50");
            comboBoxResolution.Items.Add("HD-(1440x1080)");
            comboBoxResolution.SelectedIndex = 7; // FullHD

            comboBoxFontName.SelectedIndex = 0;
            for (int i = 0; i < comboBoxFontName.Items.Count; i++)
            {
                if (Configuration.Settings.FcpExportSettings.FontName == comboBoxFontName.Items[i].ToString())
                {
                    comboBoxFontName.SelectedIndex = i;
                    break;
                }
            }

            comboBoxFontSize.SelectedIndex = 21;
            for (int i = 0; i < comboBoxFontSize.Items.Count; i++)
            {
                if (Configuration.Settings.FcpExportSettings.FontSize == int.Parse(comboBoxFontSize.Items[i].ToString()))
                {
                    comboBoxFontSize.SelectedIndex = i;
                    break;
                }
            }

            comboBoxFontFace.Items.Clear();
            comboBoxFontFace.Items.Add(Configuration.Settings.Language.ExportFcpXmlAdvanced.FontFaceRegular);
            comboBoxFontFace.SelectedIndex = 0;

            comboBoxHAlign.SelectedIndex = 1;
            for (int i = 0; i < comboBoxHAlign.Items.Count; i++)
            {
                if (Configuration.Settings.FcpExportSettings.Alignment == comboBoxHAlign.Items[i].ToString())
                {
                    comboBoxHAlign.SelectedIndex = i;
                    break;
                }
            }

            comboBoxBaseline.SelectedIndex = 27;
            for (int i = 0; i < comboBoxBaseline.Items.Count; i++)
            {
                if (Configuration.Settings.FcpExportSettings.Baseline == int.Parse(comboBoxBaseline.Items[i].ToString()))
                {
                    comboBoxBaseline.SelectedIndex = i;
                    break;
                }
            }

            comboBoxFrameRate.SelectedItem = Configuration.Settings.General.CurrentFrameRate.ToString(CultureInfo.CurrentCulture);

            panelColor.BackColor = Configuration.Settings.FcpExportSettings.Color;

            SubtitleListview.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
            SubtitleListview.InitializeTimestampColumnWidths(this);
            UiUtil.InitializeSubtitleFont(SubtitleListview);
            SubtitleListview.AutoSizeAllColumns(this);
            UiUtil.FixLargeFonts(this, buttonCancel);
            SubtitleListview.Fill(_subtitle.Paragraphs);
        }
예제 #28
0
 public Watermark()
 {
     InitializeComponent();
     UiUtil.FixLargeFonts(this, buttonOK);
 }
예제 #29
0
        public ModifySelection(Subtitle subtitle, SubtitleFormat format, SubtitleListView subtitleListView)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);
            _loading                   = true;
            _subtitle                  = subtitle;
            _format                    = format;
            _subtitleListView          = subtitleListView;
            labelInfo.Text             = string.Empty;
            comboBoxRule.SelectedIndex = 0;
            Text                                   = LanguageSettings.Current.ModifySelection.Title;
            buttonOK.Text                          = LanguageSettings.Current.General.Ok;
            buttonCancel.Text                      = LanguageSettings.Current.General.Cancel;
            buttonApply.Text                       = LanguageSettings.Current.General.Apply;
            groupBoxRule.Text                      = LanguageSettings.Current.ModifySelection.Rule;
            groupBoxWhatToDo.Text                  = LanguageSettings.Current.ModifySelection.DoWithMatches;
            checkBoxCaseSensitive.Text             = LanguageSettings.Current.ModifySelection.CaseSensitive;
            radioButtonNewSelection.Text           = LanguageSettings.Current.ModifySelection.MakeNewSelection;
            radioButtonAddToSelection.Text         = LanguageSettings.Current.ModifySelection.AddToCurrentSelection;
            radioButtonSubtractFromSelection.Text  = LanguageSettings.Current.ModifySelection.SubtractFromCurrentSelection;
            radioButtonIntersect.Text              = LanguageSettings.Current.ModifySelection.IntersectWithCurrentSelection;
            columnHeaderApply.Text                 = LanguageSettings.Current.General.Apply;
            columnHeaderLine.Text                  = LanguageSettings.Current.General.LineNumber;
            columnHeaderText.Text                  = LanguageSettings.Current.General.Text;
            toolStripMenuItemInverseSelection.Text = LanguageSettings.Current.Main.Menu.Edit.InverseSelection;
            toolStripMenuItemSelectAll.Text        = LanguageSettings.Current.Main.Menu.ContextMenu.SelectAll;

            listViewStyles.Visible = false;

            UiUtil.FixLargeFonts(this, buttonOK);

            comboBoxRule.Items.Clear();
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.Contains);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.StartsWith);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.EndsWith);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.NoContains);
            comboBoxRule.Items.Add(LanguageSettings.Current.ChangeCasing.AllUppercase);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.RegEx);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.UnequalLines);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.EqualLines);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationLessThan);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationGreaterThan);
            comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.MoreThanTwoLines);
            if (_format.HasStyleSupport)
            {
                comboBoxRule.Items.Add(LanguageSettings.Current.General.Style);
            }
            if (_format.HasStyleSupport && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha)))
            {
                comboBoxRule.Items.Add(LanguageSettings.Current.General.Actor);
            }

            checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive;
            textBoxText.Text = Configuration.Settings.Tools.ModifySelectionText;
            if (Configuration.Settings.Tools.ModifySelectionRule == "Starts with")
            {
                comboBoxRule.SelectedIndex = FunctionStartsWith;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Ends with")
            {
                comboBoxRule.SelectedIndex = FunctionEndsWith;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Not contains")
            {
                comboBoxRule.SelectedIndex = FunctionNotContains;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "AllUppercase")
            {
                comboBoxRule.SelectedIndex = FunctionAlUppercase;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "RegEx")
            {
                comboBoxRule.SelectedIndex = FunctionRegEx;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration <")
            {
                comboBoxRule.SelectedIndex = FunctionDurationLessThan;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration >")
            {
                comboBoxRule.SelectedIndex = FunctionDurationGreaterThan;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "More than two lines")
            {
                comboBoxRule.SelectedIndex = FunctionMoreThanTwoLines;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Style" && _format.HasStyleSupport)
            {
                comboBoxRule.SelectedIndex = FunctionStyle;
            }
            else if (Configuration.Settings.Tools.ModifySelectionRule == "Actor" && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha)))
            {
                comboBoxRule.SelectedIndex = FunctionActor;
            }
            else
            {
                comboBoxRule.SelectedIndex = 0;
            }

            if (!_format.HasStyleSupport)
            {
                listViewFixes.Columns.Remove(columnHeaderStyle);
            }
            ModifySelection_Resize(null, null);

            _loading = false;
            Preview();
        }
        public SubStationAlphaStylesBatchConvert(Subtitle subtitle, SubtitleFormat format)
            : base(subtitle)
        {
            UiUtil.PreInitialize(this);
            InitializeComponent();
            UiUtil.FixFonts(this);

            comboBoxWrapStyle.SelectedIndex = 2;
            comboBoxCollision.SelectedIndex = 0;
            _header            = subtitle.Header;
            _isSubStationAlpha = format.Name == SubStationAlpha.NameOfFormat;
            if (_header == null || !_header.Contains("style:", StringComparison.OrdinalIgnoreCase))
            {
                ResetHeader();
            }

            comboBoxFontName.Items.Clear();
            foreach (var x in FontFamily.Families)
            {
                comboBoxFontName.Items.Add(x.Name);
            }

            var l = Configuration.Settings.Language.SubStationAlphaStyles;

            Text = l.Title;
            groupBoxProperties.Text      = l.Properties;
            groupBoxFont.Text            = l.Font;
            labelFontName.Text           = l.FontName;
            labelFontSize.Text           = l.FontSize;
            checkBoxFontItalic.Text      = Configuration.Settings.Language.General.Italic;
            checkBoxFontBold.Text        = Configuration.Settings.Language.General.Bold;
            checkBoxFontUnderline.Text   = Configuration.Settings.Language.General.Underline;
            groupBoxAlignment.Text       = l.Alignment;
            radioButtonTopLeft.Text      = l.TopLeft;
            radioButtonTopCenter.Text    = l.TopCenter;
            radioButtonTopRight.Text     = l.TopRight;
            radioButtonMiddleLeft.Text   = l.MiddleLeft;
            radioButtonMiddleCenter.Text = l.MiddleCenter;
            radioButtonMiddleRight.Text  = l.MiddleRight;
            radioButtonBottomLeft.Text   = l.BottomLeft;
            radioButtonBottomCenter.Text = l.BottomCenter;
            radioButtonBottomRight.Text  = l.BottomRight;
            groupBoxColors.Text          = l.Colors;
            buttonPrimaryColor.Text      = l.Primary;
            buttonSecondaryColor.Text    = l.Secondary;
            buttonOutlineColor.Text      = l.Outline;
            buttonBackColor.Text         = l.Shadow;
            groupBoxMargins.Text         = l.Margins;
            labelMarginLeft.Text         = l.MarginLeft;
            labelMarginRight.Text        = l.MarginRight;
            labelMarginVertical.Text     = l.MarginVertical;
            groupBoxBorder.Text          = l.Border;
            radioButtonOutline.Text      = l.Outline;
            labelShadow.Text             = l.PlusShadow;
            radioButtonOpaqueBox.Text    = l.OpaqueBox;
            groupBoxPreview.Text         = Configuration.Settings.Language.General.Preview;

            if (_isSubStationAlpha)
            {
                Text = l.TitleSubstationAlpha;
                buttonOutlineColor.Text       = l.Tertiary;
                buttonBackColor.Text          = l.Back;
                checkBoxFontUnderline.Visible = false;

                labelWrapStyle.Visible               = false;
                comboBoxWrapStyle.Visible            = false;
                checkBoxScaleBorderAndShadow.Visible = false;

                numericUpDownOutline.Increment         = 1;
                numericUpDownOutline.DecimalPlaces     = 0;
                numericUpDownShadowWidth.Increment     = 1;
                numericUpDownShadowWidth.DecimalPlaces = 0;
            }

            buttonOK.Text     = Configuration.Settings.Language.General.Ok;
            buttonCancel.Text = Configuration.Settings.Language.General.Cancel;

            UiUtil.FixLargeFonts(this, buttonCancel);

            comboBoxFontName.Left      = labelFontName.Left + labelFontName.Width + 10;
            numericUpDownFontSize.Left = labelFontSize.Left + labelFontSize.Width + 10;
            if (comboBoxFontName.Left > numericUpDownFontSize.Left)
            {
                numericUpDownFontSize.Left = comboBoxFontName.Left;
            }
            else
            {
                comboBoxFontName.Left = numericUpDownFontSize.Left;
            }

            numericUpDownOutline.Left     = radioButtonOutline.Left + radioButtonOutline.Width + 5;
            labelShadow.Left              = numericUpDownOutline.Left + numericUpDownOutline.Width + 5;
            numericUpDownShadowWidth.Left = labelShadow.Left + labelShadow.Width + 5;
            checkBoxFontItalic.Left       = checkBoxFontBold.Left + checkBoxFontBold.Width + 12;
            checkBoxFontUnderline.Left    = checkBoxFontItalic.Left + checkBoxFontItalic.Width + 12;

            var l2 = Configuration.Settings.Language.SubStationAlphaProperties;

            groupBoxResolution.Text           = l2.Resolution;
            labelVideoResolution.Text         = l2.VideoResolution;
            groupBoxOptions.Text              = l2.Options;
            labelCollision.Text               = l2.Collision;
            labelWrapStyle.Text               = l2.WrapStyle;
            checkBoxScaleBorderAndShadow.Text = l2.ScaleBorderAndShadow;
        }