Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added speed graph to the status center #13359

Merged
merged 128 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 127 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
91ee304
Initial commit
0x5bfa Sep 12, 2023
96bdacc
Update
0x5bfa Sep 12, 2023
1500997
Update
0x5bfa Sep 13, 2023
aecdae3
Merge branch 'main' into 5bfa/Add-TransferGraph
0x5bfa Sep 14, 2023
f757935
Update
0x5bfa Sep 15, 2023
42435da
Merge branch 'main' into 5bfa/Add-TransferGraph
0x5bfa Sep 15, 2023
fcd3824
Update
0x5bfa Sep 15, 2023
8da86e0
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Sep 15, 2023
67c03fa
Update
0x5bfa Sep 15, 2023
d20e14a
Speed calc
gave92 Sep 16, 2023
feaeea7
Update
0x5bfa Sep 16, 2023
181552f
Update
0x5bfa Sep 16, 2023
5405899
Update
0x5bfa Sep 16, 2023
80b2e5f
Update src/Files.App/Utils/StatusCenter/StatusCenterItem.cs
0x5bfa Sep 16, 2023
6f9fe76
Remove unncessary comments
0x5bfa Sep 16, 2023
9c92da4
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Sep 16, 2023
7e6a86a
Merge commit 'refs/pull/13359/head' of https://github.com/files-commu…
gave92 Sep 17, 2023
9e65a23
Get progress percentage as double
gave92 Sep 17, 2023
5a3f7a4
Remove extra class
gave92 Sep 17, 2023
f43af45
Fixed build issues
0x5bfa Sep 17, 2023
e8322d2
fix
0x5bfa Sep 17, 2023
b90dd1f
Update
0x5bfa Sep 18, 2023
80dad8a
Revert "Update"
0x5bfa Sep 18, 2023
19c4d7c
Update
0x5bfa Sep 18, 2023
df148fd
Merge commit 'refs/pull/13359/head' of https://github.com/files-commu…
gave92 Sep 18, 2023
12840c5
No precalc size
gave92 Sep 18, 2023
9b1f9d5
Calc size in parallel
gave92 Sep 18, 2023
a672bfe
Fix size calc for files
gave92 Sep 18, 2023
6bd7157
Merge pull request #10 from gave92/rev_speed_2
0x5bfa Sep 19, 2023
31687fc
Merge branch 'files-community:main' into 5bfa/Add-TransferGraph
0x5bfa Sep 19, 2023
424c0eb
Fix
0x5bfa Sep 19, 2023
d0b5a98
Parallel size computation
hez2010 Sep 19, 2023
32261d4
Minor fixes
hez2010 Sep 19, 2023
3e9c62e
More fixes
hez2010 Sep 19, 2023
1a82f64
Merge pull request #11 from hez2010/parallel-size
0x5bfa Sep 20, 2023
5e467ca
Update
0x5bfa Sep 20, 2023
56ebe88
Fix merge conflicts
0x5bfa Sep 20, 2023
c3f9fe2
Update
0x5bfa Sep 20, 2023
2355648
Fix graph
gave92 Sep 20, 2023
8f80a00
Removed unused out var
gave92 Sep 20, 2023
4eeb9ec
Merge pull request #12 from gave92/rev_speed_2
0x5bfa Sep 20, 2023
d86ed24
Update
0x5bfa Sep 21, 2023
c9bf35b
Update strings
0x5bfa Sep 21, 2023
c642589
Update
0x5bfa Sep 21, 2023
206126f
Update
0x5bfa Sep 21, 2023
a2ca145
Fix
0x5bfa Sep 21, 2023
dc60e28
Update
0x5bfa Sep 21, 2023
36ad647
Update
0x5bfa Sep 22, 2023
548986e
Update
0x5bfa Sep 25, 2023
b815675
Update
0x5bfa Sep 25, 2023
f8b9f02
Fix spag errors
0x5bfa Sep 25, 2023
a83495c
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Sep 26, 2023
0bd9f06
Fix string resources
0x5bfa Sep 26, 2023
2a43a50
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Sep 26, 2023
9e41d66
Update
0x5bfa Sep 26, 2023
6721026
Update
0x5bfa Sep 26, 2023
bf64e2c
Update
0x5bfa Sep 26, 2023
5ef9caf
Update
0x5bfa Sep 26, 2023
4030e4a
Update
0x5bfa Sep 26, 2023
9405e46
Update
0x5bfa Sep 26, 2023
084d88f
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa Sep 26, 2023
badc814
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa Sep 26, 2023
0af6aa8
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa Sep 26, 2023
a0cd7ce
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa Sep 26, 2023
68bbe89
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa Sep 26, 2023
743ffe9
Merge branch 'main' into 5bfa/Add-TransferGraph
0x5bfa Sep 27, 2023
182060c
Update src/Files.App/Strings/en-US/Resources.resw
yaira2 Sep 27, 2023
3efb831
Update src/Files.App/Strings/en-US/Resources.resw
yaira2 Sep 27, 2023
8dabca3
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Sep 27, 2023
11fe156
Update
0x5bfa Sep 27, 2023
7d6cf20
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Sep 27, 2023
33bc6fa
Update
0x5bfa Sep 27, 2023
f276637
Requested changes 1
0x5bfa Sep 27, 2023
9af32cd
Requested changes
0x5bfa Sep 27, 2023
0ccc821
Update
0x5bfa Sep 28, 2023
ef3ec5c
Update
0x5bfa Sep 29, 2023
0dbfc5c
Update
0x5bfa Sep 30, 2023
c798203
Remove unused code
gave92 Sep 30, 2023
80a58c1
Show progress for extract
gave92 Oct 1, 2023
19d3247
Fix graph not updating each percentage
gave92 Oct 1, 2023
bd43685
Show progress for compress
gave92 Oct 1, 2023
70b5eed
Set icon for compressing
gave92 Oct 1, 2023
95b5d2e
Merge pull request #13 from gave92/rev_speed_2
0x5bfa Oct 1, 2023
5a5c2a0
Update
0x5bfa Oct 2, 2023
cc242a0
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Oct 2, 2023
1c8910b
Update
0x5bfa Oct 2, 2023
303962f
Fix icons
0x5bfa Oct 5, 2023
27c1d76
Update string resources
0x5bfa Oct 5, 2023
f466774
Fix resources
0x5bfa Oct 5, 2023
3d08efc
Update strings
0x5bfa Oct 6, 2023
26ff8f1
Fix canceling when extracting archives
gave92 Oct 6, 2023
6e91d71
Added cancel state
0x5bfa Oct 7, 2023
cafdb49
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Oct 7, 2023
21cc808
Remove "Complete - " label from resources
0x5bfa Oct 9, 2023
9371402
Merge branch 'main' into 5bfa/Add-TransferGraph
0x5bfa Oct 9, 2023
0bb1c1d
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Oct 10, 2023
1992ca9
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Oct 12, 2023
04b4e7d
Added status center icon
yaira2 Oct 12, 2023
5d68ca4
Requested changes
0x5bfa Oct 13, 2023
fd1a074
Merge branch 'main' into 5bfa/Add-TransferGraph
0x5bfa Oct 14, 2023
6f08389
Update strings
0x5bfa Oct 14, 2023
ca90ffc
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
0x5bfa Oct 14, 2023
a1f11fc
Add support for canceling compression. TODO: show proper status card
gave92 Oct 16, 2023
6574fbe
Update strings
yaira2 Oct 16, 2023
4585781
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Oct 16, 2023
92534b5
item(s)
yaira2 Oct 16, 2023
c232652
Merge branch '5bfa/Add-TransferGraph' of https://github.com/0x5bfa/Fi…
yaira2 Oct 16, 2023
fa475a1
Fix crash
yaira2 Oct 16, 2023
ffd91c1
Update Resources.resw
yaira2 Oct 17, 2023
c673772
merge main into here
0x5bfa Oct 17, 2023
0e3e304
Update
0x5bfa Oct 17, 2023
cc3ccc4
Null check in string resources
0x5bfa Oct 17, 2023
aea031d
Fix resource mappings
0x5bfa Oct 17, 2023
3aded1c
merge main into here
0x5bfa Oct 17, 2023
9809a1a
Update StatusCenterItem.cs
0x5bfa Oct 18, 2023
978a1f9
Update StatusCenterHelper.cs
hishitetsu Oct 18, 2023
6f5f6df
Update Resources.resw
yaira2 Oct 18, 2023
8730448
Merge branch 'main' into 5bfa/Add-TransferGraph
yaira2 Oct 18, 2023
976bc19
Requested changes
0x5bfa Oct 20, 2023
a74f5c2
Update brush name
yaira2 Oct 20, 2023
d811433
Update icon name
yaira2 Oct 20, 2023
5932038
Fix
yaira2 Oct 20, 2023
2bbace3
Fix icon name
yaira2 Oct 20, 2023
7b43460
Merge remote-tracking branch 'upstream/main' into 5bfa/Add-TransferGraph
0x5bfa Oct 21, 2023
b337e2c
merge
0x5bfa Oct 21, 2023
6bc2077
Fixed an issue wherer the backgroud fill and the series fill didn't m…
0x5bfa Oct 21, 2023
463e1d5
merge main into here
0x5bfa Oct 22, 2023
425d1ea
Fix cancellation of compression & extraction (#14)
gave92 Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal abstract class BaseCompressArchiveAction : BaseUIAction, IAction

public override bool IsExecutable =>
IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanCompress(context.SelectedItems) &&
CompressHelper.CanCompress(context.SelectedItems) &&
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
UIHelpers.CanShowDialog;

public BaseCompressArchiveAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public CompressIntoArchiveAction()

public override async Task ExecuteAsync()
{
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);

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

IArchiveCreator creator = new ArchiveCreator
{
Sources = sources,
Directory = directory,
FileName = dialog.FileName,
Password = dialog.Password,
FileFormat = dialog.FileFormat,
CompressionLevel = dialog.CompressionLevel,
SplittingSize = dialog.SplittingSize,
};
ICompressArchiveModel creator = new CompressArchiveModel(
sources,
directory,
dialog.FileName,
dialog.Password,
dialog.FileFormat,
dialog.CompressionLevel,
dialog.SplittingSize);
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved

await ArchiveHelpers.CompressArchiveAsync(creator);
await CompressHelper.CompressArchiveAsync(creator);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Files.App.Actions
internal sealed class CompressIntoSevenZipAction : BaseCompressArchiveAction
{
public override string Label
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.7z");
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{CompressHelper.DetermineArchiveNameFromSelection(context.SelectedItems)}.7z");

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

public override Task ExecuteAsync()
{
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);

IArchiveCreator creator = new ArchiveCreator
{
Sources = sources,
Directory = directory,
FileName = fileName,
FileFormat = ArchiveFormats.SevenZip,
};
ICompressArchiveModel creator = new CompressArchiveModel(
sources,
directory,
fileName,
fileFormat: ArchiveFormats.SevenZip);

return ArchiveHelpers.CompressArchiveAsync(creator);
return CompressHelper.CompressArchiveAsync(creator);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Files.App.Actions
internal sealed class CompressIntoZipAction : BaseCompressArchiveAction
{
public override string Label
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.zip");
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{CompressHelper.DetermineArchiveNameFromSelection(context.SelectedItems)}.zip");

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

public override Task ExecuteAsync()
{
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage);
var (sources, directory, fileName) = CompressHelper.GetCompressDestination(context.ShellPage);

IArchiveCreator creator = new ArchiveCreator
{
Sources = sources,
Directory = directory,
FileName = fileName,
FileFormat = ArchiveFormats.Zip,
};
ICompressArchiveModel creator = new CompressArchiveModel(
sources,
directory,
fileName,
fileFormat: ArchiveFormats.Zip);

return ArchiveHelpers.CompressArchiveAsync(creator);
return CompressHelper.CompressArchiveAsync(creator);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public virtual HotKey HotKey

public override bool IsExecutable =>
(IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanDecompress(context.SelectedItems) ||
CompressHelper.CanDecompress(context.SelectedItems) ||
CanDecompressInsideArchive()) &&
UIHelpers.CanShowDialog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public DecompressArchive()

public override Task ExecuteAsync()
{
return ArchiveHelpers.DecompressArchiveAsync(context.ShellPage);
return DecompressHelper.DecompressArchiveAsync(context.ShellPage);
}

protected override bool CanDecompressInsideArchive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DecompressArchiveHere()

public override Task ExecuteAsync()
{
return ArchiveHelpers.DecompressArchiveHereAsync(context.ShellPage);
return DecompressHelper.DecompressArchiveHereAsync(context.ShellPage);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DecompressArchiveToChildFolderAction()

public override Task ExecuteAsync()
{
return ArchiveHelpers.DecompressArchiveToChildFolderAsync(context.ShellPage);
return DecompressHelper.DecompressArchiveToChildFolderAsync(context.ShellPage);
}

protected override void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
13 changes: 11 additions & 2 deletions src/Files.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />

<!-- Styles for the custom icons -->
<ResourceDictionary Source="/ResourceDictionaries/PathIcons.xaml" />
<ResourceDictionary Source="/UserControls/SideBar/SideBarControls.xaml" />
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/PathIcons.xaml" />
<ResourceDictionary Source="ms-appx:///UserControls/SideBar/SideBarControls.xaml" />
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/App.Theme.TextBlockStyles.xaml" />
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
Expand All @@ -45,6 +45,9 @@
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SubtleFillColorSecondary}" />

<Color x:Key="App.Theme.FillColorAttention">#0070CB</Color>
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="App.Theme.BackgroundBrush" Color="Transparent" />
Expand All @@ -56,6 +59,9 @@
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SubtleFillColorTertiary}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SubtleFillColorSecondary}" />

<Color x:Key="App.Theme.FillColorAttention">#50C0FF</Color>
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="App.Theme.BackgroundBrush" Color="Transparent" />
Expand All @@ -67,6 +73,9 @@
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="{StaticResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="{StaticResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />

<Color x:Key="App.Theme.FillColorAttention">#50C0FF</Color>
<SolidColorBrush x:Key="App.Theme.FillColorAttentionBrush" Color="{StaticResource App.Theme.FillColorAttention}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
Expand Down
120 changes: 120 additions & 0 deletions src/Files.App/Converters/StatusCenterStateToBrushConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;

namespace Files.App.Converters
{
public class StatusCenterStateToBrushConverter : DependencyObject, IValueConverter
{
public static readonly DependencyProperty InProgressBackgroundBrushProperty =
DependencyProperty.Register(nameof(InProgressBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty InProgressForegroundBrushProperty =
DependencyProperty.Register(nameof(InProgressForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty SuccessfulBackgroundBrushProperty =
DependencyProperty.Register(nameof(SuccessfulBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty SuccessfulForegroundBrushProperty =
DependencyProperty.Register(nameof(SuccessfulForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty ErrorBackgroundBrushProperty =
DependencyProperty.Register(nameof(ErrorBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty ErrorForegroundBrushProperty =
DependencyProperty.Register(nameof(ErrorForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty CanceledBackgroundBrushProperty =
DependencyProperty.Register(nameof(CanceledBackgroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public static readonly DependencyProperty CanceledForegroundBrushProperty =
DependencyProperty.Register(nameof(CanceledForegroundBrush), typeof(SolidColorBrush), typeof(StatusCenterStateToBrushConverter), new PropertyMetadata(null));

public SolidColorBrush InProgressBackgroundBrush
{
get => (SolidColorBrush)GetValue(InProgressBackgroundBrushProperty);
set => SetValue(InProgressBackgroundBrushProperty, value);
}

public SolidColorBrush InProgressForegroundBrush
{
get => (SolidColorBrush)GetValue(InProgressForegroundBrushProperty);
set => SetValue(InProgressForegroundBrushProperty, value);
}

public SolidColorBrush SuccessfulBackgroundBrush
{
get => (SolidColorBrush)GetValue(SuccessfulBackgroundBrushProperty);
set => SetValue(SuccessfulBackgroundBrushProperty, value);
}

public SolidColorBrush SuccessfulForegroundBrush
{
get => (SolidColorBrush)GetValue(SuccessfulForegroundBrushProperty);
set => SetValue(SuccessfulForegroundBrushProperty, value);
}

public SolidColorBrush ErrorBackgroundBrush
{
get => (SolidColorBrush)GetValue(ErrorBackgroundBrushProperty);
set => SetValue(ErrorBackgroundBrushProperty, value);
}

public SolidColorBrush ErrorForegroundBrush
{
get => (SolidColorBrush)GetValue(ErrorForegroundBrushProperty);
set => SetValue(ErrorForegroundBrushProperty, value);
}

public SolidColorBrush CanceledBackgroundBrush
{
get => (SolidColorBrush)GetValue(CanceledBackgroundBrushProperty);
set => SetValue(CanceledBackgroundBrushProperty, value);
}

public SolidColorBrush CanceledForegroundBrush
{
get => (SolidColorBrush)GetValue(CanceledForegroundBrushProperty);
set => SetValue(CanceledForegroundBrushProperty, value);
}

public object? Convert(object value, Type targetType, object parameter, string language)
{
if (value is StatusCenterItemKind state)
{
if (bool.TryParse(parameter?.ToString(), out var isBackground) && isBackground)
{
return state switch
{
StatusCenterItemKind.InProgress => InProgressBackgroundBrush,
StatusCenterItemKind.Successful => SuccessfulBackgroundBrush,
StatusCenterItemKind.Error => ErrorBackgroundBrush,
StatusCenterItemKind.Canceled => CanceledBackgroundBrush,
_ => CanceledBackgroundBrush
};
}
else
{
return state switch
{
StatusCenterItemKind.InProgress => InProgressForegroundBrush,
StatusCenterItemKind.Successful => SuccessfulForegroundBrush,
StatusCenterItemKind.Error => ErrorForegroundBrush,
StatusCenterItemKind.Canceled => CanceledForegroundBrush,
_ => CanceledForegroundBrush
};
}
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
53 changes: 53 additions & 0 deletions src/Files.App/Converters/StatusCenterStateToStateIconConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Shapes;

namespace Files.App.Converters
{
class StatusCenterStateToStateIconConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
if (value is StatusCenterItemIconKind state)
{
var pathMarkup = state switch
{
StatusCenterItemIconKind.Copy => Application.Current.Resources["App.Theme.PathIcon.ActionCopy"] as string,
StatusCenterItemIconKind.Move => Application.Current.Resources["App.Theme.PathIcon.ActionMove"] as string,
StatusCenterItemIconKind.Delete => Application.Current.Resources["App.Theme.PathIcon.ActionDelete"] as string,
StatusCenterItemIconKind.Recycle => Application.Current.Resources["App.Theme.PathIcon.ActionDelete"] as string,
StatusCenterItemIconKind.Extract => Application.Current.Resources["App.Theme.PathIcon.ActionExtract"] as string,
StatusCenterItemIconKind.Compress => Application.Current.Resources["App.Theme.PathIcon.ActionExtract"] as string,
StatusCenterItemIconKind.Successful => Application.Current.Resources["App.Theme.PathIcon.ActionSuccess"] as string,
StatusCenterItemIconKind.Error => Application.Current.Resources["App.Theme.PathIcon.ActionInfo"] as string,
_ => ""
};

string xaml = @$"<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><Path.Data>{pathMarkup}</Path.Data></Path>";

if (XamlReader.Load(xaml) is not Path path)
return null;

// Initialize a new instance
Geometry geometry = path.Data;

// Destroy
path.Data = null;

return geometry;
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
2 changes: 1 addition & 1 deletion src/Files.App/Data/Items/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public string ItemTooltipText
get
{
var tooltipBuilder = new StringBuilder();
tooltipBuilder.AppendLine($"{"ToolTipDescriptionName".GetLocalizedResource()} {Name}");
tooltipBuilder.AppendLine($"{"NameWithColon".GetLocalizedResource()} {Name}");
tooltipBuilder.AppendLine($"{"ItemType".GetLocalizedResource()} {itemType}");
tooltipBuilder.Append($"{"ToolTipDescriptionDate".GetLocalizedResource()} {ItemDateModified}");
if(!string.IsNullOrWhiteSpace(FileSize))
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static string ConvertSizeAbbreviation(this string value)
return value;
}

public static string ToSizeString(this double size) => ByteSize.FromBytes(size).ToSizeString();
public static string ToSizeString(this long size) => ByteSize.FromBytes(size).ToSizeString();
public static string ToSizeString(this ulong size) => ByteSize.FromBytes(size).ToSizeString();
public static string ToSizeString(this ByteSize size) => size.ToBinaryString().ConvertSizeAbbreviation();
Expand Down
Loading