From 31e92dcfbc2191611849ca7a5853ae3f8db3ff14 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Wed, 8 May 2024 20:38:26 +0200 Subject: [PATCH] Work on #8312 --- src/ui/Forms/Main.cs | 10 +++++- src/ui/Forms/TimedTextPropertiesImsc11.cs | 41 ++++++++++++++++++++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 630c88c3c..5a3ec190f 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -32614,9 +32614,17 @@ namespace Nikse.SubtitleEdit.Forms if (ft == typeof(TimedTextImsc11)) { - using (var properties = new TimedTextPropertiesImsc11(_subtitle)) + var oldFr = Configuration.Settings.General.CurrentFrameRate; + using (var properties = new TimedTextPropertiesImsc11(_subtitle, _videoFileName)) { properties.ShowDialog(this); + + if (oldFr != Configuration.Settings.General.CurrentFrameRate) + { + toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); + SubtitleListview1.Fill(_subtitle, _subtitleOriginal); + RefreshSelectedParagraph(); + } } return; diff --git a/src/ui/Forms/TimedTextPropertiesImsc11.cs b/src/ui/Forms/TimedTextPropertiesImsc11.cs index ef4898ed9..cab9edbf5 100644 --- a/src/ui/Forms/TimedTextPropertiesImsc11.cs +++ b/src/ui/Forms/TimedTextPropertiesImsc11.cs @@ -2,6 +2,7 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Logic; using System; +using System.Globalization; using System.Windows.Forms; using System.Xml; @@ -10,10 +11,11 @@ namespace Nikse.SubtitleEdit.Forms public sealed partial class TimedTextPropertiesImsc11 : PositionAndSizeForm { private readonly Subtitle _subtitle; + private readonly string _videoFileName; private readonly XmlDocument _xml; private readonly XmlNamespaceManager _namespaceManager; - public TimedTextPropertiesImsc11(Subtitle subtitle) + public TimedTextPropertiesImsc11(Subtitle subtitle, string videoFileName) { UiUtil.PreInitialize(this); InitializeComponent(); @@ -23,6 +25,7 @@ namespace Nikse.SubtitleEdit.Forms Text = string.Format(LanguageSettings.Current.Main.Menu.File.FormatXProperties, new TimedTextImsc11().Name); _subtitle = subtitle; + _videoFileName = videoFileName; var notAvailable = "[" + LanguageSettings.Current.General.NotAvailable + "]"; comboBoxDropMode.Items[0] = notAvailable; comboBoxTimeBase.Items[0] = notAvailable; @@ -126,9 +129,9 @@ namespace Nikse.SubtitleEdit.Forms } } - comboBoxFrameRate.Enabled = false; - comboBoxFrameRateMultiplier.Enabled = false; - comboBoxDropMode.Enabled = false; + comboBoxFrameRate.Enabled = string.IsNullOrEmpty(_videoFileName); + comboBoxFrameRateMultiplier.Enabled = string.IsNullOrEmpty(_videoFileName); + comboBoxDropMode.Enabled = string.IsNullOrEmpty(_videoFileName); } private void buttonCancel_Click(object sender, EventArgs e) @@ -138,6 +141,36 @@ namespace Nikse.SubtitleEdit.Forms private void buttonOK_Click(object sender, EventArgs e) { + if (string.IsNullOrEmpty(_videoFileName)) + { + if (float.TryParse(comboBoxFrameRate.Text.Replace(",", "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fr)) + { + if (comboBoxFrameRateMultiplier.Text == "1 1" || string.IsNullOrEmpty(comboBoxFrameRateMultiplier.Text)) + { + Configuration.Settings.General.CurrentFrameRate = fr; + } + else + { + if (Math.Abs(fr - 24) < 0.001) + { + Configuration.Settings.General.CurrentFrameRate = 23.976; + } + else if (Math.Abs(fr - 30) < 0.001) + { + Configuration.Settings.General.CurrentFrameRate = 29.97; + } + else if (Math.Abs(fr - 60) < 0.001) + { + Configuration.Settings.General.CurrentFrameRate = 59.94; + } + else + { + Configuration.Settings.General.CurrentFrameRate = fr; + } + } + } + } + XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _namespaceManager); if (node != null) {