Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a17688b
First (original)
tinodin Oct 27, 2026
53a2425
better
tinodin Oct 27, 2026
e4dadf5
Custom actions
tinodin Oct 27, 2026
7654e03
Merge branch 'main' of G:\GitHub\Other Repositories\DevWinUI into Sta…
tinodin Nov 9, 2026
4583f4d
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 9, 2026
27fd70d
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 9, 2026
5c4d475
Add Size Unit, custom Actions, custom Icons, expose Open for toggling…
tinodin Nov 9, 2026
018305f
Merge branch 'StatusCenter' of https://github.com/tinodin/DevWinUI in…
tinodin Nov 9, 2026
ff82649
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 9, 2026
23e7c6e
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 9, 2026
e63f3a2
Improve examples
tinodin Nov 10, 2026
f5ac49e
Add Pause / Resume
tinodin Nov 11, 2026
3b78cef
Fix Theme switching
tinodin Nov 11, 2026
5b46bfd
Update sample code
tinodin Nov 11, 2026
67c9987
Add doc page
tinodin Nov 11, 2026
3b2d187
Replace IconSourceElement with ContentControl to fix crashes when the…
tinodin Nov 12, 2026
a2e0846
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 12, 2026
a9421fe
Remove ByteSize package and use FileHelper.cs
tinodin Nov 14, 2026
3b5603d
Remove unused StatusCenterStyles merge from StatusCenterButton
tinodin Nov 14, 2026
94259f9
Remove CsWinRT by removing DynamicWindowsRuntimeCast
tinodin Nov 14, 2026
1118ce2
Merge branch 'StatusCenter' of https://github.com/tinodin/DevWinUI in…
tinodin Nov 14, 2026
3bd82d4
Remove CommunityToolkit.WinUI.Converters and make StatusCenterStateTo…
tinodin Nov 14, 2026
6bf6058
Remove unused CustomProgressBarStyle
tinodin Nov 14, 2026
cac147f
Remove CommunityToolkit.WinUI.Triggers and use IsEqualStateTrigger
tinodin Nov 14, 2026
ad8cda4
Refactor StatusCenter into a reusable templated control
tinodin Nov 15, 2026
80bbac5
Update StatusCenterPage_cs.txt
tinodin Nov 15, 2026
c956bc3
Make IconElement Internal
tinodin Nov 16, 2026
2d02ce3
Update SpeedGraph2.cs
tinodin Nov 16, 2026
933886d
Give each StatusCenter instance its own item store
tinodin Nov 16, 2026
eb08232
Aggregate taskbar progress between multiple StatusCenter instances
tinodin Nov 16, 2026
d0e7853
Make StatusCenterButton also a templated control
tinodin Nov 16, 2026
9dce5fb
Remove CommunityToolkit.Mvvm
tinodin Nov 16, 2026
2b27cf2
Make size unit format a per-control SizeUnitFormat property
tinodin Nov 16, 2026
1b8e6c6
Merge branch 'ghost1372:main' into StatusCenter
tinodin Nov 16, 2026
428df5d
Update to new ControlExample
tinodin Nov 16, 2026
4ff96c1
Move StatusCenterButton to the left side
tinodin Nov 16, 2026
1275e67
Support custom icon for StatusCenterButton
tinodin Nov 19, 2026
483b275
Use ChoiceOption
tinodin Nov 20, 2026
4c30a98
Group options
tinodin Nov 20, 2026
3124393
Add partial
tinodin Nov 20, 2026
942fec6
Use existing converters
tinodin Nov 20, 2026
b9dbf0b
Add partial
tinodin Nov 20, 2026
19f16be
Use Default key in theme dictionary
tinodin Nov 20, 2026
8dae918
Consolidate all styles into StatusCenterStyles.xaml
tinodin Nov 20, 2026
b1d89cc
Add DefaultStatusCenterStyle and DefaultStatusCenterButtonStyle
tinodin Nov 20, 2026
8b14cbc
Remove unnecessary Grid and HorizontalAlignment="Left"
tinodin Nov 20, 2026
dfdcb08
Restore Light and Dark theme dictionaries
tinodin Nov 20, 2026
82f0421
Use GetGeometryFromString
tinodin Nov 21, 2026
60e44b3
Move ThemeDictionaries to the top
tinodin Nov 21, 2026
10156ed
Merge branch 'main' into StatusCenter
ghost1372 Nov 21, 2026
b0438e0
Update Generic.xaml
ghost1372 Nov 21, 2026
28800d5
Update StatusCenterButton.xaml.cs
ghost1372 Nov 21, 2026
5a91ae2
Update StatusCenterStyles.xaml
ghost1372 Nov 21, 2026
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
31 changes: 16 additions & 15 deletions dev/DevWinUI.Base/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,33 @@ public static string GetValidFileName(string fileName, string reservedNameFormat
return s;
}

private static readonly string[] DecimalSizeSuffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
private static readonly string[] BinarySizeSuffixes = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];

/// <summary>
/// Converts a file size in bytes to a human-readable format with appropriate units.
/// </summary>
/// <param name="size">The input value represents the size in bytes to be converted.</param>
/// <param name="useBinaryUnits">The input value indicates whether binary units (1 KiB = 1024 B) are used instead of decimal units (1 KB = 1000 B).</param>
/// <returns>A formatted string that displays the size along with the appropriate unit.</returns>
public static string GetFileSize(long size)
public static string GetFileSize(long size, bool useBinaryUnits = false)
{
string[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
const string formatTemplate = "{0}{1:0.#} {2}";
var sizeSuffixes = useBinaryUnits ? BinarySizeSuffixes : DecimalSizeSuffixes;
var divisor = useBinaryUnits ? 1024d : 1000d;
var isNegative = size < 0;

var normSize = isNegative ? -(double)size : size;
var iUnit = 0;

if (size == 0)
while (normSize >= divisor && iUnit < sizeSuffixes.Length - 1)
{
return string.Format(formatTemplate, null, 0, sizeSuffixes[0]);
normSize /= divisor;
iUnit++;
}

var absSize = Math.Abs((double)size);
var fpPower = Math.Log(absSize, 1000);
var intPower = (int)fpPower;
var iUnit = intPower >= sizeSuffixes.Length
? sizeSuffixes.Length - 1
: intPower;
var normSize = absSize / Math.Pow(1000, iUnit);

return string.Format(
formatTemplate,
size < 0 ? "-" : null, normSize, sizeSuffixes[iUnit]);
"{0}{1:0.##} {2}",
isNegative ? "-" : null, normSize, sizeSuffixes[iUnit]);
}

/// <summary>
Expand Down
7 changes: 7 additions & 0 deletions dev/DevWinUI.Gallery/Assets/NavViewMenu/AppData.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,13 @@
"Subtitle": "Displays audio level and frequency data.",
"ImagePath": "ms-appx:///Assets/Fluent/AudioWave2.png"
},
{
"UniqueId": "DevWinUIGallery.Views.StatusCenterPage",
"Title": "Status Center",
"Subtitle": "A status center that tracks the progress of operations, from long-running tasks with detailed progress to quick status notifications.",
"IsNew": true,
"ImagePath": "ms-appx:///Assets/Fluent/ProgressRing.png"
},
{
"UniqueId": "DevWinUIGallery.Views.WaveformTimelinePage",
"Title": "Waveform Timeline",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
private async void Copy_Click(object sender, RoutedEventArgs e)
{
var fileCount = Random.Shared.Next(3, 9);
string[] source = FilePaths(@"C:\Users\Public\Documents", fileCount);
string[] destination = FilePaths(@"C:\Users\Public\Downloads", fileCount);
var totalSize = fileCount * Random.Shared.NextInt64(24, 97) * 1024 * 1024;
var banner = AddCard_Copy(StatusCenterButtonSample, ReturnResult.InProgress, source, destination, 0, totalSize);

var result = await SimulateFileOperationAsync(banner.ProgressEventSource, source, totalSize, banner.CancellationToken, banner);

StatusCenterButtonSample.RemoveItem(banner);
AddCard_Copy(StatusCenterButtonSample, result, source, destination, banner.TotalItemsCount, totalSize);
}

private StatusCenterItem AddCard_Copy(StatusCenterButton statusCenterButton,
ReturnResult returnStatus,
string[] source,
string[] destination,
long itemsCount = 0,
long totalSize = 0)
{
var sourcePath = GetParentDir(source.FirstOrDefault());
var destinationPath = GetParentDir(destination.FirstOrDefault());
var destinationDirName = destinationPath.Split('\\').Last();

string ItemsText(long count) => count == 1 ? "1 item" : $"{count} items";

string Header(long count) => returnStatus switch
{
ReturnResult.Cancelled => $"Canceled copying {ItemsText(count)} to \"{destinationDirName}\"",
ReturnResult.Success => $"Copied {ItemsText(count)} to \"{destinationDirName}\"",
ReturnResult.Failed => $"Error copying {ItemsText(count)} to \"{destinationDirName}\"",
_ => $"Copying {ItemsText(count)} to \"{destinationDirName}\""
};

string SubHeader(long count) => returnStatus switch
{
ReturnResult.Cancelled => $"Canceled copying {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
ReturnResult.Success => $"Copied {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
ReturnResult.Failed => $"Failed to copy {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
_ => $"Copying {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\""
};

string Message(StatusCenterItemProgressModel progress)
=> progress.Percentage is null
? progress.EnumerationCompleted ? "Processing items..." : "Discovering items..."
: $"{progress.ProcessedSize.ToSizeString(statusCenterButton.SizeUnitFormat)} of {progress.TotalSize.ToSizeString(statusCenterButton.SizeUnitFormat)} processed";

var card = statusCenterButton.AddCard(
returnStatus,
Header(itemsCount),
SubHeader(itemsCount),
"Discovering items...",
StatusCenterItemIconKind.Copy,
itemsCount: itemsCount,
totalSize: totalSize,
update: (item, progress) => progress.EnumerationCompleted
? (Header(item.TotalItemsCount), SubHeader(item.TotalItemsCount), Message(progress))
: ($"Discovered {ItemsText(item.TotalItemsCount)}", SubHeader(item.TotalItemsCount), Message(progress)));

if (returnStatus is ReturnResult.InProgress)
card.IsPausable = true;

return card;
}

private static async Task<ReturnResult> SimulateFileOperationAsync(
IProgress<StatusCenterItemProgressModel> progress,
string[] source,
long totalSize,
CancellationToken cancellationToken,
StatusCenterItem item,
bool simulateDiscovery = true)
{
var itemTotal = simulateDiscovery ? Random.Shared.Next(1, 26) : source.Length;
var progressModel = new StatusCenterItemProgressModel(
progress,
enumerationCompleted: !simulateDiscovery,
status: ReturnResult.InProgress,
itemsCount: simulateDiscovery ? 0 : itemTotal);

if (!simulateDiscovery)
{
progressModel.TotalSize = totalSize;
progressModel.Report();
}

var pauseDelay = PauseAwareDelay(item);

try
{
if (simulateDiscovery)
{
for (var discovered = 1; discovered <= itemTotal; discovered++)
{
await pauseDelay(Random.Shared.Next(120, 220), cancellationToken);
progressModel.ItemsCount = discovered;
progressModel.Report();
}
}

progressModel.TotalSize = totalSize;
progressModel.ItemsCount = itemTotal;
progressModel.EnumerationCompleted = true;
progressModel.Report();

await pauseDelay(Random.Shared.Next(50, 500), cancellationToken);
progressModel.Report(0);

var failAtPercentage = Random.Shared.Next(0, 100) < 20 ? Random.Shared.Next(40, 85) : double.MaxValue;
var percentage = 0.0;

while (percentage < 100)
{
var delay = Random.Shared.Next(100, 140);
if (Random.Shared.Next(0, 15) == 0)
delay += Random.Shared.Next(150, 300);

await pauseDelay(delay, cancellationToken);

percentage = Math.Min(100, percentage + Random.Shared.Next(2, 5));

var processedItems = Math.Min(itemTotal, (int)Math.Ceiling(itemTotal * percentage / 100));
var pendingItems = processedItems - progressModel.ProcessedItemsCount;

if (pendingItems > 0)
progressModel.AddProcessedItemsCount(pendingItems);

if (processedItems > 0)
progressModel.FileName = Path.GetFileName(source[(processedItems - 1) % source.Length]);

progressModel.Report(percentage);

if (percentage >= failAtPercentage && percentage < 100)
return ReturnResult.Failed;
}

return ReturnResult.Success;
}
catch (OperationCanceledException)
{
await Task.Delay(Random.Shared.Next(50, 500), CancellationToken.None);
return ReturnResult.Cancelled;
}
}

private static Func<int, CancellationToken, Task> PauseAwareDelay(StatusCenterItem item)
{
var resumeSignal = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
item.OnPauseAsync = () =>
{
resumeSignal = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
return Task.CompletedTask;
};
item.OnResumeAsync = () =>
{
resumeSignal.TrySetResult();
return Task.CompletedTask;
};

return async (millisecondsDelay, cancellationToken) =>
{
while (item.IsPaused)
await resumeSignal.Task.WaitAsync(cancellationToken);

await Task.Delay(millisecondsDelay, cancellationToken);
};
}

private static string[] FilePaths(string directory, int count)
=> [.. Enumerable.Range(1, count).Select(i => $@"{directory}\File {i}.txt")];

private static string GetParentDir(string? path)
{
if (string.IsNullOrEmpty(path))
return string.Empty;

var index = path.Contains('/', StringComparison.Ordinal) ? path.LastIndexOf('/') : path.LastIndexOf('\\');
return path[..(index != -1 ? index : path.Length)];
}
48 changes: 48 additions & 0 deletions dev/DevWinUI.Gallery/Views/Pages/Features/StatusCenterPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page x:Class="DevWinUIGallery.Views.StatusCenterPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:local="using:DevWinUIGallery"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives"
mc:Ignorable="d">

<ScrollViewer>
<StackPanel Margin="10" dev:PanelAttach.ChildrenTransitions="Default" Spacing="10">
<local:ControlExample Title="Status center" CSharp="Features/StatusCenterPage_cs.txt" Doc="controls/statusCenter">
<local:ControlExample.XamlCode>
<x:String>&lt;dev:StatusCenterButton x:Name="StatusCenterButtonSample" /&gt;</x:String>
</local:ControlExample.XamlCode>
<local:ControlExample.OptionGroups>
<local:OptionGroup Title="Operations">
<local:OptionPanel>
<Button Click="Copy_Click" Content="Copy" />
<Button Click="Move_Click" Content="Move" />
<Button Click="Delete_Click" Content="Delete" />
<Button Click="Recycle_Click" Content="Recycle" />
<Button Click="Compress_Click" Content="Compress" />
<Button Click="Extract_Click" Content="Extract" />
<Button Click="InstallFont_Click" Content="Install font" />
<Button Click="EmptyRecycleBin_Click" Content="Recycle bin" />
<Button Click="GitClone_Click" Content="Git clone" />
<Button Click="GitFetch_Click" Content="Git fetch" />
<Button Click="GitPull_Click" Content="Git pull" />
<Button Click="GitPush_Click" Content="Git push" />
<Button Click="GitSync_Click" Content="Git sync" />
<Button Click="GitCheckout_Click" Content="Git checkout" />
</local:OptionPanel>
</local:OptionGroup>
<local:OptionGroup Title="Display">
<local:OptionPanel>
<local:ChoiceOption x:Name="CmbFlyoutPlacement" Header="Flyout placement" Value="{x:Bind primitives:FlyoutPlacementMode.RightEdgeAlignedTop}" />
<local:ChoiceOption x:Name="CmbSizeUnit" Header="Size unit" Value="{x:Bind dev:SizeUnitTypes.BinaryUnits}" />
</local:OptionPanel>
</local:OptionGroup>
</local:ControlExample.OptionGroups>
<dev:StatusCenterButton x:Name="StatusCenterButtonSample" VerticalAlignment="Top" FlyoutPlacement="{x:Bind ((primitives:FlyoutPlacementMode)CmbFlyoutPlacement.Value), Mode=OneWay}" SizeUnitFormat="{x:Bind ((dev:SizeUnitTypes)CmbSizeUnit.Value), Mode=OneWay}" />
</local:ControlExample>
</StackPanel>
</ScrollViewer>
</Page>
Loading