Skip to content

Commit aa56ffe

Browse files
authored
Fix blurred disk drive icons (#813)
1 parent 96fef2b commit aa56ffe

File tree

7 files changed

+54
-109
lines changed

7 files changed

+54
-109
lines changed

Files/App.xaml.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,10 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
345345

346346
public class WSLDistroItem : INavigationControlItem
347347
{
348-
public string DistroName { get; set; }
348+
public string Glyph { get; set; } = null;
349+
public string Text { get; set; }
349350
public string Path { get; set; }
351+
public NavigationControlItemType ItemType => NavigationControlItemType.LinuxDistro;
350352
public Uri Logo { get; set; }
351-
352-
string INavigationControlItem.IconGlyph => null;
353-
354-
string INavigationControlItem.Text => DistroName;
355-
356-
string INavigationControlItem.Path => Path;
357-
358-
NavigationControlItemType INavigationControlItem.ItemType => NavigationControlItemType.LinuxDistro;
359353
}
360354
}

Files/Filesystem/DriveItem.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,36 @@ namespace Files.Filesystem
88
public class DriveItem : INavigationControlItem
99
{
1010
public string Glyph { get; set; }
11+
public string Text { get; set; }
12+
public string Path => Tag;
13+
public NavigationControlItemType ItemType { get; set; } = NavigationControlItemType.Drive;
1114
public ulong MaxSpace { get; set; } = 0;
1215
public ulong SpaceUsed { get; set; } = 0;
13-
public string DriveText { get; set; }
14-
public string Tag { get; set; }
15-
public Visibility ProgressBarVisibility { get; set; }
1616
public string SpaceText { get; set; }
17-
public Visibility CloudGlyphVisibility { get; set; } = Visibility.Collapsed;
18-
public Visibility DriveGlyphVisibility { get; set; } = Visibility.Visible;
17+
public string Tag { get; set; }
1918
public Visibility ItemVisibility { get; set; } = Visibility.Visible;
20-
public DriveType Type { get; set; }
21-
string INavigationControlItem.IconGlyph => Glyph;
22-
string INavigationControlItem.Text => DriveText;
23-
string INavigationControlItem.Path => Tag;
24-
private readonly NavigationControlItemType NavItemType = NavigationControlItemType.Drive;
25-
NavigationControlItemType INavigationControlItem.ItemType => NavItemType;
19+
20+
private DriveType _type;
21+
public DriveType Type
22+
{
23+
get => _type;
24+
set
25+
{
26+
_type = value;
27+
SetGlyph(_type);
28+
}
29+
}
2630

2731
public DriveItem()
2832
{
29-
NavItemType = NavigationControlItemType.OneDrive;
33+
ItemType = NavigationControlItemType.OneDrive;
3034
}
3135

32-
public DriveItem(StorageFolder root, Visibility progressBarVisibility, DriveType type)
36+
public DriveItem(StorageFolder root, DriveType type)
3337
{
34-
this.ProgressBarVisibility = progressBarVisibility;
38+
Text = root.DisplayName;
3539
Type = type;
40+
Tag = root.Path;
3641

3742
var properties = Task.Run(async () =>
3843
{
@@ -52,11 +57,10 @@ public DriveItem(StorageFolder root, Visibility progressBarVisibility, DriveType
5257
{
5358
SpaceText = "Unknown";
5459
}
60+
}
5561

56-
DriveText = root.DisplayName;
57-
58-
Tag = root.Path;
59-
62+
private void SetGlyph(DriveType type)
63+
{
6064
switch (type)
6165
{
6266
case DriveType.Fixed:
@@ -85,6 +89,7 @@ public DriveItem(StorageFolder root, Visibility progressBarVisibility, DriveType
8589
break;
8690

8791
case DriveType.VirtualDrive:
92+
Glyph = "\uE753";
8893
break;
8994

9095
case DriveType.FloppyDisk:

Files/Filesystem/Drives.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,7 @@ private async void DeviceAdded(DeviceWatcher sender, DeviceInformation args)
130130
return;
131131
}
132132

133-
DriveType type = DriveType.Removable;
134-
135-
var driveItem = new DriveItem(
136-
root,
137-
Visibility.Visible,
138-
type);
133+
var driveItem = new DriveItem(root, DriveType.Removable);
139134

140135
Logger.Info($"Drive added: {driveItem.Tag}, {driveItem.Type}");
141136

@@ -261,10 +256,7 @@ private async Task GetDrives(IList<DriveItem> list)
261256
break;
262257
}
263258

264-
var driveItem = new DriveItem(
265-
folder,
266-
Visibility.Visible,
267-
type);
259+
var driveItem = new DriveItem(folder, type);
268260

269261
Logger.Info($"Drive added: {driveItem.Tag}, {driveItem.Type}");
270262

@@ -276,12 +268,9 @@ private void GetVirtualDrivesList(IList<DriveItem> list)
276268
{
277269
var oneDriveItem = new DriveItem()
278270
{
279-
DriveText = "OneDrive",
271+
Text = "OneDrive",
280272
Tag = "OneDrive",
281-
CloudGlyphVisibility = Visibility.Visible,
282-
DriveGlyphVisibility = Visibility.Collapsed,
283273
Type = DriveType.VirtualDrive,
284-
//itemVisibility = App.AppSettings.PinOneDriveToSideBar
285274
};
286275

287276
var setting = ApplicationData.Current.LocalSettings.Values["PinOneDrive"];

Files/Filesystem/INavigationControlItem.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ namespace Files.Filesystem
88
{
99
public interface INavigationControlItem
1010
{
11-
public string IconGlyph { get; }
12-
11+
public string Glyph { get; }
1312
public string Text { get; }
14-
1513
public string Path { get; }
1614
public NavigationControlItemType ItemType { get; }
1715
}

Files/Filesystem/LocationItem.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,18 @@ namespace Files.Filesystem
88
{
99
public class LocationItem : INavigationControlItem
1010
{
11-
public bool IsDefaultLocation { get; set; }
1211
public string Glyph { get; set; }
1312
public string Text { get; set; }
1413
public string Path { get; set; }
15-
16-
string INavigationControlItem.IconGlyph => Glyph;
17-
18-
string INavigationControlItem.Text => Text;
19-
20-
string INavigationControlItem.Path => Path;
21-
22-
NavigationControlItemType INavigationControlItem.ItemType => NavigationControlItemType.Location;
14+
public NavigationControlItemType ItemType => NavigationControlItemType.Location;
15+
public bool IsDefaultLocation { get; set; }
2316
}
2417

2518
public class HeaderTextItem : INavigationControlItem
2619
{
27-
string INavigationControlItem.IconGlyph => null;
20+
public string Glyph { get; set; } = null;
2821
public string Text { get; set; }
29-
30-
string INavigationControlItem.Text => Text;
31-
32-
string INavigationControlItem.Path => null;
33-
34-
NavigationControlItemType INavigationControlItem.ItemType => NavigationControlItemType.Header;
22+
public string Path { get; set; } = null;
23+
public NavigationControlItemType ItemType => NavigationControlItemType.Header;
3524
}
3625
}

Files/UserControls/ModernSidebar.xaml

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,34 @@
3535

3636
<DataTemplate x:Key="DriveNavItem" x:DataType="local2:DriveItem">
3737
<muxc:NavigationViewItem
38-
Padding="0"
38+
Content="{x:Bind Text}"
3939
BorderThickness="0.8"
4040
DataContext="{x:Bind}"
41+
Padding="0"
4142
Tag="{x:Bind Tag}"
42-
Visibility="{x:Bind ItemVisibility}">
43-
<muxc:NavigationViewItem.Content>
44-
<StackPanel
45-
Margin="-4,0,0,0"
46-
DataContext="{x:Bind}"
47-
Orientation="Horizontal"
48-
Spacing="12"
49-
ToolTipService.ToolTip="{x:Bind SpaceText}">
50-
<Grid>
51-
<FontIcon
52-
FontFamily="Segoe MDL2 Assets"
53-
FontSize="18"
54-
Glyph="{x:Bind Glyph}"
55-
Visibility="{x:Bind DriveGlyphVisibility}" />
56-
<FontIcon
57-
FontFamily="Segoe MDL2 Assets"
58-
FontSize="18"
59-
Glyph="&#xE753;"
60-
Visibility="{x:Bind CloudGlyphVisibility}" />
61-
</Grid>
62-
<TextBlock
63-
FontSize="14"
64-
Text="{x:Bind DriveText}"
65-
TextTrimming="CharacterEllipsis" />
66-
</StackPanel>
67-
</muxc:NavigationViewItem.Content>
43+
Visibility="{x:Bind ItemVisibility}"
44+
ToolTipService.ToolTip="{x:Bind SpaceText}">
45+
<muxc:NavigationViewItem.Icon>
46+
<FontIcon Glyph="{x:Bind Glyph}" />
47+
</muxc:NavigationViewItem.Icon>
6848
</muxc:NavigationViewItem>
6949
</DataTemplate>
7050

7151
<DataTemplate x:Key="LinuxNavItem" x:DataType="local1:WSLDistroItem">
7252
<muxc:NavigationViewItem
73-
Padding="0"
53+
Content="{x:Bind Text}"
7454
BorderThickness="0.8"
7555
DataContext="{x:Bind}"
56+
Padding="0"
7657
IsTabStop="False"
7758
Tag="{x:Bind Path}">
78-
<muxc:NavigationViewItem.Content>
79-
<StackPanel
80-
DataContext="{x:Bind}"
81-
Orientation="Horizontal"
82-
Spacing="6">
83-
<BitmapIcon
84-
Width="30"
85-
Height="30"
86-
ShowAsMonochrome="False"
87-
UriSource="{x:Bind Logo}" />
88-
<TextBlock
89-
VerticalAlignment="Center"
90-
FontSize="14"
91-
Text="{x:Bind DistroName}" />
92-
</StackPanel>
93-
</muxc:NavigationViewItem.Content>
59+
<muxc:NavigationViewItem.Icon>
60+
<BitmapIcon
61+
Width="30"
62+
Height="30"
63+
ShowAsMonochrome="False"
64+
UriSource="{x:Bind Logo}" />
65+
</muxc:NavigationViewItem.Icon>
9466
</muxc:NavigationViewItem>
9567
</DataTemplate>
9668

@@ -120,6 +92,7 @@
12092
OpenPaneLength="200"
12193
PaneDisplayMode="Left"
12294
SelectedItem="{x:Bind SelectedSidebarItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
95+
<NavigationViewItemSeparator />
12396
<muxc:NavigationView.PaneFooter>
12497
<Grid Width="200">
12598
<Button

Files/View Models/SettingsViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private async void DetectWSLDistros()
215215
logoURI = new Uri("ms-appx:///Assets/WSL/genericpng.png");
216216
}
217217

218-
App.sideBarItems.Add(new WSLDistroItem() { DistroName = folder.DisplayName, Path = folder.Path, Logo = logoURI });
218+
App.sideBarItems.Add(new WSLDistroItem() { Text = folder.DisplayName, Path = folder.Path, Logo = logoURI });
219219
}
220220
}
221221
catch (Exception)
@@ -371,12 +371,9 @@ public bool PinOneDriveToSideBar
371371
localSettings.Values["PinOneDrive"] = true;
372372
var oneDriveItem = new DriveItem()
373373
{
374-
DriveText = "OneDrive",
374+
Text = "OneDrive",
375375
Tag = "OneDrive",
376-
CloudGlyphVisibility = Visibility.Visible,
377-
DriveGlyphVisibility = Visibility.Collapsed,
378376
Type = Filesystem.DriveType.VirtualDrive,
379-
//itemVisibility = App.AppSettings.PinOneDriveToSideBar
380377
};
381378
App.sideBarItems.Add(oneDriveItem);
382379
}

0 commit comments

Comments
 (0)