From 5c40450a0457ad064cef18964d5927951cc31243 Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 8 Mar 2023 15:56:04 +0100 Subject: [PATCH] Change chapter property --- Changelog.txt | 1 + src/ui/Controls/AudioVisualizer.cs | 8 +- src/ui/Controls/VideoPlayerContainer.cs | 35 ++--- src/ui/Forms/GetVideoPosition.Designer.cs | 3 +- src/ui/Forms/GetVideoPosition.resx | 140 ------------------ src/ui/Forms/Main.cs | 24 +-- .../AdjustTimingViaShotChanges.Designer.cs | 5 +- src/ui/SubtitleEdit.csproj | 3 - 8 files changed, 34 insertions(+), 185 deletions(-) delete mode 100644 src/ui/Forms/GetVideoPosition.resx diff --git a/Changelog.txt b/Changelog.txt index e4133fe10..382cc38b8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -28,6 +28,7 @@ * Optimize saving of TTML files * Allow new syntax for yt transcript +1 hour - thx Vasudeo * FcpXml now supports latest version - thx Dvid + * Improve "Redo casing" in "Batch convert" - thx chschmit * FIXED: * Fix extra space after font in EBU STL - thx Stefan * Fix possible crash in batch convert w overwrite - thx chensimmons diff --git a/src/ui/Controls/AudioVisualizer.cs b/src/ui/Controls/AudioVisualizer.cs index eac70f508..52fd4bee9 100644 --- a/src/ui/Controls/AudioVisualizer.cs +++ b/src/ui/Controls/AudioVisualizer.cs @@ -198,9 +198,9 @@ namespace Nikse.SubtitleEdit.Controls } } - private List _chapters = new List(); + private MatroskaChapter[] _chapters = Array.Empty(); - public List Chapters + public MatroskaChapter[] Chapters { get => _chapters; set @@ -726,7 +726,7 @@ namespace Nikse.SubtitleEdit.Controls try { var index = 0; - while (index < _chapters.Count) + while (index < _chapters.Length) { int pos; try @@ -746,7 +746,7 @@ namespace Nikse.SubtitleEdit.Controls { string name; var x = pos + 3; - var y = index + 1 < _chapters.Count && Math.Abs(_chapters[index].StartTime - _chapters[index + 1].StartTime) < 0.01 ? Height / 2 - font.Height - 12 : Height / 2 - 12; + var y = index + 1 < _chapters.Length && Math.Abs(_chapters[index].StartTime - _chapters[index + 1].StartTime) < 0.01 ? Height / 2 - font.Height - 12 : Height / 2 - 12; using (var chapterTextBackBrush = new SolidBrush(ChaptersColor)) { name = _chapters[index].Nested ? "+ " + _chapters[index].Name : _chapters[index].Name; diff --git a/src/ui/Controls/VideoPlayerContainer.cs b/src/ui/Controls/VideoPlayerContainer.cs index 3a56d4e1d..19cb261cf 100644 --- a/src/ui/Controls/VideoPlayerContainer.cs +++ b/src/ui/Controls/VideoPlayerContainer.cs @@ -125,17 +125,8 @@ namespace Nikse.SubtitleEdit.Controls private readonly ToolTip _currentPositionToolTip = new ToolTip(); private int _lastCurrentPositionToolTipX; private int _lastCurrentPositionToolTipY; - private List _chapters = new List(); - public List Chapters - { - get => _chapters; - set - { - _chapters = value; - Invalidate(true); - } - } + public MatroskaChapter[] Chapters { get; set; } public RightToLeft TextRightToLeft { @@ -201,7 +192,7 @@ namespace Nikse.SubtitleEdit.Controls public VideoPlayerContainer() { - _chapters = new List(); + Chapters = Array.Empty(); FontSizeFactor = 1.0F; BorderStyle = BorderStyle.None; _resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayerContainer)); @@ -1532,23 +1523,23 @@ namespace Nikse.SubtitleEdit.Controls double cursorVideoPosition = CursorVideoPosition(mouseX); string toolTiptext = TimeCode.FromSeconds(cursorVideoPosition + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit).ToDisplayString(); - if (_chapters?.Count > 0) + if (Chapters?.Length > 0) { toolTiptext += " - "; - for (int index = 0; index < _chapters.Count; index++) + for (int index = 0; index < Chapters.Length; index++) { - var chapterTime = _chapters[index].StartTime; - var nextChapterTime = index + 1 < _chapters.Count ? _chapters[index + 1].StartTime : Duration; + var chapterTime = Chapters[index].StartTime; + var nextChapterTime = index + 1 < Chapters.Length ? Chapters[index + 1].StartTime : Duration; if (cursorVideoPosition >= chapterTime && cursorVideoPosition < nextChapterTime) { - if (_chapters[index].Nested) + if (Chapters[index].Nested) { toolTiptext += "+ "; } - toolTiptext += _chapters[index].Name; + toolTiptext += Chapters[index].Name; break; } } @@ -1563,12 +1554,12 @@ namespace Nikse.SubtitleEdit.Controls { int max = _pictureBoxProgressbarBackground.Width - 9; int index = 0; - while (index < _chapters.Count) + while (index < Chapters.Length) { int pos; try { - double time = _chapters[index++].StartTime; + double time = Chapters[index++].StartTime; pos = SecondsToXPosition(time) + mergin; } catch @@ -1604,7 +1595,7 @@ namespace Nikse.SubtitleEdit.Controls private void PictureBoxProgressbarBackgroundPaint(object sender, PaintEventArgs e) { - if (_chapters?.Count > 0) + if (Chapters?.Length > 0) { DrawChapters(e.Graphics, 3, _pictureBoxProgressBar.Location.Y, _pictureBoxProgressBar.Location.Y + 3); } @@ -1612,7 +1603,7 @@ namespace Nikse.SubtitleEdit.Controls private void PictureBoxProgressBarPaint(object sender, PaintEventArgs e) { - if (_chapters?.Count > 0) + if (Chapters?.Length > 0) { DrawChapters(e.Graphics, -1, 1, _pictureBoxProgressBar.Height); } @@ -1997,7 +1988,7 @@ namespace Nikse.SubtitleEdit.Controls PanelPlayer.Hide(); Pause(); SubtitleText = string.Empty; - Chapters = new List(); + Chapters = Array.Empty(); MpvPreviewStyleHeader = null; var temp = VideoPlayer; VideoPlayer = null; diff --git a/src/ui/Forms/GetVideoPosition.Designer.cs b/src/ui/Forms/GetVideoPosition.Designer.cs index 15e498c8f..f4311d173 100644 --- a/src/ui/Forms/GetVideoPosition.Designer.cs +++ b/src/ui/Forms/GetVideoPosition.Designer.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; diff --git a/src/ui/Forms/GetVideoPosition.resx b/src/ui/Forms/GetVideoPosition.resx deleted file mode 100644 index 955a868f2..000000000 --- a/src/ui/Forms/GetVideoPosition.resx +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 157, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAI4BbGlic2UsIFZlcnNpb249My42LjExLjEyNSwgQ3VsdHVyZT1u - ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0sIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1 - bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQwDAAAAP2xpYnNlLCBW - ZXJzaW9uPTMuNi4xMS4xMjUsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAUBAAAA - ZFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbTmlrc2UuU3VidGl0bGVFZGl0LkNvcmUu - Q29udGFpbmVyRm9ybWF0cy5NYXRyb3NrYS5NYXRyb3NrYUNoYXB0ZXIDAAAABl9pdGVtcwVfc2l6ZQhf - dmVyc2lvbgQAAENOaWtzZS5TdWJ0aXRsZUVkaXQuQ29yZS5Db250YWluZXJGb3JtYXRzLk1hdHJvc2th - Lk1hdHJvc2thQ2hhcHRlcltdAwAAAAgIAgAAAAkEAAAAAAAAAAAAAAAHBAAAAAABAAAAAAAAAARBTmlr - c2UuU3VidGl0bGVFZGl0LkNvcmUuQ29udGFpbmVyRm9ybWF0cy5NYXRyb3NrYS5NYXRyb3NrYUNoYXB0 - ZXIDAAAACw== - - - \ No newline at end of file diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 876fc5032..aa25c8ca1 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -3701,7 +3701,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); } var oldSaveFormat = Configuration.Settings.General.LastSaveAsFormat; @@ -3943,7 +3943,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); Configuration.Settings.RecentFiles.Add(fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, VideoAudioTrackNumber, _subtitleOriginalFileName, Configuration.Settings.General.CurrentVideoOffsetInMs, Configuration.Settings.General.CurrentVideoIsSmpte); Configuration.Settings.Save(); @@ -5195,7 +5195,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); if (mediaPlayer.VideoPlayer != null) { mediaPlayer.PauseAndDisposePlayer(); @@ -17338,7 +17338,7 @@ namespace Nikse.SubtitleEdit.Forms e.SuppressKeyPress = true; } - else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToPrevChapter) + else if (mediaPlayer.Chapters?.Length > 0 && e.KeyData == _shortcuts.VideoGoToPrevChapter) { var cp = mediaPlayer.CurrentPosition - 0.01; foreach (var chapter in mediaPlayer.Chapters.Reverse()) @@ -17352,7 +17352,7 @@ namespace Nikse.SubtitleEdit.Forms e.SuppressKeyPress = true; } - else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToNextChapter) + else if (mediaPlayer.Chapters?.Length > 0 && e.KeyData == _shortcuts.VideoGoToNextChapter) { var cp = mediaPlayer.CurrentPosition + 0.01; foreach (var chapter in mediaPlayer.Chapters) @@ -21729,7 +21729,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); if (Configuration.Settings.General.WaveformAutoGenWhenOpeningVideo) { @@ -25798,7 +25798,7 @@ namespace Nikse.SubtitleEdit.Forms } } - if (mediaPlayer.Chapters?.Count > 0) + if (mediaPlayer.Chapters?.Length > 0) { audioVisualizer.Chapters = mediaPlayer.Chapters; } @@ -25830,7 +25830,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); } if (mediaPlayer.VideoPlayer is LibVlcDynamic && audioTrackNumber != -1) @@ -27894,7 +27894,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); trackBarWaveformPosition.Value = 0; timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); timeUpDownVideoPositionAdjust.Enabled = false; @@ -31797,11 +31797,11 @@ namespace Nikse.SubtitleEdit.Forms if (chaps?.Count > 0) { - mediaPlayer.Chapters = chaps; + mediaPlayer.Chapters = chaps.ToArray(); if (audioVisualizer.WavePeaks != null) { - audioVisualizer.Chapters = chaps; + audioVisualizer.Chapters = chaps.ToArray(); } ShowStatus(string.Format(_language.XChaptersImported, chaps?.Count)); @@ -32686,7 +32686,7 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.WavePeaks = null; audioVisualizer.SetSpectrogram(null); audioVisualizer.ShotChanges = new List(); - audioVisualizer.Chapters = new List(); + audioVisualizer.Chapters = Array.Empty(); } if (!panelVideoPlayer.Visible) diff --git a/src/ui/Forms/ShotChanges/AdjustTimingViaShotChanges.Designer.cs b/src/ui/Forms/ShotChanges/AdjustTimingViaShotChanges.Designer.cs index 031ba4650..6b89fb69a 100644 --- a/src/ui/Forms/ShotChanges/AdjustTimingViaShotChanges.Designer.cs +++ b/src/ui/Forms/ShotChanges/AdjustTimingViaShotChanges.Designer.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; namespace Nikse.SubtitleEdit.Forms.ShotChanges @@ -112,7 +113,6 @@ namespace Nikse.SubtitleEdit.Forms.ShotChanges | System.Windows.Forms.AnchorStyles.Right))); this.audioVisualizer.BackColor = System.Drawing.Color.Black; this.audioVisualizer.BackgroundColor = System.Drawing.Color.Black; - this.audioVisualizer.Chapters = ((System.Collections.Generic.List)(resources.GetObject("audioVisualizer.Chapters"))); this.audioVisualizer.ChaptersColor = System.Drawing.Color.Empty; this.audioVisualizer.ClosenessForBorderSelection = 15; this.audioVisualizer.Color = System.Drawing.Color.GreenYellow; @@ -375,7 +375,6 @@ namespace Nikse.SubtitleEdit.Forms.ShotChanges // this.videoPlayerContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.videoPlayerContainer1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); - this.videoPlayerContainer1.Chapters = ((System.Collections.Generic.List)(resources.GetObject("videoPlayerContainer1.Chapters"))); this.videoPlayerContainer1.CurrentPosition = 0D; this.videoPlayerContainer1.FontSizeFactor = 1F; this.videoPlayerContainer1.LastParagraph = null; diff --git a/src/ui/SubtitleEdit.csproj b/src/ui/SubtitleEdit.csproj index 5e4a890fd..d314161a0 100644 --- a/src/ui/SubtitleEdit.csproj +++ b/src/ui/SubtitleEdit.csproj @@ -1589,9 +1589,6 @@ DownloadVosk.cs - - GetVideoPosition.cs - WordSplitDictionaryGenerator.cs