@@ -47,6 +47,7 @@ public sealed class ShellViewModel : ObservableObject, IDisposable
4747
4848 // Files and folders list for manipulating
4949 private ConcurrentCollection < ListedItem > filesAndFolders ;
50+ private readonly IWindowsIniService WindowsIniService = Ioc . Default . GetRequiredService < IWindowsIniService > ( ) ;
5051 private readonly IWindowsJumpListService jumpListService = Ioc . Default . GetRequiredService < IWindowsJumpListService > ( ) ;
5152 private readonly IDialogService dialogService = Ioc . Default . GetRequiredService < IDialogService > ( ) ;
5253 private IUserSettingsService UserSettingsService { get ; } = Ioc . Default . GetRequiredService < IUserSettingsService > ( ) ;
@@ -154,6 +155,8 @@ public GitProperties EnabledGitProperties
154155
155156 public bool IsValidGitDirectory { get ; private set ; }
156157
158+ public List < IniSectionDataItem > DesktopIni { get ; private set ; }
159+
157160 private StorageFolderWithPath ? currentStorageFolder ;
158161 private StorageFolderWithPath workingRoot ;
159162
@@ -1443,7 +1446,7 @@ private async Task RapidAddItemsToCollectionAsync(string path, string? previousD
14431446 ItemLoadStatusChanged ? . Invoke ( this , new ItemLoadStatusChangedEventArgs ( ) { Status = ItemLoadStatusChangedEventArgs . ItemLoadStatus . Complete , PreviousDirectory = previousDir , Path = path } ) ;
14441447 IsLoadingItems = false ;
14451448
1446- AdaptiveLayoutHelpers . ApplyAdaptativeLayout ( folderSettings , WorkingDirectory , filesAndFolders . ToList ( ) ) ;
1449+ AdaptiveLayoutHelpers . ApplyAdaptativeLayout ( folderSettings , filesAndFolders . ToList ( ) ) ;
14471450 }
14481451 finally
14491452 {
@@ -1736,6 +1739,7 @@ await Task.Run(async () =>
17361739 await OrderFilesAndFoldersAsync ( ) ;
17371740 await ApplyFilesAndFoldersChangesAsync ( ) ;
17381741 await dispatcherQueue . EnqueueOrInvokeAsync ( CheckForSolutionFile , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1742+ await dispatcherQueue . EnqueueOrInvokeAsync ( GetDesktopIniFileData , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
17391743 await dispatcherQueue . EnqueueOrInvokeAsync ( CheckForBackgroundImage , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
17401744 } ) ;
17411745
@@ -1797,51 +1801,61 @@ private void CheckForSolutionFile()
17971801 . FirstOrDefault ( ) ? . ItemPath ;
17981802 }
17991803
1804+ private void GetDesktopIniFileData ( )
1805+ {
1806+ var path = Path . Combine ( WorkingDirectory , "desktop.ini" ) ;
1807+ DesktopIni = WindowsIniService . GetData ( path ) ;
1808+ }
1809+
18001810 public void CheckForBackgroundImage ( )
18011811 {
1802- var iniPath = Path . Combine ( WorkingDirectory , "desktop.ini" ) ;
1803- if ( ! File . Exists ( iniPath ) )
1812+ var filesAppSection = DesktopIni . FirstOrDefault ( x => x . SectionName == "FilesApp" ) ;
1813+ if ( filesAppSection is null || folderSettings . LayoutMode is FolderLayoutModes . ColumnView )
1814+ {
1815+ FolderBackgroundImageSource = null ;
18041816 return ;
1805-
1806- // Read data
1807- var lines = File . ReadLines ( iniPath ) ;
1808- var keys = lines . Select ( line => line . Split ( '=' ) )
1809- . Where ( parts => parts . Length == 2 )
1810- . ToDictionary ( parts => parts [ 0 ] . Trim ( ) , parts => parts [ 1 ] . Trim ( ) ) ;
1817+ }
18111818
18121819 // Image source
1813- if ( folderSettings . LayoutMode is not FolderLayoutModes . ColumnView && keys . TryGetValue ( "Files_BackgroundImage" , out var backgroundImage ) )
1820+ var backgroundImage = filesAppSection . Parameters . FirstOrDefault ( x => x . Key == "Files_BackgroundImage" ) . Value ;
1821+ if ( string . IsNullOrEmpty ( backgroundImage ) )
1822+ {
1823+ FolderBackgroundImageSource = null ;
1824+ return ;
1825+ }
1826+ else
1827+ {
18141828 FolderBackgroundImageSource = new BitmapImage
18151829 {
18161830 UriSource = new Uri ( backgroundImage , UriKind . RelativeOrAbsolute ) ,
18171831 CreateOptions = BitmapCreateOptions . IgnoreImageCache
18181832 } ;
1819- else
1820- {
1821- FolderBackgroundImageSource = null ;
1822- return ;
18231833 }
18241834
18251835 // Opacity
1826- if ( keys . TryGetValue ( "Files_BackgroundOpacity" , out var backgroundOpacity ) && float . TryParse ( backgroundOpacity , out var opacity ) )
1836+ var backgroundOpacity = filesAppSection . Parameters . FirstOrDefault ( x => x . Key == "Files_BackgroundOpacity" ) . Value ;
1837+ if ( float . TryParse ( backgroundOpacity , out var opacity ) )
18271838 FolderBackgroundImageOpacity = opacity ;
18281839 else
18291840 FolderBackgroundImageOpacity = 1f ;
18301841
18311842 // Stretch
1832- if ( keys . TryGetValue ( "Files_BackgroundFit" , out var backgroundFit ) && Enum . TryParse < Stretch > ( backgroundFit , out var fit ) )
1843+ var backgroundFit = filesAppSection . Parameters . FirstOrDefault ( x => x . Key == "Files_BackgroundFit" ) . Value ;
1844+ if ( Enum . TryParse < Stretch > ( backgroundFit , out var fit ) )
18331845 FolderBackgroundImageFit = fit ;
18341846 else
18351847 FolderBackgroundImageFit = Stretch . UniformToFill ;
18361848
1837- // VerticalAlignment
1838- if ( keys . TryGetValue ( "Files_BackgroundVerticalAlignment" , out var verticalAlignment ) && Enum . TryParse < VerticalAlignment > ( verticalAlignment , out var vAlignment ) )
1849+ // Vertical alignment
1850+ var verticalAlignment = filesAppSection . Parameters . FirstOrDefault ( x => x . Key == "Files_BackgroundVerticalAlignment" ) . Value ;
1851+ if ( Enum . TryParse < VerticalAlignment > ( verticalAlignment , out var vAlignment ) )
18391852 FolderBackgroundImageVerticalAlignment = vAlignment ;
18401853 else
18411854 FolderBackgroundImageVerticalAlignment = VerticalAlignment . Center ;
18421855
1843- // HorizontalAlignment
1844- if ( keys . TryGetValue ( "Files_BackgroundHorizontalAlignment" , out var horizontalAlignment ) && Enum . TryParse < HorizontalAlignment > ( horizontalAlignment , out var hAlignment ) )
1856+ // Horizontal alignment
1857+ var horizontalAlignment = filesAppSection . Parameters . FirstOrDefault ( x => x . Key == "Files_BackgroundHorizontalAlignment" ) . Value ;
1858+ if ( Enum . TryParse < HorizontalAlignment > ( horizontalAlignment , out var hAlignment ) )
18451859 FolderBackgroundImageHorizontalAlignment = hAlignment ;
18461860 else
18471861 FolderBackgroundImageHorizontalAlignment = HorizontalAlignment . Center ;
0 commit comments