Skip to content

Commit fc75bf3

Browse files
author
Yair Aichenbaum
committed
Added toggle layout mode command
1 parent ba967a8 commit fc75bf3

File tree

2 files changed

+67
-26
lines changed

2 files changed

+67
-26
lines changed

Files/UserControls/StatusBarControl.xaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="using:Files.UserControls"
7+
xmlns:local1="using:Files"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
d:DesignHeight="40"
910
d:DesignWidth="400"
@@ -32,18 +33,16 @@
3233
</Button.Content>
3334
</Button>
3435

35-
<ToggleButton
36+
<Button
3637
Width="34"
3738
Height="30"
3839
Margin="2,0,2,0"
3940
Background="Transparent"
41+
Command="{x:Bind local1:App.AppSettings.ToggleLayoutMode}"
42+
Content="{x:Bind local1:App.AppSettings.ToggleLayoutModeIcon, Mode=OneWay}"
4043
CornerRadius="2"
4144
FontFamily="Segoe MDL2 Assets"
42-
FontSize="16">
43-
<ToggleButton.Content>
44-
&#xF0E2;
45-
</ToggleButton.Content>
46-
</ToggleButton>
45+
FontSize="16" />
4746
</StackPanel>
4847

4948
</Grid>

Files/View Models/SettingsViewModel.cs

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Newtonsoft.Json;
1515
using Files.DataModels;
1616
using System.Diagnostics;
17+
using GalaSoft.MvvmLight.Command;
1718

1819
namespace Files.View_Models
1920
{
@@ -392,40 +393,23 @@ private async void LoadTerminalApps()
392393
Terminals = terminals;
393394
}
394395

395-
private FormFactorMode _FormFactor = FormFactorMode.Regular;
396-
private ThemeStyle _ThemeValue;
397-
private bool _AreLinuxFilesSupported = false;
398-
private bool _PinOneDriveToSideBar = true;
399-
private bool _ShowRibbonContent = true;
400-
private bool _ShowFileExtensions = true;
401-
private string _DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
402-
private string _DocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
403-
private string _DownloadsPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
404-
private string _OneDrivePath = Environment.GetEnvironmentVariable("OneDrive");
405-
private string _PicturesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
406-
private string _MusicPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
407-
private string _VideosPath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
408-
private string _TempPath = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Environment", "TEMP", null);
409-
private string _AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
410-
private string _HomePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
411-
private string _WinDirPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
412-
private bool _ShowConfirmDeleteDialog = true;
413396
private SidebarOpacity _SidebarThemeMode = SidebarOpacity.Opaque;
414-
private TimeStyle _DisplayedTimeStyle = TimeStyle.Application;
397+
415398
private IList<TerminalModel> _Terminals = null;
416-
417399
public IList<TerminalModel> Terminals
418400
{
419401
get => _Terminals;
420402
set => Set(ref _Terminals, value);
421403
}
422404

405+
private FormFactorMode _FormFactor = FormFactorMode.Regular;
423406
public FormFactorMode FormFactor
424407
{
425408
get => _FormFactor;
426409
set => Set(ref _FormFactor, value);
427410
}
428411

412+
private ThemeStyle _ThemeValue;
429413
public ThemeStyle ThemeValue
430414
{
431415
get => _ThemeValue;
@@ -447,12 +431,14 @@ public ThemeStyle ThemeValue
447431
}
448432
}
449433

434+
private bool _AreLinuxFilesSupported = false;
450435
public bool AreLinuxFilesSupported
451436
{
452437
get => _AreLinuxFilesSupported;
453438
set => Set(ref _AreLinuxFilesSupported, value);
454439
}
455440

441+
private bool _ShowFileExtensions = true;
456442
public bool ShowFileExtensions
457443
{
458444
get => _ShowFileExtensions;
@@ -480,6 +466,7 @@ public bool ShowFileExtensions
480466
}
481467
}
482468

469+
private bool _ShowConfirmDeleteDialog = true;
483470
public bool ShowConfirmDeleteDialog
484471
{
485472
get => _ShowConfirmDeleteDialog;
@@ -507,6 +494,7 @@ public bool ShowConfirmDeleteDialog
507494
}
508495
}
509496

497+
private bool _PinOneDriveToSideBar = true;
510498
public bool PinOneDriveToSideBar
511499
{
512500
get => _PinOneDriveToSideBar;
@@ -544,72 +532,84 @@ public bool PinOneDriveToSideBar
544532
}
545533
}
546534

535+
private string _TempPath = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Environment", "TEMP", null);
547536
public string TempPath
548537
{
549538
get => _TempPath;
550539
set => Set(ref _TempPath, value);
551540
}
552541

542+
private string _AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
553543
public string AppDataPath
554544
{
555545
get => _AppDataPath;
556546
set => Set(ref _AppDataPath, value);
557547
}
558548

549+
private string _HomePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
559550
public string HomePath
560551
{
561552
get => _HomePath;
562553
set => Set(ref _HomePath, value);
563554
}
564555

556+
private string _WinDirPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
565557
public string WinDirPath
566558
{
567559
get => _WinDirPath;
568560
set => Set(ref _WinDirPath, value);
569561
}
570562

563+
private string _DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
571564
public string DesktopPath
572565
{
573566
get => _DesktopPath;
574567
set => Set(ref _DesktopPath, value);
575568
}
576569

570+
private string _DocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
577571
public string DocumentsPath
578572
{
579573
get => _DocumentsPath;
580574
set => Set(ref _DocumentsPath, value);
581575
}
582576

577+
private string _DownloadsPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
583578
public string DownloadsPath
584579
{
585580
get => _DownloadsPath;
586581
set => Set(ref _DownloadsPath, value);
587582
}
588583

584+
private string _OneDrivePath = Environment.GetEnvironmentVariable("OneDrive");
589585
public string OneDrivePath
590586
{
591587
get => _OneDrivePath;
592588
set => Set(ref _OneDrivePath, value);
593589
}
594590

591+
private string _PicturesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
595592
public string PicturesPath
596593
{
597594
get => _PicturesPath;
598595
set => Set(ref _PicturesPath, value);
599596
}
600597

598+
private string _MusicPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
601599
public string MusicPath
602600
{
603601
get => _MusicPath;
604602
set => Set(ref _MusicPath, value);
605603
}
606604

605+
private string _VideosPath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
607606
public string VideosPath
608607
{
609608
get => _VideosPath;
610609
set => Set(ref _VideosPath, value);
611610
}
612611

612+
private bool _ShowRibbonContent = true;
613613
public bool ShowRibbonContent
614614
{
615615
get => _ShowRibbonContent;
@@ -637,6 +637,47 @@ public bool ShowRibbonContent
637637
}
638638
}
639639

640+
private string _ToggleLayoutModeIcon = ""; // Grid View
641+
public string ToggleLayoutModeIcon
642+
{
643+
get => _ToggleLayoutModeIcon;
644+
set => Set(ref _ToggleLayoutModeIcon, value);
645+
}
646+
647+
private Int16 _LayoutMode = 0; // Grid View
648+
public Int16 LayoutMode
649+
{
650+
get => _LayoutMode;
651+
set => Set(ref _LayoutMode, value);
652+
}
653+
654+
private RelayCommand toggleLayoutMode;
655+
public RelayCommand ToggleLayoutMode => toggleLayoutMode = new RelayCommand(() =>
656+
{
657+
if (LayoutMode == 0) // Grid View
658+
{
659+
LayoutMode = 1; // List View
660+
}
661+
else
662+
{
663+
LayoutMode = 0; // Grid View
664+
}
665+
666+
UpdateToggleLayouModeIcon();
667+
});
668+
669+
public void UpdateToggleLayouModeIcon()
670+
{
671+
if (LayoutMode == 0) // Grid View
672+
{
673+
ToggleLayoutModeIcon = ""; // Grid View;
674+
}
675+
else // List View
676+
{
677+
ToggleLayoutModeIcon = ""; // List View
678+
}
679+
}
680+
640681
public SidebarOpacity SidebarThemeMode
641682
{
642683
get => _SidebarThemeMode;
@@ -654,6 +695,7 @@ public SidebarOpacity SidebarThemeMode
654695
}
655696
}
656697

698+
private TimeStyle _DisplayedTimeStyle = TimeStyle.Application;
657699
public TimeStyle DisplayedTimeStyle
658700
{
659701
get => _DisplayedTimeStyle;

0 commit comments

Comments
 (0)