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