mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 11:42:36 +01:00
parent
a835d82a1d
commit
4117249c17
@ -51,29 +51,20 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return;
|
||||
}
|
||||
|
||||
var newList = new List<RecentFileEntry> { new RecentFileEntry { FileName = fileName, FirstVisibleIndex = firstVisibleIndex, FirstSelectedIndex = firstSelectedIndex, VideoFileName = videoFileName, OriginalFileName = originalFileName, VideoOffsetInMs = videoOffset } };
|
||||
int index = 0;
|
||||
foreach (var oldRecentFile in Files)
|
||||
var existingEntry = GetRecentFile(fileName, originalFileName);
|
||||
if (existingEntry == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(originalFileName))
|
||||
{
|
||||
if (!(fileName.Equals(oldRecentFile.FileName, StringComparison.OrdinalIgnoreCase) && originalFileName.Equals(oldRecentFile.OriginalFileName, StringComparison.OrdinalIgnoreCase))
|
||||
&& index < MaxRecentFiles)
|
||||
{
|
||||
newList.Add(new RecentFileEntry { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName, OriginalFileName = oldRecentFile.OriginalFileName, VideoOffsetInMs = oldRecentFile.VideoOffsetInMs });
|
||||
}
|
||||
Files.Insert(0, new RecentFileEntry { FileName = fileName ?? string.Empty, FirstVisibleIndex = -1, FirstSelectedIndex = -1, VideoFileName = videoFileName, OriginalFileName = originalFileName });
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(fileName.Equals(oldRecentFile.FileName, StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(oldRecentFile.OriginalFileName)) && index < MaxRecentFiles)
|
||||
{
|
||||
newList.Add(new RecentFileEntry { FileName = oldRecentFile.FileName, FirstVisibleIndex = oldRecentFile.FirstVisibleIndex, FirstSelectedIndex = oldRecentFile.FirstSelectedIndex, VideoFileName = oldRecentFile.VideoFileName, OriginalFileName = oldRecentFile.OriginalFileName, VideoOffsetInMs = oldRecentFile.VideoOffsetInMs });
|
||||
Files.Remove(existingEntry);
|
||||
existingEntry.FirstSelectedIndex = firstSelectedIndex;
|
||||
existingEntry.VideoOffsetInMs = videoOffset;
|
||||
existingEntry.FirstVisibleIndex = firstVisibleIndex;
|
||||
Files.Insert(0, existingEntry);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
Files = newList;
|
||||
}
|
||||
|
||||
public void Add(string fileName, string videoFileName, string originalFileName)
|
||||
{
|
||||
@ -82,6 +73,20 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Files = Files.Where(p => !string.IsNullOrEmpty(p.FileName)).ToList();
|
||||
}
|
||||
|
||||
var existingEntry = GetRecentFile(fileName, originalFileName);
|
||||
if (existingEntry == null)
|
||||
{
|
||||
Files.Insert(0, new RecentFileEntry { FileName = fileName ?? string.Empty, FirstVisibleIndex = -1, FirstSelectedIndex = -1, VideoFileName = videoFileName, OriginalFileName = originalFileName });
|
||||
}
|
||||
else
|
||||
{
|
||||
Files.Remove(existingEntry);
|
||||
Files.Insert(0, existingEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private RecentFileEntry GetRecentFile(string fileName, string originalFileName)
|
||||
{
|
||||
RecentFileEntry existingEntry;
|
||||
if (string.IsNullOrEmpty(originalFileName))
|
||||
{
|
||||
@ -96,16 +101,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
p.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase) &&
|
||||
p.OriginalFileName.Equals(originalFileName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (existingEntry == null)
|
||||
{
|
||||
Files.Insert(0, new RecentFileEntry { FileName = fileName ?? string.Empty, FirstVisibleIndex = -1, FirstSelectedIndex = -1, VideoFileName = videoFileName, OriginalFileName = originalFileName });
|
||||
}
|
||||
else
|
||||
{
|
||||
Files.Remove(existingEntry);
|
||||
Files.Insert(0, existingEntry);
|
||||
}
|
||||
return existingEntry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2095,7 +2095,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
OpenRecentFile(rfe);
|
||||
GotoSubPosAndPause();
|
||||
SubtitleListview1.EndUpdate();
|
||||
SetRecentIndices(fileName);
|
||||
SetRecentIndices(rfe);
|
||||
if (!string.IsNullOrEmpty(rfe.VideoFileName))
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(rfe.FirstSelectedIndex);
|
||||
@ -3438,6 +3438,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (ContinueNewOrExit())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_fileName))
|
||||
{
|
||||
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs);
|
||||
}
|
||||
|
||||
RecentFileEntry rfe = null;
|
||||
foreach (var file in Configuration.Settings.RecentFiles.Files.Where(p => !string.IsNullOrEmpty(p.OriginalFileName)))
|
||||
{
|
||||
@ -3472,7 +3477,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
GotoSubPosAndPause();
|
||||
SetRecentIndices(item.Text);
|
||||
SetRecentIndices(rfe);
|
||||
SubtitleListview1.EndUpdate();
|
||||
if (rfe != null && !string.IsNullOrEmpty(rfe.VideoFileName))
|
||||
{
|
||||
@ -3487,11 +3492,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void OpenRecentFile(RecentFileEntry rfe)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_fileName))
|
||||
{
|
||||
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs);
|
||||
}
|
||||
|
||||
OpenSubtitle(rfe.FileName, null, rfe.VideoFileName, rfe.OriginalFileName, false);
|
||||
Configuration.Settings.General.CurrentVideoOffsetInMs = rfe.VideoOffsetInMs;
|
||||
if (rfe.VideoOffsetInMs != 0)
|
||||
@ -3523,7 +3523,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void SetRecentIndices(string fileName)
|
||||
private void SetRecentIndices(RecentFileEntry rfe)
|
||||
{
|
||||
if (!Configuration.Settings.General.RememberSelectedLine)
|
||||
{
|
||||
@ -3532,22 +3532,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
ShowSubtitleTimer.Stop();
|
||||
Application.DoEvents();
|
||||
foreach (var x in Configuration.Settings.RecentFiles.Files)
|
||||
{
|
||||
if (fileName.Equals(x.FileName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int sIndex = x.FirstSelectedIndex;
|
||||
if (sIndex >= 0 && sIndex < SubtitleListview1.Items.Count)
|
||||
if (rfe != null && !string.IsNullOrEmpty(rfe.FileName) &&
|
||||
rfe.FirstSelectedIndex >= 0 && rfe.FirstSelectedIndex < SubtitleListview1.Items.Count)
|
||||
{
|
||||
SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged;
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(sIndex, true);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(rfe.FirstSelectedIndex, true);
|
||||
_subtitleListViewIndex = -1;
|
||||
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
RefreshSelectedParagraph();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_loading)
|
||||
|
Loading…
Reference in New Issue
Block a user