From 82ac167024b5d412b02032d3424f3df1140a4c0c Mon Sep 17 00:00:00 2001 From: niksedk Date: Sun, 27 Jun 2021 22:24:33 +0200 Subject: [PATCH] Apply duration limit: Fix check selected lines - thx PM :) --- Changelog.txt | 1 + src/ui/Forms/ApplyDurationLimits.cs | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 65aa1f39c..21cc40914 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -44,6 +44,7 @@ * Try to fix Tools - Join... with different ASSA styles - thx Joe * Fix crash in "Continuation style" - thx ivandrofly * Fix export to "dvd studio stl" - thx nonofx + * Apply duration limit: Only fix "checked" lines - thx PM 3.6.1 (20th May 2021) diff --git a/src/ui/Forms/ApplyDurationLimits.cs b/src/ui/Forms/ApplyDurationLimits.cs index d237359da..cfbd068b1 100644 --- a/src/ui/Forms/ApplyDurationLimits.cs +++ b/src/ui/Forms/ApplyDurationLimits.cs @@ -144,13 +144,13 @@ namespace Nikse.SubtitleEdit.Forms double minDisplayTime = (double)numericUpDownDurationMin.Value; for (int i = 0; i < _working.Paragraphs.Count; i++) { - Paragraph p = _working.Paragraphs[i]; - double displayTime = p.Duration.TotalMilliseconds; + var p = _working.Paragraphs[i]; + var displayTime = p.Duration.TotalMilliseconds; if (displayTime < minDisplayTime) { var next = _working.GetParagraphOrDefault(i + 1); var wantedEndMs = p.StartTime.TotalMilliseconds + minDisplayTime; - if (next == null || wantedEndMs < next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines && AllowFix(p)) + if (next == null || wantedEndMs < next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines) { AddFix(p, wantedEndMs, DefaultBackColor); } @@ -180,21 +180,26 @@ namespace Nikse.SubtitleEdit.Forms private void AddFix(Paragraph p, double endMs, Color backgroundColor) { - string before = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); + if (!AllowFix(p)) + { + return; + } + + var before = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); p.EndTime.TotalMilliseconds = endMs; - string after = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); + var after = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); _totalFixes++; AddFixToListView(p, before, after, backgroundColor); } public void FixLongDisplayTimes() { - double maxDisplayTime = (double)numericUpDownDurationMax.Value; + var maxDisplayTime = (double)numericUpDownDurationMax.Value; for (int i = 0; i < _working.Paragraphs.Count; i++) { - Paragraph p = _working.Paragraphs[i]; - double displayTime = p.Duration.TotalMilliseconds; - if (displayTime > maxDisplayTime && AllowFix(p)) + var p = _working.Paragraphs[i]; + var displayTime = p.Duration.TotalMilliseconds; + if (displayTime > maxDisplayTime) { AddFix(p, p.StartTime.TotalMilliseconds + maxDisplayTime, DefaultBackColor); }