private void ResetSettings(ContinuationStyle continuationStyle) { if (MessageBox.Show(this, LanguageSettings.Current.Settings.ResetCustomContinuationStyleWarning, LanguageSettings.Current.General.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { LoadSettings(ContinuationUtilities.GetContinuationProfile(continuationStyle)); } }
private void UiElementChanged(object sender, EventArgs e) { var idx = listViewProfiles.SelectedItems.Count > 0 ? listViewProfiles.SelectedItems[0].Index : -1; if (idx < 0 || !_editOn) { return; } RulesProfiles[idx].Name = textBoxName.Text.Trim(); RulesProfiles[idx].SubtitleLineMaximumLength = (int)numericUpDownSubtitleLineMaximumLength.Value; RulesProfiles[idx].SubtitleOptimalCharactersPerSeconds = numericUpDownOptimalCharsSec.Value; RulesProfiles[idx].SubtitleMaximumCharactersPerSeconds = numericUpDownMaxCharsSec.Value; RulesProfiles[idx].SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; RulesProfiles[idx].SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; RulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; RulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; RulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value; RulesProfiles[idx].CpsIncludesSpace = checkBoxCpsIncludeWhiteSpace.Checked; RulesProfiles[idx].MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 10; RulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); RulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); UpdateRulesProfilesLine(idx); toolTipContinuationPreview.RemoveAll(); toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(RulesProfiles[idx].ContinuationStyle)); }
private void RefreshControls(object sender, EventArgs e) { if (_isUpdating) { return; } // Update preview var profile = CreateContinuationProfile(); var preview = ContinuationUtilities.GetContinuationStylePreview(profile); var previewSplit = preview.Split(new[] { "\n\n" }, StringSplitOptions.None); labelPreviewLine1.Text = previewSplit[0]; labelPreviewLine2.Text = previewSplit[1]; labelPreviewLine3.Text = previewSplit[2]; labelPreviewLine4.Text = previewSplit[4]; // Toggle gap controls labelGapSuffix.Enabled = checkBoxDifferentStyleGap.Checked; comboBoxGapSuffix.Enabled = checkBoxDifferentStyleGap.Checked; checkBoxGapSuffixAddForComma.Enabled = checkBoxDifferentStyleGap.Checked; checkBoxGapSuffixAddSpace.Enabled = checkBoxDifferentStyleGap.Checked; checkBoxGapSuffixRemoveComma.Enabled = checkBoxDifferentStyleGap.Checked; labelGapPrefix.Enabled = checkBoxDifferentStyleGap.Checked; comboBoxGapPrefix.Enabled = checkBoxDifferentStyleGap.Checked; checkBoxGapPrefixAddSpace.Enabled = checkBoxDifferentStyleGap.Checked; }
public void Initialize(Subtitle subtitle) { if (subtitle.Paragraphs.Count > 0) { subtitle.Renumber(subtitle.Paragraphs[0].Number); } Text = LanguageSettings.Current.SplitLongLines.Title; labelSingleLineMaxLength.Text = LanguageSettings.Current.SplitLongLines.SingleLineMaximumLength; labelLineMaxLength.Text = LanguageSettings.Current.SplitLongLines.LineMaximumLength; labelLineContinuationBeginEnd.Text = LanguageSettings.Current.SplitLongLines.LineContinuationBeginEndStrings; listViewFixes.Columns[0].Text = LanguageSettings.Current.General.Apply; listViewFixes.Columns[1].Text = LanguageSettings.Current.General.LineNumber; listViewFixes.Columns[2].Text = LanguageSettings.Current.General.Text; var continuationProfile = ContinuationUtilities.GetContinuationProfile(Configuration.Settings.General.ContinuationStyle); comboBoxLineContinuationBegin.Text = continuationProfile.Prefix; comboBoxLineContinuationEnd.Text = continuationProfile.Suffix; toolStripMenuItemInverseSelection.Text = LanguageSettings.Current.Main.Menu.Edit.InverseSelection; toolStripMenuItemSelectAll.Text = LanguageSettings.Current.Main.Menu.ContextMenu.SelectAll; buttonOK.Text = LanguageSettings.Current.General.Ok; buttonCancel.Text = LanguageSettings.Current.General.Cancel; SubtitleListview1.InitializeLanguage(LanguageSettings.Current.General, Configuration.Settings); UiUtil.InitializeSubtitleFont(SubtitleListview1); SubtitleListview1.AutoSizeAllColumns(this); NumberOfSplits = 0; numericUpDownSingleLineMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength; _subtitle = subtitle; }
private void UiElementChanged(object sender, EventArgs e) { var idx = listViewProfiles.SelectedItems.Count > 0 ? listViewProfiles.SelectedItems[0].Index : -1; if (idx < 0 || !_editOn) { return; } RulesProfiles[idx].Name = textBoxName.Text.Trim(); RulesProfiles[idx].SubtitleLineMaximumLength = (int)numericUpDownSubtitleLineMaximumLength.Value; RulesProfiles[idx].SubtitleOptimalCharactersPerSeconds = numericUpDownOptimalCharsSec.Value; RulesProfiles[idx].SubtitleMaximumCharactersPerSeconds = numericUpDownMaxCharsSec.Value; RulesProfiles[idx].SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; RulesProfiles[idx].SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; RulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; RulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; RulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value; RulesProfiles[idx].CpsLineLengthStrategy = (comboBoxCpsLineLenCalc.SelectedItem as CpsLineLength)?.Code; RulesProfiles[idx].MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 1; RulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); RulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); UpdateRulesProfilesLine(idx); toolTipContinuationPreview.RemoveAll(); toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(RulesProfiles[idx].ContinuationStyle)); toolTipDialogStylePreview.RemoveAll(); toolTipDialogStylePreview.SetToolTip(comboBoxDialogStyle, DialogSplitMerge.GetDialogStylePreview(RulesProfiles[idx].DialogStyle)); buttonEditCustomContinuationStyle.Visible = RulesProfiles[idx].ContinuationStyle == ContinuationStyle.Custom; comboBoxContinuationStyle.Width = RulesProfiles[idx].ContinuationStyle == ContinuationStyle.Custom ? (buttonEditCustomContinuationStyle.Left - comboBoxContinuationStyle.Left - 6) : (comboBoxDialogStyle.Right - comboBoxContinuationStyle.Left); }
public void Fix(Subtitle subtitle, IFixCallbacks callbacks) { var language = Configuration.Settings.Language.FixCommonErrors; string fixAction = language.FixUnnecessaryLeadingDots; int fixCount = 0; for (int i = 1; i < subtitle.Paragraphs.Count; i++) { Paragraph p = subtitle.Paragraphs[i]; var text = ContinuationUtilities.SanitizeString(p.Text); if ((text.StartsWith("..") || text.StartsWith("…")) && callbacks.AllowFix(p, fixAction)) { var oldText = p.Text; Paragraph pPrev = subtitle.Paragraphs[i - 1]; var previousText = ContinuationUtilities.SanitizeString(pPrev.Text); if (previousText.EndsWith("..") || previousText.EndsWith("…")) { // Remove starting dots // Get first word string[] split = text.Split(Convert.ToChar(" ")); string firstWord = split[0]; string newFirstWord = firstWord; // Remove dots if (newFirstWord.StartsWith("...")) { newFirstWord = newFirstWord.Substring(3); } if (newFirstWord.StartsWith("..")) { newFirstWord = newFirstWord.Substring(2); } if (newFirstWord.StartsWith("…")) { newFirstWord = newFirstWord.Substring(1); } newFirstWord = newFirstWord.Trim(); var newText = ContinuationUtilities.ReplaceFirstOccurrence(oldText, firstWord, newFirstWord); // Commit p.Text = newText; fixCount++; callbacks.AddFixToListView(p, fixAction, oldText, newText); } } } callbacks.UpdateFixStatus(fixCount, language.FixUnnecessaryLeadingDots, language.XFixUnnecessaryLeadingDots); }
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; } checkBoxCpsIncludeWhiteSpace.Checked = RulesProfiles[idx].CpsIncludesSpace; if (RulesProfiles[idx].MergeLinesShorterThan >= 10 && RulesProfiles[idx].MergeLinesShorterThan - 10 < comboBoxMergeShortLineLength.Items.Count) { comboBoxMergeShortLineLength.SelectedIndex = RulesProfiles[idx].MergeLinesShorterThan - 10; } 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); switch (RulesProfiles[idx].DialogStyle) { case DialogType.DashBothLinesWithSpace: comboBoxDialogStyle.SelectedIndex = 0; break; case DialogType.DashBothLinesWithoutSpace: comboBoxDialogStyle.SelectedIndex = 1; break; case DialogType.DashSecondLineWithSpace: comboBoxDialogStyle.SelectedIndex = 2; break; case DialogType.DashSecondLineWithoutSpace: comboBoxDialogStyle.SelectedIndex = 3; break; default: throw new ArgumentOutOfRangeException(); } comboBoxContinuationStyle.Items.Clear(); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleNone); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleNoneTrailingDots); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleNoneLeadingTrailingDots); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleOnlyTrailingDots); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleLeadingTrailingDots); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleLeadingTrailingDash); comboBoxContinuationStyle.Items.Add(LanguageSettings.Current.Settings.ContinuationStyleLeadingTrailingDashDots); comboBoxContinuationStyle.SelectedIndex = 0; toolTipContinuationPreview.RemoveAll(); toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(RulesProfiles[idx].ContinuationStyle)); comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(RulesProfiles[idx].ContinuationStyle); _editOn = oldEditOn; }
private void SetContinuationProfile(ContinuationStyle continuationStyle) { _continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); }
private bool HasSuffix(string input) { return(ContinuationUtilities.HasSuffix(input, _continuationProfile)); }
private bool ShouldFixParagraph(string input, bool gap) { return(ContinuationUtilities.ShouldAddSuffix(input, _continuationProfile, false, gap)); }
public void Fix(Subtitle subtitle, IFixCallbacks callbacks) { int fixCount = 0; var isLanguageWithoutCaseDistinction = ContinuationUtilities.IsLanguageWithoutCaseDistinction(callbacks.Language); // Check continuation profile if (_continuationProfile == null) { SetContinuationProfile(Configuration.Settings.General.ContinuationStyle); } // Quick fix for Portuguese if (callbacks.Language == "pt") { _continuationProfile.SuffixApplyIfComma = false; _continuationProfile.GapSuffixApplyIfComma = false; if (_continuationProfile.Prefix == "..." || _continuationProfile.Prefix == "…") { _continuationProfile.PrefixAddSpace = true; } if (_continuationProfile.GapPrefix == "..." || _continuationProfile.GapPrefix == "…") { _continuationProfile.GapPrefixAddSpace = true; } } var minGapMs = ContinuationUtilities.GetMinimumGapMs(); var inSentence = false; bool?inItalicSentence = null; for (var i = 0; i < subtitle.Paragraphs.Count - 1; i++) { var p = subtitle.Paragraphs[i]; var pNext = subtitle.Paragraphs[i + 1]; var oldText = p.Text; var oldTextNext = pNext.Text; var text = ContinuationUtilities.SanitizeString(p.Text); var textNext = ContinuationUtilities.SanitizeString(pNext.Text); var isChecked = true; var shouldProcess = true; // Detect gap var gap = pNext.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds >= minGapMs; // Convert for Arabic if (callbacks.Language == "ar") { oldText = ContinuationUtilities.ConvertToForArabic(oldText); oldTextNext = ContinuationUtilities.ConvertToForArabic(oldTextNext); text = ContinuationUtilities.ConvertToForArabic(text); textNext = ContinuationUtilities.ConvertToForArabic(textNext); } // Check if we should fix this paragraph if (ShouldFixParagraph(text, gap)) { // If ends with nothing... if (!ContinuationUtilities.IsEndOfSentence(text)) { if (!isLanguageWithoutCaseDistinction) { // ...ignore inserts if (Configuration.Settings.General.FixContinuationStyleUncheckInsertsAllCaps) { if (ContinuationUtilities.IsAllCaps(text) || ContinuationUtilities.IsAllCaps(textNext)) { isChecked = false; } } // ...and italic lyrics if (Configuration.Settings.General.FixContinuationStyleUncheckInsertsItalic) { if (ContinuationUtilities.IsItalic(oldText) && !ContinuationUtilities.IsNewSentence(text, true) && inItalicSentence == false) { isChecked = false; } } // ...and small caps inserts or non-italic lyrics if (Configuration.Settings.General.FixContinuationStyleUncheckInsertsLowercase) { if (!ContinuationUtilities.IsNewSentence(text, true) && !inSentence) { isChecked = false; } } // ...ignore bold tags for Portuguese if (callbacks.Language == "pt") { if (ContinuationUtilities.IsBold(oldText) || ContinuationUtilities.IsBold(oldTextNext)) { isChecked = false; } } } // ...ignore Arabic inserts if (callbacks.Language == "ar") { if (ContinuationUtilities.IsArabicInsert(oldText, text) || ContinuationUtilities.IsArabicInsert(oldTextNext, textNext)) { isChecked = false; } } } // Remove any suffixes and prefixes var oldTextWithoutSuffix = ContinuationUtilities.RemoveSuffix(oldText, _continuationProfile, new List <string> { "," }, false).Trim(); var oldTextNextWithoutPrefix = ContinuationUtilities.RemovePrefix(oldTextNext, _continuationProfile, true, gap); var textNextWithoutPrefix = ContinuationUtilities.SanitizeString(oldTextNextWithoutPrefix, true); // Get last word of this paragraph var lastWord = ContinuationUtilities.GetLastWord(text); // If ends with dots (possible interruptions), or nothing, check if next sentence is new sentence, otherwise don't check by default if (text.EndsWith("..") || text.EndsWith("…") || ContinuationUtilities.EndsWithNothing(text, _continuationProfile)) { if (!HasPrefix(textNext) && ((!isLanguageWithoutCaseDistinction && ContinuationUtilities.IsNewSentence(textNext, true)) || string.IsNullOrEmpty(textNext))) { isChecked = false; // If set, we'll hide interruption continuation candidates that don't start with a name, // to prevent clogging up the window with a lot of unchecked items. // For example, a candidate we DO want to list: But wait... Marty is still there! // or: This is something Marty can do. // If both sentences are all caps, DO show them. if (Configuration.Settings.General.FixContinuationStyleHideContinuationCandidatesWithoutName && !(textNextWithoutPrefix.StartsWith("I ") || textNextWithoutPrefix.StartsWith("I'")) && !StartsWithName(textNextWithoutPrefix, callbacks.Language) && !(ContinuationUtilities.IsAllCaps(text) && ContinuationUtilities.IsAllCaps(textNext))) { shouldProcess = false; } } } if (shouldProcess) { // First paragraph... // If first paragraphs ends with a suffix, // and profile states to NOT replace comma, // and next sentence starts with conjunction, // try to re-add comma var addComma = lastWord.EndsWith(",") || HasSuffix(text) && (gap ? !_continuationProfile.GapSuffixReplaceComma : !_continuationProfile.SuffixReplaceComma) && ContinuationUtilities.StartsWithConjunction(textNextWithoutPrefix, callbacks.Language); // Make new last word var newText = ContinuationUtilities.AddSuffixIfNeeded(oldTextWithoutSuffix, _continuationProfile, gap, addComma); // Commit if changed if (oldText != newText && callbacks.AllowFix(p, FixAction)) { // Convert back for Arabic if (callbacks.Language == "ar") { newText = ContinuationUtilities.ConvertBackForArabic(newText); } // Don't apply fix when it's checked in step 1 if (IsPreviewStep(callbacks) && isChecked || !IsPreviewStep(callbacks)) { p.Text = newText; } fixCount++; callbacks.AddFixToListView(p, FixAction, oldText, newText, isChecked); } // Second paragraph... // Make new first word var newTextNext = ContinuationUtilities.AddPrefixIfNeeded(oldTextNextWithoutPrefix, _continuationProfile, gap); // Commit if changed if (oldTextNext != newTextNext && callbacks.AllowFix(pNext, FixAction + " ")) { // Convert back for Arabic if (callbacks.Language == "ar") { newTextNext = ContinuationUtilities.ConvertBackForArabic(newTextNext); } // Don't apply fix when it's checked in step 1 if (IsPreviewStep(callbacks) && isChecked || !IsPreviewStep(callbacks)) { pNext.Text = newTextNext; } fixCount++; callbacks.AddFixToListView(pNext, FixAction + " ", oldTextNext, newTextNext, isChecked); } } } // Detect new sentence if (ContinuationUtilities.IsNewSentence(text, true)) { inSentence = true; if (ContinuationUtilities.IsItalic(oldText)) { inItalicSentence = true; } else { inItalicSentence = null; } } // Detect end of sentence if (ContinuationUtilities.IsEndOfSentence(text)) { inSentence = false; if (ContinuationUtilities.IsItalic(oldText)) { inItalicSentence = false; } else { inItalicSentence = null; } } } callbacks.UpdateFixStatus(fixCount, Language.FixUnnecessaryLeadingDots); }
public SettingsCustomContinuationStyle() { UiUtil.PreInitialize(this); InitializeComponent(); UiUtil.FixFonts(this); var language = LanguageSettings.Current.Settings; var settings = Configuration.Settings.General; Text = language.CustomContinuationStyle; toolStripMenuItemLoadStyle.Text = language.LoadStyle; labelSuffix.Text = language.Suffix; checkBoxSuffixAddForComma.Text = language.AddSuffixForComma; checkBoxSuffixAddSpace.Text = language.AddSpace; checkBoxSuffixRemoveComma.Text = language.RemoveComma; labelPrefix.Text = language.Prefix; checkBoxPrefixAddSpace.Text = language.AddSpace; checkBoxDifferentStyleGap.Text = language.DifferentStyleGap; labelMs.Text = language.Milliseconds; labelGapSuffix.Text = language.Suffix; checkBoxGapSuffixAddForComma.Text = language.AddSuffixForComma; checkBoxGapSuffixAddSpace.Text = language.AddSpace; checkBoxGapSuffixRemoveComma.Text = language.RemoveComma; labelGapPrefix.Text = language.Prefix; checkBoxGapPrefixAddSpace.Text = language.AddSpace; groupBoxPreview.Text = language.Preview; labelPreviewPause.Text = language.PreviewPause; labelNote.Text = language.CustomContinuationStyleNote; comboBoxSuffix.Left = labelSuffix.Left + labelSuffix.Width + 6; checkBoxSuffixAddForComma.Left = comboBoxSuffix.Left; checkBoxSuffixAddSpace.Left = comboBoxSuffix.Left; checkBoxSuffixRemoveComma.Left = comboBoxSuffix.Left; comboBoxPrefix.Left = labelPrefix.Left + labelPrefix.Width + 6; checkBoxPrefixAddSpace.Left = comboBoxPrefix.Left; numericUpDownDifferentStyleGapMs.Left = checkBoxDifferentStyleGap.Left + checkBoxDifferentStyleGap.Width + 6; labelMs.Left = numericUpDownDifferentStyleGapMs.Left + numericUpDownDifferentStyleGapMs.Width + 6; comboBoxGapSuffix.Left = labelGapSuffix.Left + labelGapSuffix.Width + 6; checkBoxGapSuffixAddForComma.Left = comboBoxGapSuffix.Left; checkBoxGapSuffixAddSpace.Left = comboBoxGapSuffix.Left; checkBoxGapSuffixRemoveComma.Left = comboBoxGapSuffix.Left; comboBoxGapPrefix.Left = labelGapPrefix.Left + labelGapPrefix.Width + 6; checkBoxGapPrefixAddSpace.Left = comboBoxGapPrefix.Left; // Populate styles menu toolStripMenuItemLoadStyle.DropDownItems.Clear(); foreach (var continuationStyle in ContinuationUtilities.ContinuationStyles) { if (continuationStyle != ContinuationStyle.Custom) { toolStripMenuItemLoadStyle.DropDownItems.Add(new ToolStripMenuItem(UiUtil.GetContinuationStyleName(continuationStyle), null, (sender, args) => { ResetSettings(continuationStyle); })); } } // Load config LoadSettings(ContinuationUtilities.GetContinuationProfile(ContinuationStyle.Custom)); numericUpDownDifferentStyleGapMs.Value = settings.ContinuationPause; buttonOK.Text = LanguageSettings.Current.General.Ok; buttonCancel.Text = LanguageSettings.Current.General.Cancel; UiUtil.FixLargeFonts(this, buttonOK); }
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; }
private bool HasPrefix(string input) { return(ContinuationUtilities.HasPrefix(input, this._continuationProfile)); }