Exemplo n.º 1
0
        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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
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;
            }
            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;
        }
Exemplo n.º 5
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;
        }