From cbce939d4a113c175b081f0c36ce5d091b09b0e8 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sun, 6 Oct 2019 21:33:17 +0200 Subject: [PATCH] More work on #3633 --- libse/BluRaySup/BluRaySupPicture.cs | 4 +-- libse/Settings.cs | 35 +++++++++++++++++++ src/Forms/BatchConvertTsSettings.cs | 7 ---- src/Logic/CommandLineConvert/TsToBdnXml.cs | 5 +-- src/Logic/CommandLineConvert/TsToBluRaySup.cs | 5 +-- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/libse/BluRaySup/BluRaySupPicture.cs b/libse/BluRaySup/BluRaySupPicture.cs index 89ca482c0..b8b4ad07c 100644 --- a/libse/BluRaySup/BluRaySupPicture.cs +++ b/libse/BluRaySup/BluRaySupPicture.cs @@ -439,8 +439,8 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup } if (overridePosition != null && - overridePosition.Value.X >= 0 && overridePosition.Value.X < bm.Width && - overridePosition.Value.Y >= 0 && overridePosition.Value.Y < bm.Height) + overridePosition.Value.X >= 0 && overridePosition.Value.X < pic.Width && + overridePosition.Value.Y >= 0 && overridePosition.Value.Y < pic.Height) { pic.WindowXOffset = overridePosition.Value.X; pic.WindowYOffset = overridePosition.Value.Y; diff --git a/libse/Settings.cs b/libse/Settings.cs index d86c45a97..6df8da845 100644 --- a/libse/Settings.cs +++ b/libse/Settings.cs @@ -2913,6 +2913,36 @@ $HorzAlign = Center settings.Tools.BatchConvertExportCustomTextTemplate = subNode.InnerText; } + subNode = node.SelectSingleNode("BatchConvertTsOverridePosition"); + if (subNode != null) + { + settings.Tools.BatchConvertTsOverridePosition = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("BatchConvertTsOverrideBottomMargin"); + if (subNode != null) + { + settings.Tools.BatchConvertTsOverrideBottomMargin = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("BatchConvertTsOverrideScreenSize"); + if (subNode != null) + { + settings.Tools.BatchConvertTsOverrideScreenSize = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("BatchConvertTsScreenWidth"); + if (subNode != null) + { + settings.Tools.BatchConvertTsScreenWidth = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("BatchConvertTsScreenHeight"); + if (subNode != null) + { + settings.Tools.BatchConvertTsScreenHeight = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + subNode = node.SelectSingleNode("ModifySelectionRule"); if (subNode != null) { @@ -6066,6 +6096,11 @@ $HorzAlign = Center textWriter.WriteElementString("BatchConvertSsaStyles", settings.Tools.BatchConvertSsaStyles); textWriter.WriteElementString("BatchConvertUseStyleFromSource", settings.Tools.BatchConvertUseStyleFromSource.ToString()); textWriter.WriteElementString("BatchConvertExportCustomTextTemplate", settings.Tools.BatchConvertExportCustomTextTemplate); + textWriter.WriteElementString("BatchConvertTsOverridePosition", settings.Tools.BatchConvertTsOverridePosition.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("BatchConvertTsOverrideBottomMargin", settings.Tools.BatchConvertTsOverrideBottomMargin.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("BatchConvertTsOverrideScreenSize", settings.Tools.BatchConvertTsOverrideScreenSize.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("BatchConvertTsScreenWidth", settings.Tools.BatchConvertTsScreenWidth.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("BatchConvertTsScreenHeight", settings.Tools.BatchConvertTsScreenHeight.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("ModifySelectionRule", settings.Tools.ModifySelectionRule); textWriter.WriteElementString("ModifySelectionText", settings.Tools.ModifySelectionText); textWriter.WriteElementString("ModifySelectionCaseSensitive", settings.Tools.ModifySelectionCaseSensitive.ToString()); diff --git a/src/Forms/BatchConvertTsSettings.cs b/src/Forms/BatchConvertTsSettings.cs index 13d338df5..00027e8ab 100644 --- a/src/Forms/BatchConvertTsSettings.cs +++ b/src/Forms/BatchConvertTsSettings.cs @@ -49,13 +49,6 @@ namespace Nikse.SubtitleEdit.Forms numericUpDownWidth.Enabled = checkBoxOverrideVideoSize.Checked; labelHeight.Enabled = checkBoxOverrideVideoSize.Checked; numericUpDownHeight.Enabled = checkBoxOverrideVideoSize.Checked; - - if (checkBoxOverrideVideoSize.Checked && !checkBoxOverrideOriginalPosition.Checked) - { - checkBoxOverrideOriginalPosition.Checked = true; - } - checkBoxOverrideOriginalPosition.Enabled = !checkBoxOverrideVideoSize.Checked; - CheckBoxOverrideOriginalPosition_CheckedChanged(null, null); } private void BatchConvertTsSettings_KeyDown(object sender, KeyEventArgs e) diff --git a/src/Logic/CommandLineConvert/TsToBdnXml.cs b/src/Logic/CommandLineConvert/TsToBdnXml.cs index 5009b186e..85e8636c4 100644 --- a/src/Logic/CommandLineConvert/TsToBdnXml.cs +++ b/src/Logic/CommandLineConvert/TsToBdnXml.cs @@ -91,10 +91,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert mp.ScreenWidth = width; mp.ScreenHeight = height; int bottomMarginInPixels; - if (Configuration.Settings.Tools.BatchConvertTsOverridePosition || - Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize && - Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 && - Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0) + if (Configuration.Settings.Tools.BatchConvertTsOverridePosition) { mp.BottomMargin = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin; bottomMarginInPixels = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin; diff --git a/src/Logic/CommandLineConvert/TsToBluRaySup.cs b/src/Logic/CommandLineConvert/TsToBluRaySup.cs index 48e4fa6eb..d4017508b 100644 --- a/src/Logic/CommandLineConvert/TsToBluRaySup.cs +++ b/src/Logic/CommandLineConvert/TsToBluRaySup.cs @@ -85,10 +85,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert 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) + if (Configuration.Settings.Tools.BatchConvertTsOverridePosition) { mp.BottomMargin = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin; mp.Alignment = ContentAlignment.BottomCenter;