Skip to content

Commit a0fbab3

Browse files
authored
Merge pull request #241 from duke7553/custom-start
Several Tweaks
2 parents 9d20d96 + 9f015aa commit a0fbab3

15 files changed

+728
-202
lines changed

Files UWP/App.xaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@
88
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
99
<ResourceDictionary>
1010
<ResourceDictionary.ThemeDictionaries>
11-
<ResourceDictionary x:Key="Default">
12-
<AcrylicBrush x:Key="NavigationViewDefaultPaneBackground" BackgroundSource="Backdrop" FallbackColor="#eaeaea" TintColor="LightSlateGray" TintOpacity="0.6"/>
13-
<SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="White"/>
14-
<AcrylicBrush x:Key="NavigationViewExpandedPaneBackground" BackgroundSource="HostBackdrop" TintOpacity="0.6" TintColor="White" FallbackColor="#eaeaea"/>
15-
<SolidColorBrush x:Key="UnmodifiedSystemPageColor" Color="White"/>
16-
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="#f3f1ef"/>
17-
<SolidColorBrush x:Key="YourHomeCardBorderColor" Color="#f3f1ef"/>
18-
</ResourceDictionary>
1911
<ResourceDictionary x:Key="Light">
2012
<AcrylicBrush x:Key="NavigationViewDefaultPaneBackground" FallbackColor="#eaeaea" BackgroundSource="Backdrop" TintColor="LightSlateGray" TintOpacity="0.6"/>
2113
<SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="White"/>
2214
<AcrylicBrush x:Key="NavigationViewExpandedPaneBackground" BackgroundSource="HostBackdrop" TintOpacity="0.6" TintColor="White" FallbackColor="#eaeaea"/>
2315
<SolidColorBrush x:Key="UnmodifiedSystemPageColor" Color="White"/>
2416
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="#f3f1ef"/>
2517
<SolidColorBrush x:Key="YourHomeCardBorderColor" Color="#f3f1ef"/>
18+
<SolidColorBrush x:Key="CustomInputFieldBorderBrush" Color="DarkGray"/>
2619
</ResourceDictionary>
2720
<ResourceDictionary x:Key="Dark">
2821
<AcrylicBrush x:Key="NavigationViewDefaultPaneBackground" BackgroundSource="Backdrop" TintColor="Black" TintOpacity="0.6"/>
@@ -32,6 +25,11 @@
3225
<SolidColorBrush x:Key="UnmodifiedSystemPageColor" Color="Black"/>
3326
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="Black"/>
3427
<SolidColorBrush x:Key="YourHomeCardBorderColor" Color="White"/>
28+
<SolidColorBrush x:Key="TabViewBackground" Color="Black"/>
29+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="#191919"/>
30+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="#191919" />
31+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="#191919"/>
32+
<SolidColorBrush x:Key="CustomInputFieldBorderBrush" Color="#FF363636"/>
3533
</ResourceDictionary>
3634
<ResourceDictionary x:Key="HighContrast">
3735
<!-- This empty dictionary ensures that the default high contrast resources are used when the user turns on high contrast mode. -->

Files UWP/App.xaml.cs

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
using Microsoft.AppCenter.Analytics;
1818
using Microsoft.AppCenter.Crashes;
1919
using Windows.UI.Xaml.Media;
20+
using Files.Filesystem;
21+
using System.IO;
22+
using System.Linq;
23+
using System.Collections.ObjectModel;
24+
using Windows.Devices.Enumeration;
25+
using System.Text.RegularExpressions;
2026

2127
namespace Files
2228
{
@@ -76,6 +82,120 @@ public App()
7682

7783
this.RequestedTheme = SettingsPages.Personalization.TV.ThemeValue;
7884
//Debug.WriteLine("!!Requested Theme!!" + RequestedTheme.ToString());
85+
86+
if (localSettings.Values["FavoritesDisplayed_Start"] == null)
87+
{
88+
localSettings.Values["FavoritesDisplayed_Start"] = true;
89+
}
90+
91+
if (localSettings.Values["RecentsDisplayed_Start"] == null)
92+
{
93+
localSettings.Values["RecentsDisplayed_Start"] = true;
94+
}
95+
96+
if (localSettings.Values["DrivesDisplayed_Start"] == null)
97+
{
98+
localSettings.Values["DrivesDisplayed_Start"] = false;
99+
}
100+
101+
if (localSettings.Values["FavoritesDisplayed_NewTab"] == null)
102+
{
103+
localSettings.Values["FavoritesDisplayed_NewTab"] = true;
104+
}
105+
106+
if (localSettings.Values["RecentsDisplayed_NewTab"] == null)
107+
{
108+
localSettings.Values["RecentsDisplayed_NewTab"] = true;
109+
}
110+
111+
if (localSettings.Values["DrivesDisplayed_NewTab"] == null)
112+
{
113+
localSettings.Values["DrivesDisplayed_NewTab"] = false;
114+
}
115+
116+
FindDrives();
117+
//DeviceWatcher watcher = DeviceInformation.CreateWatcher();
118+
//watcher.Added += (sender, info) => FindDrives();
119+
//watcher.Removed += (sender, info) => FindDrives();
120+
//watcher.Start();
121+
}
122+
123+
private async void FindDrives()
124+
{
125+
foundDrives.Clear();
126+
var knownRemDevices = new ObservableCollection<string>();
127+
foreach (var f in await KnownFolders.RemovableDevices.GetFoldersAsync())
128+
{
129+
var path = f.Path;
130+
knownRemDevices.Add(path);
131+
}
132+
133+
var driveLetters = DriveInfo.GetDrives().Select(x => x.RootDirectory.Root).ToList().OrderBy(x => x.Root.FullName).ToList();
134+
135+
if (!driveLetters.Any()) return;
136+
137+
driveLetters.ForEach(async roots =>
138+
{
139+
try
140+
{
141+
//if (roots.Name == @"C:\") return;
142+
var content = string.Empty;
143+
string icon;
144+
if (knownRemDevices.Contains(roots.Name))
145+
{
146+
content = $"Removable Drive ({roots.Name})";
147+
icon = "\uE88E";
148+
}
149+
else
150+
{
151+
content = $"Local Disk ({roots.Name})";
152+
icon = "\uEDA2";
153+
}
154+
StorageFolder drive = await StorageFolder.GetFolderFromPathAsync(roots.Name);
155+
var retrivedProperties = await drive.Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace", "System.Capacity" });
156+
157+
ulong totalSpaceProg = 0;
158+
ulong freeSpaceProg = 0;
159+
string free_space_text = "Unknown";
160+
string total_space_text = "Unknown";
161+
Visibility capacityBarVis = Visibility.Visible;
162+
try
163+
{
164+
var sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).GigaBytes;
165+
freeSpaceProg = Convert.ToUInt64(sizeAsGBString);
166+
167+
sizeAsGBString = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).GigaBytes;
168+
totalSpaceProg = Convert.ToUInt64(sizeAsGBString);
169+
170+
171+
free_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.FreeSpace"]).ToString();
172+
total_space_text = ByteSizeLib.ByteSize.FromBytes((ulong)retrivedProperties["System.Capacity"]).ToString();
173+
}
174+
catch (UnauthorizedAccessException)
175+
{
176+
capacityBarVis = Visibility.Collapsed;
177+
}
178+
catch (NullReferenceException)
179+
{
180+
capacityBarVis = Visibility.Collapsed;
181+
}
182+
183+
foundDrives.Add(new DriveItem()
184+
{
185+
driveText = content,
186+
glyph = icon,
187+
maxSpace = totalSpaceProg,
188+
spaceUsed = totalSpaceProg - freeSpaceProg,
189+
tag = roots.Name,
190+
progressBarVisibility = capacityBarVis,
191+
spaceText = free_space_text + " free of " + total_space_text,
192+
});
193+
}
194+
catch (UnauthorizedAccessException e)
195+
{
196+
Debug.WriteLine(e.Message);
197+
}
198+
});
79199
}
80200

81201
public static Windows.UI.Xaml.UnhandledExceptionEventArgs exceptionInfo { get; set; }
@@ -96,7 +216,7 @@ private async void App_UnhandledException(object sender, Windows.UI.Xaml.Unhandl
96216

97217
public static PasteState PS { get; set; } = new PasteState();
98218
public static List<string> pathsToDeleteAfterPaste = new List<string>();
99-
219+
public static ObservableCollection<DriveItem> foundDrives = new ObservableCollection<DriveItem>();
100220

101221
/// <summary>
102222
/// Invoked when the application is launched normally by the end user. Other entry points

Files UWP/FilesUWP.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
</Compile>
143143
<Compile Include="Enums\ThemeStyle.cs" />
144144
<Compile Include="Enums\TimeStyle.cs" />
145+
<Compile Include="Filesystem\DriveItem.cs" />
145146
<Compile Include="Filesystem\ItemViewModel.cs" />
146147
<Compile Include="Filesystem\ListedItem.cs" />
147148
<Compile Include="GenericFileBrowser.xaml.cs">
@@ -185,6 +186,9 @@
185186
<Compile Include="SettingsPages\Preferences.xaml.cs">
186187
<DependentUpon>Preferences.xaml</DependentUpon>
187188
</Compile>
189+
<Compile Include="SettingsPages\StartPageWidgets.xaml.cs">
190+
<DependentUpon>StartPageWidgets.xaml</DependentUpon>
191+
</Compile>
188192
<Compile Include="UnhandledExceptionDisplay.xaml.cs">
189193
<DependentUpon>UnhandledExceptionDisplay.xaml</DependentUpon>
190194
</Compile>
@@ -272,6 +276,10 @@
272276
<SubType>Designer</SubType>
273277
<Generator>MSBuild:Compile</Generator>
274278
</Page>
279+
<Page Include="SettingsPages\StartPageWidgets.xaml">
280+
<SubType>Designer</SubType>
281+
<Generator>MSBuild:Compile</Generator>
282+
</Page>
275283
<Page Include="UnhandledExceptionDisplay.xaml">
276284
<SubType>Designer</SubType>
277285
<Generator>MSBuild:Compile</Generator>
@@ -313,7 +321,7 @@
313321
<Version>5.1.0</Version>
314322
</PackageReference>
315323
<PackageReference Include="Microsoft.UI.Xaml">
316-
<Version>2.2.190830001</Version>
324+
<Version>2.2.190917002</Version>
317325
</PackageReference>
318326
</ItemGroup>
319327
<ItemGroup>

Files UWP/Filesystem/DriveItem.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml;
7+
8+
namespace Files.Filesystem
9+
{
10+
public class DriveItem
11+
{
12+
public string glyph { get; set; }
13+
public ulong maxSpace { get; set; }
14+
public ulong spaceUsed { get; set; }
15+
public string driveText { get; set; }
16+
public string tag { get; set; }
17+
public Visibility progressBarVisibility { get; set; }
18+
public string spaceText { get; set; }
19+
}
20+
}

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
<controls:DataGrid.Resources>
181181
<SolidColorBrush x:Key="DataGridCellFocusVisualPrimaryBrush" Color="Transparent"/>
182182
<SolidColorBrush x:Key="DataGridCellFocusVisualSecondaryBrush" Color="Transparent"/>
183+
<StaticResource x:Key="DataGridColumnHeaderBackgroundColor" ResourceKey="ApplicationPageBackgroundThemeBrush"/>
183184
</controls:DataGrid.Resources>
184185
<controls:DataGrid.ColumnHeaderStyle>
185186
<Style TargetType="controlsprimitives:DataGridColumnHeader">

Files UWP/InstanceTabsView.xaml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<KeyboardAccelerator Modifiers="Control" Key="T"/>
102102
</Button.KeyboardAccelerators>
103103
</Button>
104-
104+
105105
<Grid Background="Transparent" Name="DragArea" Loaded="DragArea_Loaded" Grid.Column="3"/>
106106

107107
</Grid>
@@ -113,7 +113,7 @@
113113
</Style>
114114
</Page.Resources>
115115

116-
<Grid Background="{StaticResource SystemControlAcrylicWindowBrush}" Name="rootGrid" >
116+
<Grid Background="Transparent" Name="rootGrid" >
117117
<Grid.RowDefinitions>
118118
<RowDefinition Height="Auto"/>
119119
<RowDefinition Height="*"/>
@@ -124,34 +124,9 @@
124124
</Grid.ColumnDefinitions>
125125
<ContentPresenter Background="{StaticResource ApplicationPageBackgroundThemeBrush}" x:Name="ContentPresenter" Grid.Row="1" Grid.ColumnSpan="2" Content="{x:Bind ((uilib:TabViewItem)(local:InstanceTabsView).TabStrip.SelectedItem).Content, Mode=OneWay}"/>
126126

127-
<uilib:TabView Background="Transparent" Grid.Row="0" AddTabButtonClick="TabStrip_AddTabButtonClick" Style="{StaticResource TabViewStyleFixed}" SelectionChanged="TabStrip_SelectionChanged" TabCloseRequested="TabStrip_TabCloseRequested" Name="TabStrip" TabWidthMode="Equal" VerticalAlignment="Stretch">
128-
<uilib:TabView.Resources>
129-
<ResourceDictionary>
130-
<ResourceDictionary.ThemeDictionaries>
131-
<ResourceDictionary x:Key="Default">
132-
<StaticResource x:Key="TabViewItemHeaderBackgroundSelected" ResourceKey="SystemControlBackgroundAltHighBrush" />
133-
<StaticResource x:Key="TabViewItemHeaderBackgroundPointerOver" ResourceKey="SystemAltMediumLowColor" />
134-
<StaticResource x:Key="TabViewItemHeaderBackgroundPressed" ResourceKey="SystemAltMediumColor" />
135-
</ResourceDictionary>
136-
<ResourceDictionary x:Key="Light">
137-
<StaticResource x:Key="TabViewItemHeaderBackgroundSelected" ResourceKey="SystemControlBackgroundAltHighBrush" />
138-
<StaticResource x:Key="TabViewItemHeaderBackgroundPointerOver" ResourceKey="SystemAltMediumLowColor" />
139-
<StaticResource x:Key="TabViewItemHeaderBackgroundPressed" ResourceKey="SystemAltMediumColor" />
140-
</ResourceDictionary>
141-
<ResourceDictionary x:Key="Dark">
142-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="#191919" />
143-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="#191919" />
144-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="#191919" />
145-
</ResourceDictionary>
146-
<ResourceDictionary x:Key="HighContrast">
147-
<!-- This empty dictionary ensures that the default high contrast resources are used when the user turns on high contrast mode. -->
148-
</ResourceDictionary>
149-
</ResourceDictionary.ThemeDictionaries>
150-
</ResourceDictionary>
151-
<!--<x:Double x:Key="TabViewItemHeaderMinHeight">32</x:Double>
152-
<StaticResource x:Key="TabViewSelectionIndicatorForeground" ResourceKey="SystemControlTransparentBrush" />-->
153-
</uilib:TabView.Resources>
127+
<uilib:TabView Grid.Row="0" AddTabButtonClick="TabStrip_AddTabButtonClick" Style="{ThemeResource TabViewStyleFixed}" SelectionChanged="TabStrip_SelectionChanged" TabCloseRequested="TabStrip_TabCloseRequested" Name="TabStrip" TabWidthMode="Equal" VerticalAlignment="Stretch">
128+
154129
</uilib:TabView>
155-
130+
<Grid Grid.Column="1" Background="{ThemeResource TabViewBackground}"/>
156131
</Grid>
157132
</Page>

0 commit comments

Comments
 (0)