Skip to content

Commit 7a90114

Browse files
committed
Implement SettingsViewModel
2 parents a1eb4f8 + 620e7df commit 7a90114

20 files changed

+807
-656
lines changed

Files.Launcher/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ static void Main(string[] args)
1515
var arguments = (string)localSettings.Values["Arguments"];
1616
if (!string.IsNullOrWhiteSpace(arguments))
1717
{
18-
if (arguments.Equals("DetectUserPaths"))
18+
if (arguments.Equals("StartupTasks"))
1919
{
20+
// Detect User Paths
2021
ApplicationData.Current.LocalSettings.Values["DetectedDesktopLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", null);
2122
ApplicationData.Current.LocalSettings.Values["DetectedDownloadsLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", null);
2223
ApplicationData.Current.LocalSettings.Values["DetectedDocumentsLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal", null);
2324
ApplicationData.Current.LocalSettings.Values["DetectedPicturesLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Pictures", null);
2425
ApplicationData.Current.LocalSettings.Values["DetectedMusicLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Music", null);
2526
ApplicationData.Current.LocalSettings.Values["DetectedVideosLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Video", null);
2627
ApplicationData.Current.LocalSettings.Values["DetectedOneDriveLocation"] = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\OneDrive", "UserFolder", null);
27-
}
28-
else if (arguments.Equals("CheckQuickLookAvailability"))
29-
{
28+
29+
// Check QuickLook Availability
3030
QuickLook.CheckQuickLookAvailability(localSettings);
3131
}
3232
else if (arguments.Equals("ToggleQuickLook"))

Files/App.xaml.cs

Lines changed: 36 additions & 418 deletions
Large diffs are not rendered by default.

Files/BaseLayout.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
8888
// Add item jumping handler
8989
Window.Current.CoreWindow.CharacterReceived += Page_CharacterReceived;
9090
var parameters = (string)eventArgs.Parameter;
91-
if (App.FormFactor == Enums.FormFactorMode.Regular)
91+
if (App.AppSettings.FormFactor == Enums.FormFactorMode.Regular)
9292
{
9393
Frame rootFrame = Window.Current.Content as Frame;
9494
InstanceTabsView instanceTabsView = rootFrame.Content as InstanceTabsView;
@@ -111,31 +111,31 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
111111
App.OccupiedInstance.instanceViewModel.AddItemsToCollectionAsync(App.OccupiedInstance.instanceViewModel.Universal.path);
112112
App.Clipboard_ContentChanged(null, null);
113113

114-
if (parameters.Equals(App.DesktopPath))
114+
if (parameters.Equals(App.AppSettings.DesktopPath))
115115
{
116116
App.OccupiedInstance.PathText.Text = "Desktop";
117117
}
118-
else if (parameters.Equals(App.DocumentsPath))
118+
else if (parameters.Equals(App.AppSettings.DocumentsPath))
119119
{
120120
App.OccupiedInstance.PathText.Text = "Documents";
121121
}
122-
else if (parameters.Equals(App.DownloadsPath))
122+
else if (parameters.Equals(App.AppSettings.DownloadsPath))
123123
{
124124
App.OccupiedInstance.PathText.Text = "Downloads";
125125
}
126-
else if (parameters.Equals(App.PicturesPath))
126+
else if (parameters.Equals(App.AppSettings.PicturesPath))
127127
{
128128
App.OccupiedInstance.PathText.Text = "Pictures";
129129
}
130-
else if (parameters.Equals(App.MusicPath))
130+
else if (parameters.Equals(App.AppSettings.MusicPath))
131131
{
132132
App.OccupiedInstance.PathText.Text = "Music";
133133
}
134-
else if (parameters.Equals(App.OneDrivePath))
134+
else if (parameters.Equals(App.AppSettings.OneDrivePath))
135135
{
136136
App.OccupiedInstance.PathText.Text = "OneDrive";
137137
}
138-
else if (parameters.Equals(App.VideosPath))
138+
else if (parameters.Equals(App.AppSettings.VideosPath))
139139
{
140140
App.OccupiedInstance.PathText.Text = "Videos";
141141
}

Files/Controls/RibbonArea.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,43 +114,43 @@ public async void CheckPathInput(ItemViewModel instance, string CurrentInput)
114114
}
115115
else if (CurrentInput.Equals("Desktop", StringComparison.OrdinalIgnoreCase))
116116
{
117-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.DesktopPath);
117+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.DesktopPath);
118118
parentPage.PathText.Text = "Desktop";
119119
parentPage.LayoutItems.isEnabled = true;
120120
}
121121
else if (CurrentInput.Equals("Documents", StringComparison.OrdinalIgnoreCase))
122122
{
123-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.DocumentsPath);
123+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.DocumentsPath);
124124
parentPage.PathText.Text = "Documents";
125125
parentPage.LayoutItems.isEnabled = true;
126126
}
127127
else if (CurrentInput.Equals("Downloads", StringComparison.OrdinalIgnoreCase))
128128
{
129-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.DownloadsPath);
129+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.DownloadsPath);
130130
parentPage.PathText.Text = "Downloads";
131131
parentPage.LayoutItems.isEnabled = true;
132132
}
133133
else if (CurrentInput.Equals("Pictures", StringComparison.OrdinalIgnoreCase))
134134
{
135-
parentPage.ItemDisplayFrame.Navigate(typeof(PhotoAlbum), App.PicturesPath);
135+
parentPage.ItemDisplayFrame.Navigate(typeof(PhotoAlbum), App.AppSettings.PicturesPath);
136136
parentPage.PathText.Text = "Pictures";
137137
parentPage.LayoutItems.isEnabled = true;
138138
}
139139
else if (CurrentInput.Equals("Music", StringComparison.OrdinalIgnoreCase))
140140
{
141-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.MusicPath);
141+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.MusicPath);
142142
parentPage.PathText.Text = "Music";
143143
parentPage.LayoutItems.isEnabled = true;
144144
}
145145
else if (CurrentInput.Equals("Videos", StringComparison.OrdinalIgnoreCase))
146146
{
147-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.VideosPath);
147+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.VideosPath);
148148
parentPage.PathText.Text = "Videos";
149149
parentPage.LayoutItems.isEnabled = true;
150150
}
151151
else if (CurrentInput.Equals("OneDrive", StringComparison.OrdinalIgnoreCase))
152152
{
153-
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.OneDrivePath);
153+
parentPage.ItemDisplayFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.OneDrivePath);
154154
parentPage.PathText.Text = "OneDrive";
155155
parentPage.LayoutItems.isEnabled = true;
156156
}

Files/Enums/SidebarOpacity.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Files.Enums
8+
{
9+
public enum SidebarOpacity
10+
{
11+
Opaque = 0,
12+
AcrylicEnabled = 1
13+
}
14+
}

Files/Files.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@
173173
<DependentUpon>RenameDialog.xaml</DependentUpon>
174174
</Compile>
175175
<Compile Include="Enums\FormFactorMode.cs" />
176+
<Compile Include="Enums\SidebarOpacity.cs" />
176177
<Compile Include="Enums\SortOption.cs" />
177178
<Compile Include="Enums\ThemeStyle.cs" />
178179
<Compile Include="Enums\TimeStyle.cs" />
179180
<Compile Include="Filesystem\DriveItem.cs" />
181+
<Compile Include="Filesystem\Drives.cs" />
180182
<Compile Include="Filesystem\ItemViewModel.cs" />
181183
<Compile Include="Filesystem\ListedItem.cs" />
182184
<Compile Include="Filesystem\SidebarItem.cs" />
@@ -211,6 +213,7 @@
211213
<Compile Include="Search.xaml.cs">
212214
<DependentUpon>Search.xaml</DependentUpon>
213215
</Compile>
216+
<Compile Include="Settings.cs" />
214217
<Compile Include="Settings.xaml.cs">
215218
<DependentUpon>Settings.xaml</DependentUpon>
216219
</Compile>
@@ -227,6 +230,7 @@
227230
<DependentUpon>StartPageWidgets.xaml</DependentUpon>
228231
</Compile>
229232
<Compile Include="View Models\RibbonViewModel.cs" />
233+
<Compile Include="View Models\SettingsViewModel.cs" />
230234
<Compile Include="WindowDisplayInfo.cs" />
231235
<Compile Include="WindowDisplayMode.cs" />
232236
<Compile Include="YourHome.xaml.cs">

Files/Filesystem/DriveItem.cs

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
7+
using Windows.Storage;
68
using Windows.UI.Xaml;
79
using Windows.UI.Xaml.Media.Imaging;
810

@@ -11,14 +13,96 @@ namespace Files.Filesystem
1113
public class DriveItem
1214
{
1315
public string glyph { get; set; }
14-
public ulong maxSpace { get; set; }
15-
public ulong spaceUsed { get; set; }
16+
public ulong maxSpace { get; set; } = 0;
17+
public ulong spaceUsed { get; set; } = 0;
1618
public string driveText { get; set; }
1719
public string tag { get; set; }
1820
public Visibility progressBarVisibility { get; set; }
1921
public string spaceText { get; set; }
2022
public Visibility cloudGlyphVisibility { get; set; } = Visibility.Collapsed;
2123
public Visibility driveGlyphVisibility { get; set; } = Visibility.Visible;
24+
public DriveType Type { get; set; }
2225

26+
private StorageFolder _root;
27+
28+
public DriveItem()
29+
{
30+
31+
}
32+
33+
public DriveItem(StorageFolder root, Visibility progressBarVisibility, DriveType type)
34+
{
35+
_root = root;
36+
this.progressBarVisibility = progressBarVisibility;
37+
Type = type;
38+
39+
var properties = Task.Run(async () =>
40+
{
41+
return await root.Properties.RetrievePropertiesAsync(new[] {"System.FreeSpace", "System.Capacity"});
42+
}).Result;
43+
44+
45+
46+
try
47+
{
48+
spaceUsed = maxSpace -
49+
Convert.ToUInt64(ByteSizeLib.ByteSize.FromBytes((ulong)properties["System.FreeSpace"]).GigaBytes);
50+
maxSpace = Convert.ToUInt64(ByteSizeLib.ByteSize.FromBytes((ulong)properties["System.Capacity"]).GigaBytes);
51+
spaceText = String.Format("{0} of {1}",
52+
ByteSizeLib.ByteSize.FromBytes((ulong)properties["System.FreeSpace"]).ToString(),
53+
ByteSizeLib.ByteSize.FromBytes((ulong)properties["System.Capacity"]).ToString());
54+
}
55+
catch(NullReferenceException e)
56+
{
57+
spaceText = "Unkown";
58+
}
59+
60+
driveText = root.DisplayName;
61+
62+
tag = root.Path;
63+
64+
switch (type)
65+
{
66+
case DriveType.Fixed:
67+
glyph = "\uEDA2";
68+
break;
69+
case DriveType.Removable:
70+
glyph = "\uE88E";
71+
break;
72+
case DriveType.Network:
73+
break;
74+
case DriveType.Ram:
75+
break;
76+
case DriveType.CDRom:
77+
glyph = "\uE958";
78+
break;
79+
case DriveType.Unkown:
80+
break;
81+
case DriveType.NoRootDirectory:
82+
break;
83+
case DriveType.VirtualDrive:
84+
break;
85+
case DriveType.FloppyDisk:
86+
glyph = "\uEDA2";
87+
break;
88+
default:
89+
throw new ArgumentOutOfRangeException(nameof(type), type, null);
90+
}
91+
}
92+
93+
94+
}
95+
96+
public enum DriveType
97+
{
98+
Fixed,
99+
Removable,
100+
Network,
101+
Ram,
102+
CDRom,
103+
FloppyDisk,
104+
Unkown,
105+
NoRootDirectory,
106+
VirtualDrive
23107
}
24108
}

0 commit comments

Comments
 (0)