Browse Source

Allow reloading to work when browsing folder recursively and when not

Ruben 4 years ago
parent
commit
c96e13e950
2 changed files with 13 additions and 22 deletions
  1. 11 20
      PicView/ChangeImage/Error_Handling.cs
  2. 2 2
      PicView/ChangeImage/LoadPic.cs

+ 11 - 20
PicView/ChangeImage/Error_Handling.cs

@@ -10,7 +10,6 @@ using System.Windows;
 using System.Windows.Threading;
 using static PicView.ChangeImage.Navigation;
 using static PicView.FileHandling.DeleteFiles;
-using static PicView.UILogic.TransformImage.Rotation;
 
 namespace PicView.ChangeImage
 {
@@ -174,13 +173,19 @@ namespace PicView.ChangeImage
                 }
                 path = BackupPath;
             }
-            else if (string.IsNullOrWhiteSpace(Navigation.InitialPath) == false)
-            {
-                path = Navigation.InitialPath;
-            }
             else if (CheckOutOfRange() == false)
             {
-                path = Pics[FolderIndex];
+                // Determine if browsing directories recursively or only update from single directory
+                if (string.IsNullOrWhiteSpace(Navigation.InitialPath) == false
+                    && Properties.Settings.Default.IncludeSubDirectories
+                    && Path.GetDirectoryName(Navigation.InitialPath) != Path.GetDirectoryName(Pics[FolderIndex]))
+                {
+                    path = Navigation.InitialPath;
+                }
+                else
+                {
+                    path = Pics[FolderIndex];
+                }
             }
             else
             {
@@ -260,20 +265,6 @@ namespace PicView.ChangeImage
             {
                 await GalleryFunctions.SortGallery().ConfigureAwait(false);
             }
-
-            // Reset
-            await ConfigureWindows.GetMainWindow.Dispatcher.InvokeAsync(() =>
-            {
-                if (Flipped)
-                {
-                    Flip();
-                }
-
-                if (Rotateint != 0)
-                {
-                    Rotate(0);
-                }
-            });
         }
 
         /// <summary>

+ 2 - 2
PicView/ChangeImage/LoadPic.cs

@@ -305,7 +305,7 @@ namespace PicView.ChangeImage
 
             await FileLists.RetrieveFilelistAsync(fileInfo).ConfigureAwait(false);
 
-            if (Pics.Count < 0)
+            if (Pics.Count < 0) // TODO make function to find first folder with pics, when not browsing recursively
             {
                 await Error_Handling.ReloadAsync(true).ConfigureAwait(false);
                 return;
@@ -325,7 +325,7 @@ namespace PicView.ChangeImage
                 await GalleryLoad.Load().ConfigureAwait(false);
             }
 
-            if (string.IsNullOrWhiteSpace(InitialPath) || folderChanged)
+            if (folderChanged || string.IsNullOrWhiteSpace(InitialPath))
             {
                 InitialPath = fileInfo.FullName;
             }