Skip to content

Commit 5e3e6d6

Browse files
committed
feat: add Windows toast notifications for completed scans and scheduled cleaning runs
1 parent 3145e8d commit 5e3e6d6

6 files changed

Lines changed: 43 additions & 4 deletions

File tree

src/DeepPurge.App/DeepPurge.App.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net8.0-windows</TargetFramework>
5+
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
66
<UseWPF>true</UseWPF>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>

src/DeepPurge.Cli/DeepPurge.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0-windows</TargetFramework>
5+
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<RootNamespace>DeepPurge.Cli</RootNamespace>

src/DeepPurge.Cli/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ private static async Task<int> CmdCleanAsync(ParsedArgs a, CancellationToken ct)
157157
total += freed;
158158
}
159159
Console.WriteLine($"Total: {FormatBytes(total)} {(dryRun ? "(dry-run)" : "")}");
160+
if (!dryRun && total > 0)
161+
DeepPurge.Core.Diagnostics.ToastNotifier.ShowCleaningSummary("Scheduled Clean", total, categories.Count, dryRun);
160162
return 0;
161163
}
162164

src/DeepPurge.Core/DeepPurge.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0-windows</TargetFramework>
4+
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
55
<UseWPF>true</UseWPF>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
@@ -31,6 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34+
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
3435
<PackageReference Include="System.Management" Version="8.0.0" />
3536
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.1" />
3637
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.Toolkit.Uwp.Notifications;
2+
3+
namespace DeepPurge.Core.Diagnostics;
4+
5+
public static class ToastNotifier
6+
{
7+
public static void Show(string title, string body)
8+
{
9+
try
10+
{
11+
new ToastContentBuilder()
12+
.AddText(title)
13+
.AddText(body)
14+
.Show();
15+
}
16+
catch (Exception ex)
17+
{
18+
Log.Warn($"Toast notification failed: {ex.Message}");
19+
}
20+
}
21+
22+
public static void ShowCleaningSummary(string operation, long bytesFreed, int itemCount, bool dryRun)
23+
{
24+
var prefix = dryRun ? "[Dry Run] " : "";
25+
var freed = bytesFreed > 0 ? $" — freed {FormatBytes(bytesFreed)}" : "";
26+
Show($"{prefix}DeepPurge: {operation}", $"{itemCount} items processed{freed}");
27+
}
28+
29+
private static string FormatBytes(long bytes)
30+
{
31+
string[] u = { "B", "KB", "MB", "GB", "TB" };
32+
double b = bytes; int i = 0;
33+
while (b >= 1024 && i < u.Length - 1) { b /= 1024; i++; }
34+
return $"{b:F1} {u[i]}";
35+
}
36+
}

tests/DeepPurge.Tests/DeepPurge.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0-windows</TargetFramework>
4+
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<IsPackable>false</IsPackable>

0 commit comments

Comments
 (0)