Przeglądaj źródła

Fix toggling subdirectories not running in background properly

Ruben 1 rok temu
rodzic
commit
1ae5ad3736

+ 4 - 1
src/PicView.WPF/ConfigureSettings/UpdateUIValues.cs

@@ -232,13 +232,16 @@ namespace PicView.WPF.ConfigureSettings
 
             Navigation.Pics = fileList;
 
+            var checkIfGalleryHasChildren = false;
+
             await GetMainWindow.Dispatcher.InvokeAsync(() =>
             {
                 SetTitle.SetTitleString(preloadValue.BitmapSource.PixelWidth, preloadValue.BitmapSource.PixelHeight,
                     Navigation.FolderIndex, preloadValue.FileInfo);
+                checkIfGalleryHasChildren = UC.GetPicGallery?.Container.Children.Count > 0;
             });
 
-            if (UC.GetPicGallery?.Container.Children.Count > 0)
+            if (checkIfGalleryHasChildren)
             {
                 if (initialValue)
                 {

+ 8 - 3
src/PicView.WPF/Views/Windows/SettingsWindow.xaml.cs

@@ -31,7 +31,7 @@ namespace PicView.WPF.Views.Windows
             Width *= WindowSizing.MonitorInfo.DpiScaling;
             if (double.IsNaN(Width)) // Fixes if user opens window when loading from startup
             {
-                WindowSizing.MonitorInfo = MonitorSize.GetMonitorSize();
+                WindowSizing.MonitorInfo = MonitorSize.GetMonitorSize(this);
                 MaxHeight = WindowSizing.MonitorInfo.WorkArea.Height;
                 Width *= WindowSizing.MonitorInfo.DpiScaling;
             }
@@ -56,8 +56,13 @@ namespace PicView.WPF.Views.Windows
 
                 // SubDirRadio
                 SubDirRadio.IsChecked = Settings.Default.IncludeSubDirectories;
-                SubDirRadio.Click += async (_, _) =>
-                    await UpdateUIValues.ToggleIncludeSubdirectoriesAsync().ConfigureAwait(false);
+                SubDirRadio.Click += async delegate
+                {
+                    await Task.Run(async () =>
+                    {
+                        await UpdateUIValues.ToggleIncludeSubdirectoriesAsync().ConfigureAwait(false);
+                    });
+                };
 
                 // Slideshow
                 SlideshowSlider.Value = Settings.Default.SlideTimer / 1000;