Ruben пре 1 година
родитељ
комит
25ee90a404

+ 0 - 0
src/PicView.Core/Localization/TranslationService.cs → src/PicView.Core/Localization/TranslationHelper.cs


+ 276 - 0
src/PicView.Core/Navigation/FileHistory.cs

@@ -0,0 +1,276 @@
+using System.Diagnostics;
+using System.Text.Json;
+
+namespace PicView.Core.Navigation
+{
+    /// <summary>
+    /// Represents an entry in the file history.
+    /// </summary>
+    public class FileEntry
+    {
+        /// <summary>
+        /// Gets or sets the file path.
+        /// </summary>
+        public string FilePath { get; set; }
+
+        /// <summary>
+        /// Gets or sets the top-level directory.
+        /// </summary>
+        public string TopLevelDirectory { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="FileEntry"/> class.
+        /// </summary>
+        /// <param name="filePath">The file path.</param>
+        /// <param name="topLevelDirectory">The top-level directory.</param>
+        public FileEntry(string filePath, string topLevelDirectory)
+        {
+            FilePath = filePath;
+            TopLevelDirectory = topLevelDirectory;
+        }
+    }
+
+    /// <summary>
+    /// Manages the history of recently accessed files.
+    /// </summary>
+    public class FileHistory
+    {
+        private readonly List<FileEntry?> _fileHistory;
+        public const short MaxCount = 15;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="FileHistory"/> class.
+        /// </summary>
+        public FileHistory()
+        {
+            _fileHistory ??= new List<FileEntry?>();
+
+            try
+            {
+                var jsonFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/recent.json");
+
+                if (!File.Exists(jsonFile))
+                {
+                    using var fs = File.Create(jsonFile);
+                    fs.Seek(0, SeekOrigin.Begin);
+                }
+            }
+            catch (Exception e)
+            {
+#if DEBUG
+                Trace.WriteLine($"{nameof(FileHistory)} exception, \n{e.Message}");
+#endif
+            }
+            ReadFromFile();
+        }
+
+        /// <summary>
+        /// Reads the file history from a JSON file.
+        /// </summary>
+        /// <returns>An empty string if successful, otherwise an error message.</returns>
+        public string ReadFromFile()
+        {
+            lock (_fileHistory)
+            {
+                _fileHistory.Clear();
+            }
+
+            try
+            {
+                var json = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/recent.json"));
+                lock (_fileHistory)
+                {
+                    _fileHistory.AddRange(JsonSerializer.Deserialize<List<FileEntry>>(json));
+                }
+            }
+            catch (Exception e)
+            {
+#if DEBUG
+                Trace.WriteLine($"{nameof(FileHistory)}: {nameof(ReadFromFile)} exception,\n{e.Message}");
+#endif
+                return e.Message;
+            }
+            return string.Empty;
+        }
+
+        /// <summary>
+        /// Writes the file history to a JSON file.
+        /// </summary>
+        /// <returns>An empty string if successful, otherwise an error message.</returns>
+        public string WriteToFile()
+        {
+            try
+            {
+                lock (_fileHistory)
+                {
+                    var json = JsonSerializer.Serialize(_fileHistory);
+                    File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/recent.json"), json);
+                }
+            }
+            catch (Exception e)
+            {
+                return e.Message;
+            }
+            return string.Empty;
+        }
+
+        public int GetCount()
+        {
+            lock (_fileHistory)
+            {
+                return _fileHistory.Count;
+            }
+        }
+
+        /// <summary>
+        /// Adds a file to the history.
+        /// </summary>
+        /// <param name="fileName">The name of the file to add.</param>
+        public void Add(string fileName)
+        {
+            if (string.IsNullOrWhiteSpace(fileName))
+            {
+                return;
+            }
+
+            lock (_fileHistory)
+            {
+                if (_fileHistory.Exists(e => e.FilePath.EndsWith(fileName)))
+                {
+                    return;
+                }
+
+                if (_fileHistory.Count >= MaxCount)
+                {
+                    _fileHistory.RemoveAt(0);
+                }
+
+                var entry = new FileEntry(fileName, Path.GetDirectoryName(fileName));
+
+                _fileHistory.Add(entry);
+            }
+        }
+
+        /// <summary>
+        /// Gets the last file in the history.
+        /// </summary>
+        /// <returns>The last file entry or null if the history is empty.</returns>
+        public FileEntry? GetLastFile()
+        {
+            lock (_fileHistory)
+            {
+                return _fileHistory.Count > 0 ? _fileHistory[^1] : null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the first file in the history.
+        /// </summary>
+        /// <returns>The first file entry or null if the history is empty.</returns>
+        public FileEntry? GetFirstFile()
+        {
+            lock (_fileHistory)
+            {
+                return _fileHistory.Count > 0 ? _fileHistory[0] : null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the file entry at the specified index.
+        /// </summary>
+        /// <param name="index">The index of the file entry to retrieve.</param>
+        /// <returns>The file entry at the specified index or null if the history is empty.</returns>
+        public FileEntry? GetEntryAt(int index)
+        {
+            lock (_fileHistory)
+            {
+                if (_fileHistory.Count == 0)
+                {
+                    return null;
+                }
+
+                if (index < 0)
+                {
+                    return _fileHistory[0];
+                }
+
+                return index >= _fileHistory.Count ? _fileHistory[^1] : _fileHistory[index];
+            }
+        }
+
+        /// <summary>
+        /// Gets the next file entry based on the current index and list of file names.
+        /// </summary>
+        /// <param name="looping">Whether to loop to the beginning when reaching the end.</param>
+        /// <param name="index">The current index in the list.</param>
+        /// <param name="list">The list of file names.</param>
+        /// <returns>The next file entry or null if not found or an exception occurs.</returns>
+        public FileEntry? GetNextEntry(bool looping, int index, List<string> list)
+        {
+            if (list.Count <= 0)
+            {
+                return GetLastFile();
+            }
+
+            try
+            {
+                lock (_fileHistory)
+                {
+                    var foundIndex = _fileHistory.FindIndex(entry => entry.FilePath == list[index]);
+
+                    if (looping)
+                    {
+                        return GetEntryAt((foundIndex + 1 + _fileHistory.Count) % _fileHistory.Count);
+                    }
+
+                    foundIndex++;
+                    return foundIndex >= MaxCount ? null : GetEntryAt(foundIndex);
+                }
+            }
+            catch (Exception e)
+            {
+#if DEBUG
+                Trace.WriteLine($"{nameof(FileHistory)}: {nameof(GetNextEntry)} exception,\n{e.Message}");
+#endif
+                return null;
+            }
+        }
+
+        /// <summary>
+        /// Gets the previous file entry based on the current index and list of file names.
+        /// </summary>
+        /// <param name="looping">Whether to loop to the end when reaching the beginning.</param>
+        /// <param name="index">The current index in the list.</param>
+        /// <param name="list">The list of file names.</param>
+        /// <returns>The previous file entry or null if not found or an exception occurs.</returns>
+        public FileEntry? GetPreviousEntry(bool looping, int index, List<string> list)
+        {
+            if (list.Count <= 0)
+            {
+                return GetLastFile();
+            }
+
+            try
+            {
+                lock (_fileHistory)
+                {
+                    var foundIndex = _fileHistory.FindIndex(entry => entry.FilePath == list[index]);
+                    if (looping)
+                    {
+                        return GetEntryAt((foundIndex - 1 + _fileHistory.Count) % _fileHistory.Count);
+                    }
+
+                    index--;
+                    return index < 0 ? null : GetEntryAt(index);
+                }
+            }
+            catch (Exception e)
+            {
+#if DEBUG
+                Trace.WriteLine($"{nameof(FileHistory)}: {nameof(GetPreviousEntry)} exception,\n{e.Message}");
+#endif
+                return null;
+            }
+        }
+    }
+}

+ 71 - 167
src/PicView.WPF/ChangeImage/FileHistory.cs → src/PicView.WPF/ChangeImage/FileHistoryNavigation.cs

@@ -6,6 +6,7 @@ using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Threading;
 using PicView.Core.FileHandling;
+using PicView.Core.Navigation;
 using PicView.WPF.ChangeTitlebar;
 using PicView.WPF.FileHandling;
 using PicView.WPF.PicGallery;
@@ -15,87 +16,18 @@ using PicView.WPF.UILogic.Sizing;
 
 namespace PicView.WPF.ChangeImage
 {
-    internal class FileHistory
+    internal static class FileHistoryNavigation
     {
-        private readonly List<string> _fileHistory;
-        private const short MaxCount = 15;
-        private readonly string _path;
+        private static FileHistory? _fileHistory;
 
-        internal FileHistory()
+        internal static void Add(string file)
         {
-            _fileHistory ??= new List<string>();
-            try
-            {
-                _path = FileFunctions.GetWritingPath() + "\\Recent.txt";
-
-                if (!File.Exists(_path))
-                {
-                    using var fs = File.Create(_path);
-                    fs.Seek(0, SeekOrigin.Begin);
-                }
-            }
-            catch (Exception e)
-            {
-                _path = "";
-            }
-
-            ReadFromFile();
-        }
-
-        private void ReadFromFile()
-        {
-            _fileHistory.Clear();
-
-            if (!File.Exists(_path))
-            {
-                return;
-            }
-
-            try
-            {
-                using var reader = new StreamReader(_path);
-                while (reader.Peek() >= 0)
-                {
-                    _fileHistory.Add(reader.ReadLine());
-                }
-            }
-            catch (Exception e)
-            {
-                Tooltip.ShowTooltipMessage(e.Message, true, TimeSpan.FromSeconds(5));
-            }
-        }
-
-        /// <summary>
-        /// Write all entries to the Recent.txt file
-        /// </summary>
-        internal void WriteToFile()
-        {
-            try
-            {
-                using var writer = new StreamWriter(_path);
-                foreach (var item in _fileHistory)
-                {
-                    writer.WriteLine(item);
-                }
-            }
-            catch (Exception e)
-            {
-                Tooltip.ShowTooltipMessage(e.Message, true, TimeSpan.FromSeconds(5));
-            }
+            _fileHistory ??= new FileHistory();
+            _fileHistory.Add(file);
         }
 
-        internal async Task OpenLastFileAsync()
+        internal static async Task OpenLastFileAsync()
         {
-            if (_fileHistory.Count <= 0)
-            {
-                return;
-            }
-
-            if (!File.Exists(_fileHistory.Last()))
-            {
-                return;
-            }
-
             await ConfigureWindows.GetMainWindow.Dispatcher.InvokeAsync(() =>
             {
                 if (UC.GetStartUpUC is not null)
@@ -108,93 +40,79 @@ namespace PicView.WPF.ChangeImage
                 UC.GetSpinWaiter.Visibility = Visibility.Visible;
             }, DispatcherPriority.Normal);
 
+            _fileHistory ??= new FileHistory();
+            var fileEntry = await Task.FromResult(_fileHistory.GetLastFile()).ConfigureAwait(false);
+            if (fileEntry is null)
+            {
+                return;
+            }
             await Task.Run(async () => // Make sure UI responsive
             {
                 if (Settings.Default.IncludeSubDirectories)
                 {
-                    if (_fileHistory.Last().IsArchive())
+                    if (fileEntry.FilePath.IsArchive())
                     {
-                        await LoadPic.LoadPicFromArchiveAsync(_fileHistory.Last()).ConfigureAwait(false);
+                        await LoadPic.LoadPicFromArchiveAsync(fileEntry.FilePath).ConfigureAwait(false);
                         return;
                     }
 
-                    var currentFolder = Path.GetDirectoryName(_fileHistory.Last());
-                    var parentFolder = Path.GetDirectoryName(currentFolder);
-                    var fileInfo = new FileInfo(parentFolder);
+                    var fileInfo = new FileInfo(fileEntry.TopLevelDirectory);
                     Navigation.Pics = await Task.FromResult(FileLists.FileList(fileInfo)).ConfigureAwait(false);
                     if (Navigation.Pics.Count > 0)
                     {
-                        Navigation.FolderIndex = Navigation.Pics.IndexOf(_fileHistory.Last());
+                        Navigation.FolderIndex = Navigation.Pics.IndexOf(fileEntry.FilePath);
                         await LoadPic.LoadPicAtIndexAsync(Navigation.FolderIndex).ConfigureAwait(false);
 
                         // Fix if Bottom Gallery is enabled
                         if (Settings.Default.IsBottomGalleryShown)
                         {
-                            if (UC.GetPicGallery is null)
-                            {
-                                await ConfigureWindows.GetMainWindow.Dispatcher.InvokeAsync(GalleryToggle.ShowBottomGallery);
-                                await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
-                                {
-                                    GalleryToggle.ShowBottomGallery();
-                                    ScaleImage.TryFitImage();
-                                });
-                                await GalleryLoad.LoadAsync().ConfigureAwait(false);
-                            }
-                            else if (UC.GetPicGallery is { Visibility: Visibility.Collapsed })
+                            switch (UC.GetPicGallery)
                             {
-                                var shouldLoadGallery = false;
-                                await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
-                                {
-                                    GalleryToggle.ShowBottomGallery();
-                                    ScaleImage.TryFitImage();
-                                    if (UC.GetPicGallery.Container.Children.Count <= 0)
+                                case null:
+                                    await ConfigureWindows.GetMainWindow.Dispatcher.InvokeAsync(GalleryToggle.ShowBottomGallery);
+                                    await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
                                     {
-                                        shouldLoadGallery = true;
-                                    }
-                                });
-                                if (shouldLoadGallery)
-                                {
+                                        GalleryToggle.ShowBottomGallery();
+                                        ScaleImage.TryFitImage();
+                                    });
                                     await GalleryLoad.LoadAsync().ConfigureAwait(false);
-                                }
+                                    break;
+
+                                case { Visibility: Visibility.Collapsed }:
+                                    {
+                                        var shouldLoadGallery = false;
+                                        await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
+                                        {
+                                            GalleryToggle.ShowBottomGallery();
+                                            ScaleImage.TryFitImage();
+                                            if (UC.GetPicGallery.Container.Children.Count <= 0)
+                                            {
+                                                shouldLoadGallery = true;
+                                            }
+                                        });
+                                        if (shouldLoadGallery)
+                                        {
+                                            await GalleryLoad.LoadAsync().ConfigureAwait(false);
+                                        }
+
+                                        break;
+                                    }
                             }
                         }
                     }
                     else
                     {
-                        await LoadPic.LoadPicFromStringAsync(_fileHistory.Last()).ConfigureAwait(false);
+                        await LoadPic.LoadPicFromStringAsync(fileEntry.FilePath).ConfigureAwait(false);
                     }
                 }
                 else
                 {
-                    await LoadPic.LoadPicFromStringAsync(_fileHistory.Last()).ConfigureAwait(false);
+                    await LoadPic.LoadPicFromStringAsync(fileEntry.FilePath).ConfigureAwait(false);
                 }
             });
         }
 
-        internal void Add(string fileName)
-        {
-            if (string.IsNullOrWhiteSpace(fileName))
-            {
-                return;
-            }
-
-            lock (_fileHistory) // index out of range exception when multiple threads accessing it
-            {
-                if (_fileHistory.Exists(e => e.EndsWith(fileName)))
-                {
-                    return;
-                }
-
-                if (_fileHistory.Count >= MaxCount)
-                {
-                    _fileHistory.Remove(_fileHistory[0]);
-                }
-
-                _fileHistory.Add(fileName);
-            }
-        }
-
-        internal async Task NextAsync()
+        internal static async Task NextAsync()
         {
             if (Navigation.Pics.Count <= 0)
             {
@@ -202,21 +120,12 @@ namespace PicView.WPF.ChangeImage
                 return;
             }
 
-            var index = _fileHistory.IndexOf(Navigation.Pics[Navigation.FolderIndex]);
-            if (Settings.Default.Looping)
-            {
-                index = (index + 1 + _fileHistory.Count) % _fileHistory.Count;
-            }
-            else
-            {
-                index++;
-                if (index >= MaxCount)
-                    return;
-            }
+            _fileHistory ??= new FileHistory();
+            var fileEntry = await Task.FromResult(_fileHistory.GetNextEntry(Settings.Default.Looping, Navigation.FolderIndex, Navigation.Pics)).ConfigureAwait(false);
 
-            if (Navigation.Pics.Contains(_fileHistory[index]))
+            if (Navigation.Pics.Contains(fileEntry.FilePath))
             {
-                if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
+                if (fileEntry.FilePath == Navigation.Pics[Navigation.FolderIndex])
                 {
                     return;
                 }
@@ -231,14 +140,14 @@ namespace PicView.WPF.ChangeImage
                         GalleryNavigation.SetSelected(Navigation.FolderIndex, false);
                     });
                 }
-                await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(_fileHistory[index])).ConfigureAwait(false);
+                await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(fileEntry.FilePath)).ConfigureAwait(false);
                 return;
             }
 
-            await LoadPic.LoadPicFromStringAsync(_fileHistory[index]).ConfigureAwait(false);
+            await LoadPic.LoadPicFromStringAsync(fileEntry.FilePath).ConfigureAwait(false);
         }
 
-        internal async Task PrevAsync()
+        internal static async Task PrevAsync()
         {
             if (Navigation.Pics.Count <= 0)
             {
@@ -246,23 +155,12 @@ namespace PicView.WPF.ChangeImage
                 return;
             }
 
-            var index = _fileHistory.IndexOf(Navigation.Pics[Navigation.FolderIndex]);
-            if (Settings.Default.Looping)
-            {
-                index = (index - 1 + _fileHistory.Count) % _fileHistory.Count;
-            }
-            else
-            {
-                index--;
-                if (index < 0)
-                {
-                    return;
-                }
-            }
+            _fileHistory ??= new FileHistory();
+            var fileEntry = await Task.FromResult(_fileHistory.GetNextEntry(Settings.Default.Looping, Navigation.FolderIndex, Navigation.Pics)).ConfigureAwait(false);
 
-            if (Navigation.Pics.Contains(_fileHistory[index]))
+            if (Navigation.Pics.Contains(fileEntry.FilePath))
             {
-                if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
+                if (fileEntry.FilePath == Navigation.Pics[Navigation.FolderIndex])
                 {
                     return;
                 }
@@ -277,11 +175,11 @@ namespace PicView.WPF.ChangeImage
                         GalleryNavigation.SetSelected(Navigation.FolderIndex, false);
                     });
                 }
-                await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(_fileHistory[index])).ConfigureAwait(false);
+                await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(fileEntry.FilePath)).ConfigureAwait(false);
                 return;
             }
 
-            await LoadPic.LoadPicFromStringAsync(_fileHistory[index]).ConfigureAwait(false);
+            await LoadPic.LoadPicFromStringAsync(fileEntry.FilePath).ConfigureAwait(false);
         }
 
         private static MenuItem MenuItem(string filePath, int i)
@@ -332,20 +230,20 @@ namespace PicView.WPF.ChangeImage
             return menuItem;
         }
 
-        internal void RefreshRecentItemsMenu()
+        internal static void RefreshRecentItemsMenu()
         {
             try
             {
                 var cm = (MenuItem)ConfigureWindows.MainContextMenu.Items[6];
 
-                for (var i = 0; i < MaxCount; i++)
+                for (var i = 0; i < FileHistory.MaxCount; i++)
                 {
-                    if (_fileHistory.Count == i)
+                    if (_fileHistory.GetCount() == i)
                     {
                         return;
                     }
 
-                    var item = MenuItem(_fileHistory[i], i);
+                    var item = MenuItem(_fileHistory.GetEntryAt(i).FilePath, i);
                     if (cm.Items.Count <= i)
                     {
                         cm.Items.Add(item);
@@ -363,5 +261,11 @@ namespace PicView.WPF.ChangeImage
 #endif
             }
         }
+
+        internal static void WriteToFile()
+        {
+            _fileHistory ??= new FileHistory();
+            _fileHistory.WriteToFile();
+        }
     }
 }

+ 1 - 2
src/PicView.WPF/ChangeImage/LoadPic.cs

@@ -556,8 +556,7 @@ namespace PicView.WPF.ChangeImage
             // Add recent files, except when browsing archive
             if (string.IsNullOrWhiteSpace(ArchiveExtraction.TempZipFile) && Pics.Count > index)
             {
-                GetFileHistory ??= new FileHistory();
-                GetFileHistory.Add(Pics[index]);
+                FileHistoryNavigation.Add(Pics[index]);
             }
             return;
 

+ 2 - 3
src/PicView.WPF/ChangeImage/Navigation.cs

@@ -1,4 +1,5 @@
-using PicView.WPF.ChangeTitlebar;
+using PicView.Core.Navigation;
+using PicView.WPF.ChangeTitlebar;
 using PicView.WPF.FileHandling;
 using PicView.WPF.PicGallery;
 using PicView.WPF.Properties;
@@ -63,8 +64,6 @@ namespace PicView.WPF.ChangeImage
         /// </summary>
         internal static bool ClickArrowLeftClicked { get; set; }
 
-        internal static FileHistory? GetFileHistory;
-
         #endregion Static fields
 
         #region Change navigation values

+ 1 - 2
src/PicView.WPF/ChangeImage/QuickLoad.cs

@@ -131,8 +131,7 @@ namespace PicView.WPF.ChangeImage
             // Add recent files, except when browsing archive
             if (string.IsNullOrWhiteSpace(ArchiveExtraction.TempZipFile) && Pics.Count > FolderIndex)
             {
-                GetFileHistory ??= new FileHistory();
-                GetFileHistory.Add(Pics[FolderIndex]);
+                FileHistoryNavigation.Add(Pics[FolderIndex]);
             }
         });
     }

+ 1 - 2
src/PicView.WPF/FileHandling/ArchiveExtraction.cs

@@ -185,8 +185,7 @@ namespace PicView.WPF.FileHandling
                             }
                         }
 
-                        GetFileHistory ??= new FileHistory();
-                        GetFileHistory.Add(Core.FileHandling.ArchiveExtraction.TempZipFile);
+                        FileHistoryNavigation.Add(Core.FileHandling.ArchiveExtraction.TempZipFile);
 
                         if (Settings.Default.IsBottomGalleryShown)
                         {

+ 1 - 2
src/PicView.WPF/FileHandling/HttpFunctions.cs

@@ -73,8 +73,7 @@ namespace PicView.WPF.FileHandling
                     ConfigureWindows.GetMainWindow.Focus();
                 }
             });
-            Navigation.GetFileHistory ??= new FileHistory();
-            Navigation.GetFileHistory.Add(url);
+            FileHistoryNavigation.Add(url);
             Navigation.InitialPath = url;
         }
 

+ 2 - 2
src/PicView.WPF/Shortcuts/MainMouseKeys.cs

@@ -106,11 +106,11 @@ namespace PicView.WPF.Shortcuts
                     break;
 
                 case MouseButton.XButton1:
-                    await GetFileHistory.PrevAsync().ConfigureAwait(false);
+                    await FileHistoryNavigation.PrevAsync().ConfigureAwait(false);
                     break;
 
                 case MouseButton.XButton2:
-                    await GetFileHistory.NextAsync().ConfigureAwait(false);
+                    await FileHistoryNavigation.NextAsync().ConfigureAwait(false);
                     break;
             }
         }

+ 2 - 3
src/PicView.WPF/UILogic/Loading/LoadContextMenus.cs

@@ -2,6 +2,7 @@
 using System.Windows.Controls;
 using System.Windows.Input;
 using PicView.Core.FileHandling;
+using PicView.Core.Navigation;
 using PicView.WPF.ChangeImage;
 using PicView.WPF.ConfigureSettings;
 using PicView.WPF.FileHandling;
@@ -20,12 +21,10 @@ namespace PicView.WPF.UILogic.Loading
     {
         internal static void AddContextMenus()
         {
-            GetFileHistory ??= new FileHistory();
-
             // Add main contextmenu
             MainContextMenu = (ContextMenu)Application.Current.Resources["mainCM"];
             GetMainWindow.ParentContainer.ContextMenu = MainContextMenu;
-            MainContextMenu.Opened += (_, _) => GetFileHistory.RefreshRecentItemsMenu();
+            MainContextMenu.Opened += (_, _) => FileHistoryNavigation.RefreshRecentItemsMenu();
 
             ///////////////////////////
             //     Open              \\

+ 1 - 1
src/PicView.WPF/UILogic/Loading/StartLoading.cs

@@ -13,6 +13,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using PicView.Core.Navigation;
 using static PicView.WPF.ChangeImage.Navigation;
 using static PicView.WPF.UILogic.Loading.LoadContextMenus;
 using static PicView.WPF.UILogic.Loading.LoadControls;
@@ -293,7 +294,6 @@ namespace PicView.WPF.UILogic.Loading
 
             // Initialize things!
             InitializeZoom();
-            GetFileHistory ??= new FileHistory();
 
             // Add things!
             Timers.AddTimers();

+ 1 - 1
src/PicView.WPF/UILogic/Sizing/WindowSizing.cs

@@ -369,7 +369,7 @@ namespace PicView.WPF.UILogic.Sizing
 
             Settings.Default.Save();
             DeleteFiles.DeleteTempFiles();
-            Navigation.GetFileHistory.WriteToFile();
+            FileHistoryNavigation.WriteToFile();
             // Update the keybindings.json file
             await CustomKeybindings.UpdateKeyBindingsFile();
             Application.Current.Shutdown();

+ 1 - 1
src/PicView.WPF/Views/UserControls/Misc/StartUpUC.xaml.cs

@@ -129,7 +129,7 @@ namespace PicView.WPF.Views.UserControls.Misc
             SelectFile.Click += async (_, _) => await OpenSave.OpenAsync().ConfigureAwait(false);
 
             OpenLastFileButton.Click += async (_, _) =>
-                await Navigation.GetFileHistory.OpenLastFileAsync().ConfigureAwait(false);
+                await FileHistoryNavigation.OpenLastFileAsync().ConfigureAwait(false);
 
             PasteButton.Click += async (_, _) => await CopyPaste.PasteAsync().ConfigureAwait(false);
         }