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 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; }