Skip to content

Commit b112b02

Browse files
authored
Feature: Added speed graph to status center (#13359)
1 parent 9b816ae commit b112b02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3661
-1592
lines changed

src/Files.App/Actions/Content/Archives/Compress/BaseCompressArchiveAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal abstract class BaseCompressArchiveAction : BaseUIAction, IAction
1313

1414
public override bool IsExecutable =>
1515
IsContextPageTypeAdaptedToCommand() &&
16-
ArchiveHelpers.CanCompress(context.SelectedItems) &&
16+
CompressHelper.CanCompress(context.SelectedItems) &&
1717
UIHelpers.CanShowDialog;
1818

1919
public BaseCompressArchiveAction()

src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public CompressIntoArchiveAction()
2020

2121
public override async Task ExecuteAsync()
2222
{
23-
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
23+
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);
2424

2525
var dialog = new CreateArchiveDialog
2626
{
@@ -32,18 +32,16 @@ public override async Task ExecuteAsync()
3232
if (!dialog.CanCreate || result != ContentDialogResult.Primary)
3333
return;
3434

35-
IArchiveCreator creator = new ArchiveCreator
36-
{
37-
Sources = sources,
38-
Directory = directory,
39-
FileName = dialog.FileName,
40-
Password = dialog.Password,
41-
FileFormat = dialog.FileFormat,
42-
CompressionLevel = dialog.CompressionLevel,
43-
SplittingSize = dialog.SplittingSize,
44-
};
35+
ICompressArchiveModel creator = new CompressArchiveModel(
36+
sources,
37+
directory,
38+
dialog.FileName,
39+
dialog.Password,
40+
dialog.FileFormat,
41+
dialog.CompressionLevel,
42+
dialog.SplittingSize);
4543

46-
await ArchiveHelpers.CompressArchiveAsync(creator);
44+
await CompressHelper.CompressArchiveAsync(creator);
4745
}
4846
}
4947
}

src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Files.App.Actions
66
internal sealed class CompressIntoSevenZipAction : BaseCompressArchiveAction
77
{
88
public override string Label
9-
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.7z");
9+
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{CompressHelper.DetermineArchiveNameFromSelection(context.SelectedItems)}.7z");
1010

1111
public override string Description
1212
=> "CompressIntoSevenZipDescription".GetLocalizedResource();
@@ -17,17 +17,15 @@ public CompressIntoSevenZipAction()
1717

1818
public override Task ExecuteAsync()
1919
{
20-
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
20+
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);
2121

22-
IArchiveCreator creator = new ArchiveCreator
23-
{
24-
Sources = sources,
25-
Directory = directory,
26-
FileName = fileName,
27-
FileFormat = ArchiveFormats.SevenZip,
28-
};
22+
ICompressArchiveModel creator = new CompressArchiveModel(
23+
sources,
24+
directory,
25+
fileName,
26+
fileFormat: ArchiveFormats.SevenZip);
2927

30-
return ArchiveHelpers.CompressArchiveAsync(creator);
28+
return CompressHelper.CompressArchiveAsync(creator);
3129
}
3230
}
3331
}

src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Files.App.Actions
66
internal sealed class CompressIntoZipAction : BaseCompressArchiveAction
77
{
88
public override string Label
9-
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.zip");
9+
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{CompressHelper.DetermineArchiveNameFromSelection(context.SelectedItems)}.zip");
1010

1111
public override string Description
1212
=> "CompressIntoZipDescription".GetLocalizedResource();
@@ -17,17 +17,15 @@ public CompressIntoZipAction()
1717

1818
public override Task ExecuteAsync()
1919
{
20-
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
20+
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);
2121

22-
IArchiveCreator creator = new ArchiveCreator
23-
{
24-
Sources = sources,
25-
Directory = directory,
26-
FileName = fileName,
27-
FileFormat = ArchiveFormats.Zip,
28-
};
22+
ICompressArchiveModel creator = new CompressArchiveModel(
23+
sources,
24+
directory,
25+
fileName,
26+
fileFormat: ArchiveFormats.Zip);
2927

30-
return ArchiveHelpers.CompressArchiveAsync(creator);
28+
return CompressHelper.CompressArchiveAsync(creator);
3129
}
3230
}
3331
}

src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public virtual HotKey HotKey
1616

1717
public override bool IsExecutable =>
1818
(IsContextPageTypeAdaptedToCommand() &&
19-
ArchiveHelpers.CanDecompress(context.SelectedItems) ||
19+
CompressHelper.CanDecompress(context.SelectedItems) ||
2020
CanDecompressInsideArchive()) &&
2121
UIHelpers.CanShowDialog;
2222

src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public DecompressArchive()
2323

2424
public override Task ExecuteAsync()
2525
{
26-
return ArchiveHelpers.DecompressArchiveAsync(context.ShellPage);
26+
return DecompressHelper.DecompressArchiveAsync(context.ShellPage);
2727
}
2828

2929
protected override bool CanDecompressInsideArchive()

src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHere.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public DecompressArchiveHere()
1717

1818
public override Task ExecuteAsync()
1919
{
20-
return ArchiveHelpers.DecompressArchiveHereAsync(context.ShellPage);
20+
return DecompressHelper.DecompressArchiveHereAsync(context.ShellPage);
2121
}
2222
}
2323
}

src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public DecompressArchiveToChildFolderAction()
1717

1818
public override Task ExecuteAsync()
1919
{
20-
return ArchiveHelpers.DecompressArchiveToChildFolderAsync(context.ShellPage);
20+
return DecompressHelper.DecompressArchiveToChildFolderAsync(context.ShellPage);
2121
}
2222

2323
protected override void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Files.App/App.xaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
3131

3232
<!-- Styles for the custom icons -->
33-
<ResourceDictionary Source="/ResourceDictionaries/PathIcons.xaml" />
34-
<ResourceDictionary Source="/UserControls/SideBar/SideBarControls.xaml" />
33+
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/PathIcons.xaml" />
34+
<ResourceDictionary Source="ms-appx:///UserControls/SideBar/SideBarControls.xaml" />
3535
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/App.Theme.TextBlockStyles.xaml" />
3636
<ResourceDictionary>
3737
<ResourceDictionary.ThemeDictionaries>
@@ -45,6 +45,9 @@
4545
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
4646
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SubtleFillColorTertiary}" />
4747
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SubtleFillColorSecondary}" />
48+
49+
<Color x:Key="App.Theme.FillColorAttention">#0070CB</Color>
50+
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
4851
</ResourceDictionary>
4952
<ResourceDictionary x:Key="Dark">
5053
<SolidColorBrush x:Key="App.Theme.BackgroundBrush" Color="Transparent" />
@@ -56,6 +59,9 @@
5659
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
5760
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SubtleFillColorTertiary}" />
5861
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SubtleFillColorSecondary}" />
62+
63+
<Color x:Key="App.Theme.FillColorAttention">#50C0FF</Color>
64+
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
5965
</ResourceDictionary>
6066
<ResourceDictionary x:Key="HighContrast">
6167
<SolidColorBrush x:Key="App.Theme.BackgroundBrush" Color="Transparent" />
@@ -67,6 +73,9 @@
6773
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource SystemColorHighlightColor}" />
6874
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SystemColorHighlightColor}" />
6975
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
76+
77+
<Color x:Key="App.Theme.FillColorAttention">#50C0FF</Color>
78+
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
7079
</ResourceDictionary>
7180
</ResourceDictionary.ThemeDictionaries>
7281
</ResourceDictionary>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright (c) 2023 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
using Microsoft.UI.Xaml;
5+
using Microsoft.UI.Xaml.Data;
6+
using Microsoft.UI.Xaml.Media;
7+
8+
namespace Files.App.Converters
9+
{
10+
public class StatusCenterStateToBrushConverter : DependencyObject, IValueConverter
11+
{
12+
public static readonly DependencyProperty InProgressBackgroundBrushProperty =
13+
DependencyProperty.Register(nameof(InProgressBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
14+
15+
public static readonly DependencyProperty InProgressForegroundBrushProperty =
16+
DependencyProperty.Register(nameof(InProgressForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
17+
18+
public static readonly DependencyProperty SuccessfulBackgroundBrushProperty =
19+
DependencyProperty.Register(nameof(SuccessfulBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
20+
21+
public static readonly DependencyProperty SuccessfulForegroundBrushProperty =
22+
DependencyProperty.Register(nameof(SuccessfulForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
23+
24+
public static readonly DependencyProperty ErrorBackgroundBrushProperty =
25+
DependencyProperty.Register(nameof(ErrorBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
26+
27+
public static readonly DependencyProperty ErrorForegroundBrushProperty =
28+
DependencyProperty.Register(nameof(ErrorForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
29+
30+
public static readonly DependencyProperty CanceledBackgroundBrushProperty =
31+
DependencyProperty.Register(nameof(CanceledBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
32+
33+
public static readonly DependencyProperty CanceledForegroundBrushProperty =
34+
DependencyProperty.Register(nameof(CanceledForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));
35+
36+
public SolidColorBrush InProgressBackgroundBrush
37+
{
38+
get => (SolidColorBrush)GetValue(InProgressBackgroundBrushProperty);
39+
set => SetValue(InProgressBackgroundBrushProperty, value);
40+
}
41+
42+
public SolidColorBrush InProgressForegroundBrush
43+
{
44+
get => (SolidColorBrush)GetValue(InProgressForegroundBrushProperty);
45+
set => SetValue(InProgressForegroundBrushProperty, value);
46+
}
47+
48+
public SolidColorBrush SuccessfulBackgroundBrush
49+
{
50+
get => (SolidColorBrush)GetValue(SuccessfulBackgroundBrushProperty);
51+
set => SetValue(SuccessfulBackgroundBrushProperty, value);
52+
}
53+
54+
public SolidColorBrush SuccessfulForegroundBrush
55+
{
56+
get => (SolidColorBrush)GetValue(SuccessfulForegroundBrushProperty);
57+
set => SetValue(SuccessfulForegroundBrushProperty, value);
58+
}
59+
60+
public SolidColorBrush ErrorBackgroundBrush
61+
{
62+
get => (SolidColorBrush)GetValue(ErrorBackgroundBrushProperty);
63+
set => SetValue(ErrorBackgroundBrushProperty, value);
64+
}
65+
66+
public SolidColorBrush ErrorForegroundBrush
67+
{
68+
get => (SolidColorBrush)GetValue(ErrorForegroundBrushProperty);
69+
set => SetValue(ErrorForegroundBrushProperty, value);
70+
}
71+
72+
public SolidColorBrush CanceledBackgroundBrush
73+
{
74+
get => (SolidColorBrush)GetValue(CanceledBackgroundBrushProperty);
75+
set => SetValue(CanceledBackgroundBrushProperty, value);
76+
}
77+
78+
public SolidColorBrush CanceledForegroundBrush
79+
{
80+
get => (SolidColorBrush)GetValue(CanceledForegroundBrushProperty);
81+
set => SetValue(CanceledForegroundBrushProperty, value);
82+
}
83+
84+
public object? Convert(object value, Type targetType, object parameter, string language)
85+
{
86+
if (value is StatusCenterItemKind state)
87+
{
88+
if (bool.TryParse(parameter?.ToString(), out var isBackground) && isBackground)
89+
{
90+
return state switch
91+
{
92+
StatusCenterItemKind.InProgress => InProgressBackgroundBrush,
93+
StatusCenterItemKind.Successful => SuccessfulBackgroundBrush,
94+
StatusCenterItemKind.Error => ErrorBackgroundBrush,
95+
StatusCenterItemKind.Canceled => CanceledBackgroundBrush,
96+
_ => CanceledBackgroundBrush
97+
};
98+
}
99+
else
100+
{
101+
return state switch
102+
{
103+
StatusCenterItemKind.InProgress => InProgressForegroundBrush,
104+
StatusCenterItemKind.Successful => SuccessfulForegroundBrush,
105+
StatusCenterItemKind.Error => ErrorForegroundBrush,
106+
StatusCenterItemKind.Canceled => CanceledForegroundBrush,
107+
_ => CanceledForegroundBrush
108+
};
109+
}
110+
}
111+
112+
return null;
113+
}
114+
115+
public object ConvertBack(object value, Type targetType, object parameter, string language)
116+
{
117+
throw new NotImplementedException();
118+
}
119+
}
120+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) 2023 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
using Microsoft.UI.Xaml;
5+
using Microsoft.UI.Xaml.Data;
6+
using Microsoft.UI.Xaml.Markup;
7+
using Microsoft.UI.Xaml.Media;
8+
using Microsoft.UI.Xaml.Shapes;
9+
10+
namespace Files.App.Converters
11+
{
12+
class StatusCenterStateToStateIconConverter : IValueConverter
13+
{
14+
public object? Convert(object value, Type targetType, object parameter, string language)
15+
{
16+
if (value is StatusCenterItemIconKind state)
17+
{
18+
var pathMarkup = state switch
19+
{
20+
StatusCenterItemIconKind.Copy => Application.Current.Resources["App.Theme.PathIcon.ActionCopy"] as string,
21+
StatusCenterItemIconKind.Move => Application.Current.Resources["App.Theme.PathIcon.ActionMove"] as string,
22+
StatusCenterItemIconKind.Delete => Application.Current.Resources["App.Theme.PathIcon.ActionDelete"] as string,
23+
StatusCenterItemIconKind.Recycle => Application.Current.Resources["App.Theme.PathIcon.ActionDelete"] as string,
24+
StatusCenterItemIconKind.Extract => Application.Current.Resources["App.Theme.PathIcon.ActionExtract"] as string,
25+
StatusCenterItemIconKind.Compress => Application.Current.Resources["App.Theme.PathIcon.ActionExtract"] as string,
26+
StatusCenterItemIconKind.Successful => Application.Current.Resources["App.Theme.PathIcon.ActionSuccess"] as string,
27+
StatusCenterItemIconKind.Error => Application.Current.Resources["App.Theme.PathIcon.ActionInfo"] as string,
28+
_ => ""
29+
};
30+
31+
string xaml = @$"<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><Path.Data>{pathMarkup}</Path.Data></Path>";
32+
33+
if (XamlReader.Load(xaml) is not Path path)
34+
return null;
35+
36+
// Initialize a new instance
37+
Geometry geometry = path.Data;
38+
39+
// Destroy
40+
path.Data = null;
41+
42+
return geometry;
43+
}
44+
45+
return null;
46+
}
47+
48+
public object ConvertBack(object value, Type targetType, object parameter, string language)
49+
{
50+
throw new NotImplementedException();
51+
}
52+
}
53+
}

src/Files.App/Data/Items/ListedItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public string ItemTooltipText
3838
get
3939
{
4040
var tooltipBuilder = new StringBuilder();
41-
tooltipBuilder.AppendLine($"{"ToolTipDescriptionName".GetLocalizedResource()} {Name}");
41+
tooltipBuilder.AppendLine($"{"NameWithColon".GetLocalizedResource()} {Name}");
4242
tooltipBuilder.AppendLine($"{"ItemType".GetLocalizedResource()} {itemType}");
4343
tooltipBuilder.Append($"{"ToolTipDescriptionDate".GetLocalizedResource()} {ItemDateModified}");
4444
if(!string.IsNullOrWhiteSpace(FileSize))

src/Files.App/Extensions/StringExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static string ConvertSizeAbbreviation(this string value)
7979
return value;
8080
}
8181

82+
public static string ToSizeString(this double size) => ByteSize.FromBytes(size).ToSizeString();
8283
public static string ToSizeString(this long size) => ByteSize.FromBytes(size).ToSizeString();
8384
public static string ToSizeString(this ulong size) => ByteSize.FromBytes(size).ToSizeString();
8485
public static string ToSizeString(this ByteSize size) => size.ToBinaryString().ConvertSizeAbbreviation();

0 commit comments

Comments
 (0)