30
30
using Windows . Storage . Streams ;
31
31
using Windows . System ;
32
32
using Microsoft . UI . Xaml . Controls ;
33
+ using Files . View_Models ;
33
34
34
35
namespace Files
35
36
{
36
37
sealed partial class App : Application
37
38
{
38
- public static bool areLinuxFilesSupported { get ; set ; } = false ;
39
- public static string DesktopPath = Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) ;
40
- public static string DocumentsPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) ;
41
- public static string DownloadsPath = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) + @"\Downloads" ;
42
- public static string OneDrivePath = Environment . GetEnvironmentVariable ( "OneDrive" ) ;
43
- public static string PicturesPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures ) ;
44
- public static string MusicPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyMusic ) ;
45
- public static string VideosPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyVideos ) ;
39
+
46
40
private static ProHome occupiedInstance ;
47
41
public static ProHome OccupiedInstance
48
42
{
@@ -66,8 +60,7 @@ public static ProHome OccupiedInstance
66
60
private DeviceWatcher watcher ;
67
61
public static ObservableCollection < SidebarItem > sideBarItems = new ObservableCollection < SidebarItem > ( ) ;
68
62
public static ObservableCollection < WSLDistroItem > linuxDistroItems = new ObservableCollection < WSLDistroItem > ( ) ;
69
- public static FormFactorMode FormFactor { get ; set ; } = FormFactorMode . Regular ;
70
- ApplicationDataContainer localSettings ;
63
+ public static SettingsViewModel AppSettings = new SettingsViewModel ( ) ;
71
64
72
65
public App ( )
73
66
{
@@ -82,12 +75,11 @@ public App()
82
75
Clipboard . ContentChanged += Clipboard_ContentChanged ;
83
76
Clipboard_ContentChanged ( null , null ) ;
84
77
AppCenter . Start ( "682666d1-51d3-4e4a-93d0-d028d43baaa0" , typeof ( Analytics ) , typeof ( Crashes ) ) ;
85
- localSettings = ApplicationData . Current . LocalSettings ;
78
+
86
79
SetPropertiesFromLocalSettings ( ) ;
87
- DetectCustomLocations ( ) ;
80
+
88
81
PopulatePinnedSidebarItems ( ) ;
89
82
DetectWSLDistros ( ) ;
90
- QuickLookIntegration ( ) ;
91
83
}
92
84
93
85
public void CloseOpenPopups ( )
@@ -226,7 +218,7 @@ private async void DetectWSLDistros()
226
218
var distroFolder = await StorageFolder . GetFolderFromPathAsync ( @"\\wsl$\" ) ;
227
219
if ( ( await distroFolder . GetFoldersAsync ( ) ) . Count > 0 )
228
220
{
229
- areLinuxFilesSupported = false ;
221
+ AppSettings . AreLinuxFilesSupported = false ;
230
222
}
231
223
232
224
foreach ( StorageFolder folder in await distroFolder . GetFoldersAsync ( ) )
@@ -264,86 +256,21 @@ private async void DetectWSLDistros()
264
256
catch ( Exception )
265
257
{
266
258
// WSL Not Supported/Enabled
267
- areLinuxFilesSupported = false ;
259
+ AppSettings . AreLinuxFilesSupported = false ;
268
260
}
269
261
}
270
262
271
- private async void QuickLookIntegration ( )
272
- {
273
- localSettings . Values [ "Arguments" ] = "CheckQuickLookAvailability" ;
274
- await FullTrustProcessLauncher . LaunchFullTrustProcessForCurrentAppAsync ( ) ;
275
- }
276
-
277
263
private void SetPropertiesFromLocalSettings ( )
278
264
{
279
- if ( localSettings . Values [ "theme" ] == null )
280
- {
281
- localSettings . Values [ "theme" ] = "Default" ;
282
- }
283
265
284
- if ( localSettings . Values [ "datetimeformat" ] == null )
285
- {
286
- localSettings . Values [ "datetimeformat" ] = "Application" ;
287
- }
288
266
289
- if ( localSettings . Values [ "theme" ] != null )
290
- {
291
- if ( localSettings . Values [ "theme" ] . ToString ( ) == "Light" )
292
- {
293
- SettingsPages . Personalization . TV . ThemeValue = ApplicationTheme . Light ;
294
- }
295
- else if ( localSettings . Values [ "theme" ] . ToString ( ) == "Dark" )
296
- {
297
- SettingsPages . Personalization . TV . ThemeValue = ApplicationTheme . Dark ;
298
- }
299
- else
300
- {
301
- var uiSettings = new Windows . UI . ViewManagement . UISettings ( ) ;
302
- var color = uiSettings . GetColorValue ( Windows . UI . ViewManagement . UIColorType . Background ) ;
303
- if ( color == Colors . White )
304
- {
305
- SettingsPages . Personalization . TV . ThemeValue = ApplicationTheme . Light ;
306
- }
307
- else
308
- {
309
- SettingsPages . Personalization . TV . ThemeValue = ApplicationTheme . Dark ;
310
- }
311
- }
312
- }
313
267
314
- this . RequestedTheme = SettingsPages . Personalization . TV . ThemeValue ;
315
- }
268
+
316
269
317
- private async void DetectCustomLocations ( )
318
- {
319
- // Detect custom locations set from Windows
320
- localSettings . Values [ "Arguments" ] = "DetectUserPaths" ;
321
- await FullTrustProcessLauncher . LaunchFullTrustProcessForCurrentAppAsync ( "UserFolderPathsGroup" ) ;
322
-
323
- App . DesktopPath = localSettings . Values [ "DetectedDesktopLocation" ] as string ;
324
- App . DownloadsPath = localSettings . Values [ "DetectedDownloadsLocation" ] as string ;
325
- App . DocumentsPath = localSettings . Values [ "DetectedDocumentsLocation" ] as string ;
326
- App . PicturesPath = localSettings . Values [ "DetectedPicturesLocation" ] as string ;
327
- App . MusicPath = localSettings . Values [ "DetectedMusicLocation" ] as string ;
328
- App . VideosPath = localSettings . Values [ "DetectedVideosLocation" ] as string ;
329
- App . OneDrivePath = localSettings . Values [ "DetectedOneDriveLocation" ] as string ;
330
-
331
- // Overwrite paths for common locations if Custom Locations setting is enabled
332
- if ( localSettings . Values [ "customLocationsSetting" ] != null )
333
- {
334
- if ( localSettings . Values [ "customLocationsSetting" ] . Equals ( true ) )
335
- {
336
- App . DesktopPath = localSettings . Values [ "DesktopLocation" ] as string ;
337
- App . DownloadsPath = localSettings . Values [ "DownloadsLocation" ] as string ;
338
- App . DocumentsPath = localSettings . Values [ "DocumentsLocation" ] as string ;
339
- App . PicturesPath = localSettings . Values [ "PicturesLocation" ] as string ;
340
- App . MusicPath = localSettings . Values [ "MusicLocation" ] as string ;
341
- App . VideosPath = localSettings . Values [ "VideosLocation" ] as string ;
342
- App . OneDrivePath = localSettings . Values [ "DetectedOneDriveLocation" ] as string ;
343
- }
344
- }
345
270
}
346
271
272
+
273
+
347
274
public void PopulateDrivesListWithLocalDisks ( )
348
275
{
349
276
var driveLetters = DriveInfo . GetDrives ( ) . Select ( x => x . RootDirectory . Root ) . ToList ( ) . OrderBy ( x => x . Root . FullName ) . ToList ( ) ;
@@ -616,12 +543,12 @@ public async void PopulatePinnedSidebarItems()
616
543
private void AddDefaultLocations ( )
617
544
{
618
545
sideBarItems . Add ( new SidebarItem ( ) { Text = "Home" , IconGlyph = "\uE737 " , isDefaultLocation = true , Path = "Home" } ) ;
619
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Desktop" , IconGlyph = "\uE8FC " , isDefaultLocation = true , Path = DesktopPath } ) ;
620
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Downloads" , IconGlyph = "\uE896 " , isDefaultLocation = true , Path = DownloadsPath } ) ;
621
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Documents" , IconGlyph = "\uE8A5 " , isDefaultLocation = true , Path = DocumentsPath } ) ;
622
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Pictures" , IconGlyph = "\uEB9F " , isDefaultLocation = true , Path = PicturesPath } ) ;
623
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Music" , IconGlyph = "\uEC4F " , isDefaultLocation = true , Path = MusicPath } ) ;
624
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Videos" , IconGlyph = "\uE8B2 " , isDefaultLocation = true , Path = VideosPath } ) ;
546
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Desktop" , IconGlyph = "\uE8FC " , isDefaultLocation = true , Path = AppSettings . DesktopPath } ) ;
547
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Downloads" , IconGlyph = "\uE896 " , isDefaultLocation = true , Path = AppSettings . DownloadsPath } ) ;
548
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Documents" , IconGlyph = "\uE8A5 " , isDefaultLocation = true , Path = AppSettings . DocumentsPath } ) ;
549
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Pictures" , IconGlyph = "\uEB9F " , isDefaultLocation = true , Path = AppSettings . PicturesPath } ) ;
550
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Music" , IconGlyph = "\uEC4F " , isDefaultLocation = true , Path = AppSettings . MusicPath } ) ;
551
+ sideBarItems . Add ( new SidebarItem ( ) { Text = "Videos" , IconGlyph = "\uE8B2 " , isDefaultLocation = true , Path = AppSettings . VideosPath } ) ;
625
552
}
626
553
627
554
public static async void RemoveStaleSidebarItems ( )
0 commit comments