示例#1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_subtitle.Header))
            {
                _subtitle.Header = AdvancedSubStationAlpha.DefaultHeader;
            }

            var newStyles        = AdvancedSubStationAlpha.GetSsaStylesFromHeader(_progessBarSubtitle.Header);
            var ignoreStyleNames = new List <string> {
                "SE-progress-bar-text", "SE-progress-bar-splitter", "SE-progress-bar-bg"
            };
            var styles = AdvancedSubStationAlpha.GetSsaStylesFromHeader(_subtitle.Header).Where(p => !ignoreStyleNames.Contains(p.Name)).ToList();

            styles.AddRange(newStyles);
            _subtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_subtitle.Header, styles);

            for (int i = _subtitle.Paragraphs.Count - 1; i >= 0; i--)
            {
                if (ignoreStyleNames.Contains(_subtitle.Paragraphs[i].Extra))
                {
                    _subtitle.Paragraphs.RemoveAt(i);
                }
            }

            _subtitle.Paragraphs.AddRange(_progessBarSubtitle.Paragraphs);

            if (_videoInfo != null && _videoInfo.Width > 0 && _videoInfo.Height > 0)
            {
                _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + _videoInfo.Width.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header);
                _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + _videoInfo.Height.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header);
            }


            Configuration.Settings.Tools.AssaProgressBarForeColor      = panelPrimaryColor.BackColor;
            Configuration.Settings.Tools.AssaProgressBarBackColor      = panelSecondaryColor.BackColor;
            Configuration.Settings.Tools.AssaProgressBarTextColor      = panelTextColor.BackColor;
            Configuration.Settings.Tools.AssaProgressBarHeight         = (int)numericUpDownHeight.Value;
            Configuration.Settings.Tools.AssaProgressBarSplitterWidth  = (int)numericUpDownSplitterWidth.Value;
            Configuration.Settings.Tools.AssaProgressBarSplitterHeight = (int)numericUpDownSplitterHeight.Value;
            Configuration.Settings.Tools.AssaProgressBarFontName       = comboBoxFontName.Text;
            Configuration.Settings.Tools.AssaProgressBarFontSize       = (int)numericUpDownFontSize.Value;
            if (comboBoxTextHorizontalAlignment.SelectedIndex == 1)
            {
                Configuration.Settings.Tools.AssaProgressBarTextAlign = "center";
            }
            else if (comboBoxTextHorizontalAlignment.SelectedIndex == 2)
            {
                Configuration.Settings.Tools.AssaProgressBarTextAlign = "right";
            }
            else
            {
                Configuration.Settings.Tools.AssaProgressBarTextAlign = "left";
            }

            DialogResult = DialogResult.OK;
        }
示例#2
0
        private void LoadExistingProgressBarSettings()
        {
            //TODO: splitter height + width
            foreach (var p in _subtitle.Paragraphs)
            {
                if (p.Extra == "SE-progress-bar-text")
                {
                    var newParagraph = new Paragraph(p)
                    {
                        Text = Utilities.RemoveSsaTags(p.Text)
                    };

                    if (double.TryParse(p.Actor, NumberStyles.None, CultureInfo.InvariantCulture, out var number))
                    {
                        newParagraph.StartTime.TotalMilliseconds = number;
                    }

                    _chapters.Paragraphs.Add(newParagraph);
                }
            }

            foreach (var style in AdvancedSubStationAlpha.GetSsaStylesFromHeader(_subtitle.Header))
            {
                if (style.Name == "SE-progress-bar-text")
                {
                    comboBoxFontName.Text       = style.FontName;
                    numericUpDownFontSize.Value = (decimal)style.FontSize;
                    panelTextColor.BackColor    = style.Primary;
                }
                else if (style.Name == "SE-progress-bar-bg")
                {
                    panelPrimaryColor.BackColor   = style.Primary;
                    panelSecondaryColor.BackColor = style.Secondary;

                    if (style.Alignment != "7")
                    {
                        radioButtonPosBottom.Checked = true;
                    }
                    else
                    {
                        radioButtonPosTop.Checked = true;
                    }
                }
            }

            RefreshListView();
        }
示例#3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!checkBoxMargins.Checked && !checkBoxFontSize.Checked && !checkBoxPosition.Checked && !checkBoxDrawing.Checked)
            {
                return;
            }

            if (string.IsNullOrEmpty(_subtitle.Header))
            {
                _subtitle.Header = AdvancedSubStationAlpha.DefaultHeader;
            }

            var sourceWidth  = numericUpDownSourceWidth.Value;
            var sourceHeight = numericUpDownSourceHeight.Value;
            var targetWidth  = numericUpDownTargetWidth.Value;
            var targetHeight = numericUpDownTargetHeight.Value;

            if (sourceWidth == 0 || sourceHeight == 0 || targetWidth == 0 || targetHeight == 0)
            {
                MessageBox.Show("Video width/height cannot be zero");
                return;
            }


            if (sourceWidth == targetWidth && sourceHeight == targetHeight)
            {
                MessageBox.Show("Source and target resolution is the same - nothing to do.");
                return;
            }

            var fixMargins = checkBoxMargins.Checked;
            var fixFonts   = checkBoxFontSize.Checked;
            var fixPos     = checkBoxPosition.Checked;
            var fixDraw    = checkBoxDrawing.Checked;
            var styles     = AdvancedSubStationAlpha.GetSsaStylesFromHeader(_subtitle.Header);

            foreach (var style in styles)
            {
                if (fixMargins)
                {
                    style.MarginLeft     = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginLeft);
                    style.MarginRight    = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginRight);
                    style.MarginVertical = AssaResampler.Resample(sourceHeight, targetHeight, style.MarginVertical);
                }

                if (fixFonts)
                {
                    style.FontSize = AssaResampler.Resample(sourceHeight, targetHeight, style.FontSize);
                }

                if (fixFonts || fixDraw)
                {
                    style.OutlineWidth = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.OutlineWidth);
                    style.ShadowWidth  = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.ShadowWidth);
                    style.Spacing      = (decimal)AssaResampler.Resample(sourceWidth, targetWidth, (float)style.Spacing);
                }
            }

            _subtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_subtitle.Header, styles);

            _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + targetWidth.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header);
            _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + targetHeight.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header);

            foreach (var p in _subtitle.Paragraphs)
            {
                if (fixFonts)
                {
                    p.Text = AssaResampler.ResampleOverrideTagsFont(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text);
                }

                if (fixPos)
                {
                    p.Text = AssaResampler.ResampleOverrideTagsPosition(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text);
                }

                if (fixDraw)
                {
                    p.Text = AssaResampler.ResampleOverrideTagsDrawing(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text, null);
                }
            }

            DialogResult = DialogResult.OK;
        }