Skip to content

Commit 2e0707f

Browse files
author
Yair Aichenbaum
committed
Improved layout modes
1 parent c0408b8 commit 2e0707f

File tree

2 files changed

+53
-80
lines changed

2 files changed

+53
-80
lines changed

Files/View Models/SettingsViewModel.cs

Lines changed: 52 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ public class SettingsViewModel : ViewModelBase
3030

3131
public SettingsViewModel()
3232
{
33+
_roamingSettings = ApplicationData.Current.RoamingSettings;
34+
3335
DetectCustomLocations();
3436
DetectApplicationTheme();
37+
DetectOneDrivePreference();
3538
DetectDateTimeFormat();
3639
PinSidebarLocationItems();
37-
DrivesManager = new DrivesManager();
3840

39-
_roamingSettings = ApplicationData.Current.RoamingSettings;
41+
DrivesManager = new DrivesManager();
4042

4143
foundDrives = DrivesManager.Drives;
4244
//DetectWSLDistros();
@@ -370,31 +372,26 @@ public bool AreLinuxFilesSupported
370372
set => Set(ref _AreLinuxFilesSupported, value);
371373
}
372374

373-
private bool _ShowConfirmDeleteDialog = true;
374-
public bool ShowConfirmDeleteDialog
375+
private void DetectOneDrivePreference()
375376
{
376-
get => _ShowConfirmDeleteDialog;
377-
set
377+
if (localSettings.Values["PinOneDrive"] == null) { localSettings.Values["PinOneDrive"] = true; }
378+
379+
if ((bool)localSettings.Values["PinOneDrive"] == true)
378380
{
379-
if (localSettings.Values["ShowConfirmDeleteDialog"] == null)
380-
{
381-
localSettings.Values["ShowConfirmDeleteDialog"] = value;
382-
}
383-
else
384-
{
385-
if (value != _ShowConfirmDeleteDialog)
386-
{
387-
Set(ref _ShowConfirmDeleteDialog, value);
388-
if (value == true)
389-
{
390-
localSettings.Values["ShowConfirmDeleteDialog"] = true;
391-
}
392-
else
393-
{
394-
localSettings.Values["ShowConfirmDeleteDialog"] = false;
395-
}
396-
}
397-
}
381+
PinOneDriveToSideBar = true;
382+
}
383+
else
384+
{
385+
PinOneDriveToSideBar = false;
386+
}
387+
388+
try
389+
{
390+
StorageFolder.GetFolderFromPathAsync(OneDrivePath);
391+
}
392+
catch (Exception)
393+
{
394+
PinOneDriveToSideBar = false;
398395
}
399396
}
400397

@@ -513,82 +510,58 @@ public string VideosPath
513510
set => Set(ref _VideosPath, value);
514511
}
515512

516-
private bool _ShowRibbonContent = true;
517-
public bool ShowRibbonContent
513+
public bool AcrylicSidebar
518514
{
519-
get => _ShowRibbonContent;
520-
set
521-
{
522-
if (localSettings.Values["ShowRibbonContent"] == null)
523-
{
524-
localSettings.Values["ShowRibbonContent"] = value;
525-
}
526-
else
527-
{
528-
if (value != _ShowRibbonContent)
529-
{
530-
Set(ref _ShowRibbonContent, value);
531-
if (value == true)
532-
{
533-
localSettings.Values["ShowRibbonContent"] = true;
534-
}
535-
else
536-
{
537-
localSettings.Values["ShowRibbonContent"] = false;
538-
}
539-
}
540-
}
541-
}
515+
get => Get(false);
516+
set => Set(value);
542517
}
543-
public string ToggleLayoutModeIcon
518+
519+
public bool ShowFileExtensions
544520
{
545-
get => Get(""); // List View;
521+
get => Get(true);
522+
set => Set(value);
523+
}
524+
525+
public bool ShowConfirmDeleteDialog
526+
{
527+
get => Get(true);
546528
set => Set(value);
547529
}
530+
531+
public bool ShowRibbonContent
532+
{
533+
get => Get(true);
534+
set => Set(value);
535+
}
536+
548537
public Int32 LayoutMode
549538
{
550539
get => Get(0); // List View
551540
set => Set(value);
552541
}
553542

543+
public string ToggleLayoutModeIcon
544+
{
545+
get => Get(""); // List View;
546+
set => Set(value);
547+
}
548+
554549
private RelayCommand toggleLayoutMode;
555550
public RelayCommand ToggleLayoutMode => toggleLayoutMode = new RelayCommand(() =>
556551
{
557552
if (LayoutMode == 0) // List View
558553
{
559554
LayoutMode = 1; // Grid View
555+
556+
ToggleLayoutModeIcon = "";
560557
}
561-
else
558+
else //Grid View
562559
{
563560
LayoutMode = 0; // List View
564-
}
565-
566-
UpdateToggleLayouModeIcon();
567-
});
568561

569-
public void UpdateToggleLayouModeIcon()
570-
{
571-
if (LayoutMode == 0) // List View
572-
{
573-
ToggleLayoutModeIcon = ""; // List View;
574-
}
575-
else // List View
576-
{
577-
ToggleLayoutModeIcon = ""; // Grid View
562+
ToggleLayoutModeIcon = "";
578563
}
579-
}
580-
581-
public bool AcrylicSidebar
582-
{
583-
get => Get(false);
584-
set => Set(value);
585-
}
586-
587-
public bool ShowFileExtensions
588-
{
589-
get => Get(true);
590-
set => Set(value);
591-
}
564+
});
592565

593566
private TimeStyle _DisplayedTimeStyle = TimeStyle.Application;
594567
public TimeStyle DisplayedTimeStyle

Files/Views/SettingsPages/Preferences.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
Width="40"
8585
HorizontalAlignment="Right"
8686
IsEnabled="True"
87-
IsOn="{x:Bind local2:App.AppSettings.ShowConfirmDeleteDialog, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
87+
IsOn="{x:Bind local2:App.AppSettings.ShowConfirmDeleteDialog, Mode=TwoWay}"
8888
OffContent=""
8989
OnContent="" />
9090
</Grid>

0 commit comments

Comments
 (0)