Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

feat: add disk cleanup page and its features

itsfatduckef36e3a9da57
diff --git a/optimizerDuck/App.xaml.cs b/optimizerDuck/App.xaml.cs
index b73686a..6f9de62 100644
--- a/optimizerDuck/App.xaml.cs
+++ b/optimizerDuck/App.xaml.cs
@@ -158,6 +158,9 @@ public partial class App : Application
services.AddSingleton<BloatwareViewModel>();
services.AddSingleton<BloatwarePage>();
+ services.AddSingleton<DiskCleanupViewModel>();
+ services.AddSingleton<DiskCleanupPage>();
+
// Optimizations
services.AddAllOptimizationPages();
@@ -169,6 +172,7 @@ public partial class App : Application
services.AddSingleton<OptimizationRegistry>();
services.AddSingleton<OptimizationService>();
services.AddSingleton<BloatwareService>();
+ services.AddSingleton<DiskCleanupService>();
services.AddSingleton<SystemInfoService>();
services.AddSingleton<StreamService>();
services.AddSingleton<UpdaterService>();
diff --git a/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs b/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs
new file mode 100644
index 0000000..af090a8
--- /dev/null
+++ b/optimizerDuck/Core/Models/Cleanup/CleanupItem.cs
@@ -0,0 +1,39 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using Wpf.Ui.Controls;
+
+namespace optimizerDuck.Core.Models.Cleanup;
+
+public partial class CleanupItem : ObservableObject
+{
+ public required string Id { get; init; }
+ public required string Name { get; init; }
+ public required string Description { get; init; }
+ public required string Path { get; init; }
+ public required SymbolRegular Icon { get; init; }
+
+ /// <summary>
+ /// Whether this item uses a PowerShell command instead of a file path.
+ /// </summary>
+ public bool IsCommand { get; init; }
+
+ [ObservableProperty] private long _sizeBytes;
+ [ObservableProperty] private bool _isSelected = true;
+ [ObservableProperty] private bool _isScanning;
+ [ObservableProperty] private bool _isCleaning;
+ [ObservableProperty] private bool _isScanned;
+
+ public string FormattedSize => FormatBytes(SizeBytes);
+
+ partial void OnSizeBytesChanged(long value) => OnPropertyChanged(nameof(FormattedSize));
+
+ public static string FormatBytes(long bytes)
+ {
+ return bytes switch
+ {
+ < 1024 => $"{bytes} B",
+ < 1024 * 1024 => $"{bytes / 1024.0:F1} KB",
+ < 1024 * 1024 * 1024 => $"{bytes / (1024.0 * 1024.0):F1} MB",
+ _ => $"{bytes / (1024.0 * 1024.0 * 1024.0):F2} GB"
+ };
+ }
+}
diff --git a/optimizerDuck/Resources/Languages/Translations.Designer.cs b/optimizerDuck/Resources/Languages/Translations.Designer.cs
index a380464..812de7f 100644
--- a/optimizerDuck/Resources/Languages/Translations.Designer.cs
+++ b/optimizerDuck/Resources/Languages/Translations.Designer.cs
@@ -2765,5 +2765,248 @@ namespace optimizerDuck.Resources.Languages {
return ResourceManager.GetString("Snackbar.OpenLinkFailed.Title", resourceCulture);
}
}
+
+ /// <summary>
+ /// Looks up a localized string similar to Disk Cleanup.
+ /// </summary>
+ public static string Sidebar_DiskCleanup {
+ get {
+ return ResourceManager.GetString("Sidebar.DiskCleanup", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Disk Cleanup.
+ /// </summary>
+ public static string DiskCleanup_Header_Title {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Header.Title", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Free up disk space by removing temporary files and cache.
+ /// </summary>
+ public static string DiskCleanup_Header_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Header.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Total reclaimable space.
+ /// </summary>
+ public static string DiskCleanup_TotalSpace {
+ get {
+ return ResourceManager.GetString("DiskCleanup.TotalSpace", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Scan.
+ /// </summary>
+ public static string DiskCleanup_Button_Scan {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Button.Scan", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Select All.
+ /// </summary>
+ public static string DiskCleanup_Button_SelectAll {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Button.SelectAll", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Deselect All.
+ /// </summary>
+ public static string DiskCleanup_Button_DeselectAll {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Button.DeselectAll", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Scanning....
+ /// </summary>
+ public static string DiskCleanup_Scanning {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Scanning", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Loading cleanup items....
+ /// </summary>
+ public static string DiskCleanup_Loading {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Loading", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Cleanup Complete.
+ /// </summary>
+ public static string DiskCleanup_Complete_Title {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Complete.Title", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Successfully freed {0} of disk space.
+ /// </summary>
+ public static string DiskCleanup_Complete_Message {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Complete.Message", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Cleanup Error.
+ /// </summary>
+ public static string DiskCleanup_Error_Title {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Error.Title", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Some files could not be deleted. They may be in use by another process..
+ /// </summary>
+ public static string DiskCleanup_Error_Message {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Error.Message", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Temporary Files.
+ /// </summary>
+ public static string DiskCleanup_Item_TempFiles {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.TempFiles", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to User temporary files created by applications.
+ /// </summary>
+ public static string DiskCleanup_Item_TempFiles_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.TempFiles.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to System Temp Files.
+ /// </summary>
+ public static string DiskCleanup_Item_SystemTemp {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.SystemTemp", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Windows system temporary files.
+ /// </summary>
+ public static string DiskCleanup_Item_SystemTemp_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.SystemTemp.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Windows Update Cache.
+ /// </summary>
+ public static string DiskCleanup_Item_WindowsUpdate {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.WindowsUpdate", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Downloaded Windows Update files that are no longer needed.
+ /// </summary>
+ public static string DiskCleanup_Item_WindowsUpdate_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.WindowsUpdate.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Prefetch Files.
+ /// </summary>
+ public static string DiskCleanup_Item_Prefetch {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.Prefetch", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Application prefetch data used to speed up loading.
+ /// </summary>
+ public static string DiskCleanup_Item_Prefetch_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.Prefetch.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Thumbnail Cache.
+ /// </summary>
+ public static string DiskCleanup_Item_Thumbnails {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.Thumbnails", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Cached thumbnail images for Explorer file previews.
+ /// </summary>
+ public static string DiskCleanup_Item_Thumbnails_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.Thumbnails.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Recycle Bin.
+ /// </summary>
+ public static string DiskCleanup_Item_RecycleBin {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.RecycleBin", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Deleted files still stored in the Recycle Bin.
+ /// </summary>
+ public static string DiskCleanup_Item_RecycleBin_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.RecycleBin.Description", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Error Reports.
+ /// </summary>
+ public static string DiskCleanup_Item_ErrorReports {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.ErrorReports", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Windows error reports and crash dump files.
+ /// </summary>
+ public static string DiskCleanup_Item_ErrorReports_Description {
+ get {
+ return ResourceManager.GetString("DiskCleanup.Item.ErrorReports.Description", resourceCulture);
+ }
+ }
}
}
diff --git a/optimizerDuck/Resources/Languages/Translations.resx b/optimizerDuck/Resources/Languages/Translations.resx
index c8e6f1a..2faec22 100644
--- a/optimizerDuck/Resources/Languages/Translations.resx
+++ b/optimizerDuck/Resources/Languages/Translations.resx
@@ -1024,4 +1024,85 @@ Update now to enjoy the latest features, improvements, and bug fixes.</value>
<data name="Common.SortBy" xml:space="preserve">
<value>Sort by</value>
</data>
+ <data name="Sidebar.DiskCleanup" xml:space="preserve">
+ <value>Disk Cleanup</value>
+ </data>
+ <data name="DiskCleanup.Header.Title" xml:space="preserve">
+ <value>Disk Cleanup</value>
+ </data>
+ <data name="DiskCleanup.Header.Description" xml:space="preserve">
+ <value>Free up disk space by removing temporary files and cache</value>
+ </data>
+ <data name="DiskCleanup.TotalSpace" xml:space="preserve">
+ <value>Total reclaimable space</value>
+ </data>
+ <data name="DiskCleanup.Button.Scan" xml:space="preserve">
+ <value>Scan</value>
+ </data>
+ <data name="DiskCleanup.Button.SelectAll" xml:space="preserve">
+ <value>Select All</value>
+ </data>
+ <data name="DiskCleanup.Button.DeselectAll" xml:space="preserve">
+ <value>Deselect All</value>
+ </data>
+ <data name="DiskCleanup.Scanning" xml:space="preserve">
+ <value>Scanning...</value>
+ </data>
+ <data name="DiskCleanup.Loading" xml:space="preserve">
+ <value>Loading cleanup items...</value>
+ </data>
+ <data name="DiskCleanup.Complete.Title" xml:space="preserve">
+ <value>Cleanup Complete</value>
+ </data>
+ <data name="DiskCleanup.Complete.Message" xml:space="preserve">
+ <value>Successfully freed {0} of disk space</value>
+ </data>
+ <data name="DiskCleanup.Error.Title" xml:space="preserve">
+ <value>Cleanup Error</value>
+ </data>
+ <data name="DiskCleanup.Error.Message" xml:space="preserve">
+ <value>Some files could not be deleted. They may be in use by another process.</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles" xml:space="preserve">
+ <value>Temporary Files</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles.Description" xml:space="preserve">
+ <value>User temporary files created by applications</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp" xml:space="preserve">
+ <value>System Temp Files</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp.Description" xml:space="preserve">
+ <value>Windows system temporary files</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate" xml:space="preserve">
+ <value>Windows Update Cache</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate.Description" xml:space="preserve">
+ <value>Downloaded Windows Update files that are no longer needed</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch" xml:space="preserve">
+ <value>Prefetch Files</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch.Description" xml:space="preserve">
+ <value>Application prefetch data used to speed up loading</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails" xml:space="preserve">
+ <value>Thumbnail Cache</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails.Description" xml:space="preserve">
+ <value>Cached thumbnail images for Explorer file previews</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin" xml:space="preserve">
+ <value>Recycle Bin</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin.Description" xml:space="preserve">
+ <value>Deleted files still stored in the Recycle Bin</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports" xml:space="preserve">
+ <value>Error Reports</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports.Description" xml:space="preserve">
+ <value>Windows error reports and crash dump files</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/optimizerDuck/Resources/Languages/Translations.ru-RU.resx b/optimizerDuck/Resources/Languages/Translations.ru-RU.resx
index 9396492..3b48ecf 100644
--- a/optimizerDuck/Resources/Languages/Translations.ru-RU.resx
+++ b/optimizerDuck/Resources/Languages/Translations.ru-RU.resx
@@ -1024,4 +1024,85 @@
<data name="Common.SortBy" xml:space="preserve">
<value>Сортировать по</value>
</data>
+ <data name="Sidebar.DiskCleanup" xml:space="preserve">
+ <value>Очистка диска</value>
+ </data>
+ <data name="DiskCleanup.Header.Title" xml:space="preserve">
+ <value>Очистка диска</value>
+ </data>
+ <data name="DiskCleanup.Header.Description" xml:space="preserve">
+ <value>Освободите место на диске, удалив временные файлы и кеш</value>
+ </data>
+ <data name="DiskCleanup.TotalSpace" xml:space="preserve">
+ <value>Общий объём для освобождения</value>
+ </data>
+ <data name="DiskCleanup.Button.Scan" xml:space="preserve">
+ <value>Сканировать</value>
+ </data>
+ <data name="DiskCleanup.Button.SelectAll" xml:space="preserve">
+ <value>Выбрать всё</value>
+ </data>
+ <data name="DiskCleanup.Button.DeselectAll" xml:space="preserve">
+ <value>Снять выделение</value>
+ </data>
+ <data name="DiskCleanup.Scanning" xml:space="preserve">
+ <value>Сканирование...</value>
+ </data>
+ <data name="DiskCleanup.Loading" xml:space="preserve">
+ <value>Загрузка элементов очистки...</value>
+ </data>
+ <data name="DiskCleanup.Complete.Title" xml:space="preserve">
+ <value>Очистка завершена</value>
+ </data>
+ <data name="DiskCleanup.Complete.Message" xml:space="preserve">
+ <value>Успешно освобождено {0} дискового пространства</value>
+ </data>
+ <data name="DiskCleanup.Error.Title" xml:space="preserve">
+ <value>Ошибка очистки</value>
+ </data>
+ <data name="DiskCleanup.Error.Message" xml:space="preserve">
+ <value>Некоторые файлы не удалось удалить. Возможно, они используются другим процессом.</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles" xml:space="preserve">
+ <value>Временные файлы</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles.Description" xml:space="preserve">
+ <value>Пользовательские временные файлы, созданные приложениями</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp" xml:space="preserve">
+ <value>Системные временные файлы</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp.Description" xml:space="preserve">
+ <value>Временные файлы системы Windows</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate" xml:space="preserve">
+ <value>Кеш обновлений Windows</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate.Description" xml:space="preserve">
+ <value>Загруженные файлы обновлений Windows, которые больше не нужны</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch" xml:space="preserve">
+ <value>Файлы предварительной загрузки</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch.Description" xml:space="preserve">
+ <value>Данные предварительной загрузки для ускорения запуска приложений</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails" xml:space="preserve">
+ <value>Кеш эскизов</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails.Description" xml:space="preserve">
+ <value>Кешированные эскизы для предпросмотра файлов в Проводнике</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin" xml:space="preserve">
+ <value>Корзина</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin.Description" xml:space="preserve">
+ <value>Удалённые файлы, хранящиеся в Корзине</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports" xml:space="preserve">
+ <value>Отчёты об ошибках</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports.Description" xml:space="preserve">
+ <value>Отчёты об ошибках Windows и файлы аварийных дампов</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx b/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
index f8a58b0..ab965d1 100644
--- a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
+++ b/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
@@ -1024,4 +1024,85 @@ Cập nhật ngay để trải nghiệm các tính năng mới, cải tiến và
<data name="Common.SortBy" xml:space="preserve">
<value>Sắp xếp theo</value>
</data>
+ <data name="Sidebar.DiskCleanup" xml:space="preserve">
+ <value>Dọn ổ đĩa</value>
+ </data>
+ <data name="DiskCleanup.Header.Title" xml:space="preserve">
+ <value>Dọn ổ đĩa</value>
+ </data>
+ <data name="DiskCleanup.Header.Description" xml:space="preserve">
+ <value>Giải phóng dung lượng ổ đĩa bằng cách xóa các tệp tạm và bộ nhớ đệm</value>
+ </data>
+ <data name="DiskCleanup.TotalSpace" xml:space="preserve">
+ <value>Tổng dung lượng có thể giải phóng</value>
+ </data>
+ <data name="DiskCleanup.Button.Scan" xml:space="preserve">
+ <value>Quét</value>
+ </data>
+ <data name="DiskCleanup.Button.SelectAll" xml:space="preserve">
+ <value>Chọn tất cả</value>
+ </data>
+ <data name="DiskCleanup.Button.DeselectAll" xml:space="preserve">
+ <value>Bỏ chọn tất cả</value>
+ </data>
+ <data name="DiskCleanup.Scanning" xml:space="preserve">
+ <value>Đang quét...</value>
+ </data>
+ <data name="DiskCleanup.Loading" xml:space="preserve">
+ <value>Đang tải danh sách dọn dẹp...</value>
+ </data>
+ <data name="DiskCleanup.Complete.Title" xml:space="preserve">
+ <value>Dọn dẹp hoàn tất</value>
+ </data>
+ <data name="DiskCleanup.Complete.Message" xml:space="preserve">
+ <value>Đã giải phóng {0} dung lượng ổ đĩa</value>
+ </data>
+ <data name="DiskCleanup.Error.Title" xml:space="preserve">
+ <value>Lỗi dọn dẹp</value>
+ </data>
+ <data name="DiskCleanup.Error.Message" xml:space="preserve">
+ <value>Một số tệp không thể xóa. Chúng có thể đang được sử dụng bởi chương trình khác.</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles" xml:space="preserve">
+ <value>Tệp tạm thời</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles.Description" xml:space="preserve">
+ <value>Tệp tạm thời của người dùng được tạo bởi các ứng dụng</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp" xml:space="preserve">
+ <value>Tệp tạm hệ thống</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp.Description" xml:space="preserve">
+ <value>Tệp tạm thời của hệ thống Windows</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate" xml:space="preserve">
+ <value>Bộ nhớ đệm Windows Update</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate.Description" xml:space="preserve">
+ <value>Tệp cập nhật Windows đã tải về không còn cần thiết</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch" xml:space="preserve">
+ <value>Tệp Prefetch</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch.Description" xml:space="preserve">
+ <value>Dữ liệu prefetch giúp tăng tốc khởi chạy ứng dụng</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails" xml:space="preserve">
+ <value>Bộ nhớ đệm hình thu nhỏ</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails.Description" xml:space="preserve">
+ <value>Hình thu nhỏ được lưu trong bộ nhớ đệm cho Explorer</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin" xml:space="preserve">
+ <value>Thùng rác</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin.Description" xml:space="preserve">
+ <value>Các tệp đã xóa vẫn còn trong Thùng rác</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports" xml:space="preserve">
+ <value>Báo cáo lỗi</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports.Description" xml:space="preserve">
+ <value>Báo cáo lỗi Windows và tệp crash dump</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/optimizerDuck/Resources/Languages/Translations.zh-Hans.resx b/optimizerDuck/Resources/Languages/Translations.zh-Hans.resx
index ac37c43..286ae5d 100644
--- a/optimizerDuck/Resources/Languages/Translations.zh-Hans.resx
+++ b/optimizerDuck/Resources/Languages/Translations.zh-Hans.resx
@@ -970,5 +970,86 @@
<data name="Bloatware.Search.NoResults" xml:space="preserve">
<value>未找到结果。请尝试其他搜索词或筛选条件。</value>
</data>
+ <data name="Sidebar.DiskCleanup" xml:space="preserve">
+ <value>磁盘清理</value>
+ </data>
+ <data name="DiskCleanup.Header.Title" xml:space="preserve">
+ <value>磁盘清理</value>
+ </data>
+ <data name="DiskCleanup.Header.Description" xml:space="preserve">
+ <value>通过删除临时文件和缓存来释放磁盘空间</value>
+ </data>
+ <data name="DiskCleanup.TotalSpace" xml:space="preserve">
+ <value>可回收的总空间</value>
+ </data>
+ <data name="DiskCleanup.Button.Scan" xml:space="preserve">
+ <value>扫描</value>
+ </data>
+ <data name="DiskCleanup.Button.SelectAll" xml:space="preserve">
+ <value>全选</value>
+ </data>
+ <data name="DiskCleanup.Button.DeselectAll" xml:space="preserve">
+ <value>取消全选</value>
+ </data>
+ <data name="DiskCleanup.Scanning" xml:space="preserve">
+ <value>正在扫描...</value>
+ </data>
+ <data name="DiskCleanup.Loading" xml:space="preserve">
+ <value>正在加载清理项目...</value>
+ </data>
+ <data name="DiskCleanup.Complete.Title" xml:space="preserve">
+ <value>清理完成</value>
+ </data>
+ <data name="DiskCleanup.Complete.Message" xml:space="preserve">
+ <value>成功释放了 {0} 的磁盘空间</value>
+ </data>
+ <data name="DiskCleanup.Error.Title" xml:space="preserve">
+ <value>清理错误</value>
+ </data>
+ <data name="DiskCleanup.Error.Message" xml:space="preserve">
+ <value>部分文件无法删除,可能正在被其他程序使用。</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles" xml:space="preserve">
+ <value>临时文件</value>
+ </data>
+ <data name="DiskCleanup.Item.TempFiles.Description" xml:space="preserve">
+ <value>应用程序创建的用户临时文件</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp" xml:space="preserve">
+ <value>系统临时文件</value>
+ </data>
+ <data name="DiskCleanup.Item.SystemTemp.Description" xml:space="preserve">
+ <value>Windows 系统临时文件</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate" xml:space="preserve">
+ <value>Windows 更新缓存</value>
+ </data>
+ <data name="DiskCleanup.Item.WindowsUpdate.Description" xml:space="preserve">
+ <value>已下载的不再需要的 Windows 更新文件</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch" xml:space="preserve">
+ <value>预取文件</value>
+ </data>
+ <data name="DiskCleanup.Item.Prefetch.Description" xml:space="preserve">
+ <value>用于加速应用程序加载的预取数据</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails" xml:space="preserve">
+ <value>缩略图缓存</value>
+ </data>
+ <data name="DiskCleanup.Item.Thumbnails.Description" xml:space="preserve">
+ <value>资源管理器文件预览的缓存缩略图</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin" xml:space="preserve">
+ <value>回收站</value>
+ </data>
+ <data name="DiskCleanup.Item.RecycleBin.Description" xml:space="preserve">
+ <value>仍存储在回收站中的已删除文件</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports" xml:space="preserve">
+ <value>错误报告</value>
+ </data>
+ <data name="DiskCleanup.Item.ErrorReports.Description" xml:space="preserve">
+ <value>Windows 错误报告和崩溃转储文件</value>
+ </data>
</root>
diff --git a/optimizerDuck/Services/DiskCleanupService.cs b/optimizerDuck/Services/DiskCleanupService.cs
new file mode 100644
index 0000000..4bc4170
--- /dev/null
+++ b/optimizerDuck/Services/DiskCleanupService.cs
@@ -0,0 +1,289 @@
+using System.IO;
+using Microsoft.Extensions.Logging;
+using optimizerDuck.Core.Models.Cleanup;
+using optimizerDuck.Resources.Languages;
+using optimizerDuck.Services.OptimizationServices;
+using Wpf.Ui.Controls;
+
+namespace optimizerDuck.Services;
+
+public class DiskCleanupService(ILogger<DiskCleanupService> logger)
+{
+ public List<CleanupItem> GetCleanupItems()
+ {
+ return
+ [
+ new CleanupItem
+ {
+ Id = "TempFiles",
+ Name = Translations.DiskCleanup_Item_TempFiles,
+ Description = Translations.DiskCleanup_Item_TempFiles_Description,
+ Path = Path.GetTempPath(),
+ Icon = SymbolRegular.Document24
+ },
+ new CleanupItem
+ {
+ Id = "SystemTemp",
+ Name = Translations.DiskCleanup_Item_SystemTemp,
+ Description = Translations.DiskCleanup_Item_SystemTemp_Description,
+ Path = @"C:\Windows\Temp",
+ Icon = SymbolRegular.DocumentError24
+ },
+ new CleanupItem
+ {
+ Id = "WindowsUpdate",
+ Name = Translations.DiskCleanup_Item_WindowsUpdate,
+ Description = Translations.DiskCleanup_Item_WindowsUpdate_Description,
+ Path = @"C:\Windows\SoftwareDistribution\Download",
+ Icon = SymbolRegular.ArrowDownload24
+ },
+ new CleanupItem
+ {
+ Id = "Prefetch",
+ Name = Translations.DiskCleanup_Item_Prefetch,
+ Description = Translations.DiskCleanup_Item_Prefetch_Description,
+ Path = @"C:\Windows\Prefetch",
+ Icon = SymbolRegular.Flash24
+ },
+ new CleanupItem
+ {
+ Id = "Thumbnails",
+ Name = Translations.DiskCleanup_Item_Thumbnails,
+ Description = Translations.DiskCleanup_Item_Thumbnails_Description,
+ Path = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+ @"Microsoft\Windows\Explorer"),
+ Icon = SymbolRegular.Image24
+ },
+ new CleanupItem
+ {
+ Id = "RecycleBin",
+ Name = Translations.DiskCleanup_Item_RecycleBin,
+ Description = Translations.DiskCleanup_Item_RecycleBin_Description,
+ Path = "Clear-RecycleBin -Force -ErrorAction SilentlyContinue",
+ Icon = SymbolRegular.Delete24,
+ IsCommand = true
+ },
+ new CleanupItem
+ {
+ Id = "ErrorReports",
+ Name = Translations.DiskCleanup_Item_ErrorReports,
+ Description = Translations.DiskCleanup_Item_ErrorReports_Description,
+ Path = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+ "CrashDumps"),
+ Icon = SymbolRegular.Bug24
+ }
+ ];
+ }
+
+ public async Task ScanAsync(CleanupItem item)
+ {
+ item.IsScanning = true;
+ try
+ {
+ if (item.IsCommand)
+ {
+ // For RecycleBin, estimate size via PowerShell
+ if (item.Id == "RecycleBin")
+ {
+ var result = await ShellService.PowerShellAsync(
+ "(New-Object -ComObject Shell.Application).NameSpace(0xA).Items() | " +
+ "Measure-Object -Property Size -Sum | Select-Object -ExpandProperty Sum");
+ if (long.TryParse(result.Stdout.Trim(), out var size))
+ item.SizeBytes = size;
+ else
+ item.SizeBytes = 0;
+ }
+ }
+ else
+ {
+ item.SizeBytes = await Task.Run(() => CalculateDirectorySize(item.Path, item.Id));
+ }
+
+ item.IsScanned = true;
+ logger.LogInformation("Scanned {ItemId}: {Size}", item.Id, item.FormattedSize);
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to scan {ItemId}", item.Id);
+ item.SizeBytes = 0;
+ item.IsScanned = true;
+ }
+ finally
+ {
+ item.IsScanning = false;
+ }
+ }
+
+ public async Task ScanAllAsync(IEnumerable<CleanupItem> items)
+ {
+ foreach (var item in items)
+ await ScanAsync(item);
+ }
+
+ public async Task<long> CleanAsync(CleanupItem item)
+ {
+ item.IsCleaning = true;
+ long freedBytes = 0;
+
+ try
+ {
+ if (item.IsCommand)
+ {
+ var sizeBefore = item.SizeBytes;
+ await ShellService.PowerShellAsync(item.Path);
+ freedBytes = sizeBefore;
+ item.SizeBytes = 0;
+ logger.LogInformation("Cleaned {ItemId} via command, freed ~{Size}",
+ item.Id, CleanupItem.FormatBytes(freedBytes));
+ }
+ else
+ {
+ freedBytes = await Task.Run(() => DeleteFilesInDirectory(item.Path, item.Id));
+ item.SizeBytes = Math.Max(0, item.SizeBytes - freedBytes);
+ logger.LogInformation("Cleaned {ItemId}, freed {Size}",
+ item.Id, CleanupItem.FormatBytes(freedBytes));
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to clean {ItemId}", item.Id);
+ }
+ finally
+ {
+ item.IsCleaning = false;
+ }
+
+ return freedBytes;
+ }
+
+ public async Task<long> CleanSelectedAsync(IEnumerable<CleanupItem> items)
+ {
+ long totalFreed = 0;
+ foreach (var item in items.Where(i => i.IsSelected && i.SizeBytes > 0))
+ totalFreed += await CleanAsync(item);
+ return totalFreed;
+ }
+
+ private long CalculateDirectorySize(string path, string itemId)
+ {
+ if (!Directory.Exists(path))
+ return 0;
+
+ long size = 0;
+ try
+ {
+ // For Thumbnails, only count thumbcache_* files
+ var searchPattern = itemId == "Thumbnails" ? "thumbcache_*" : "*";
+
+ foreach (var file in Directory.EnumerateFiles(path, searchPattern, SearchOption.TopDirectoryOnly))
+ {
+ try
+ {
+ size += new FileInfo(file).Length;
+ }
+ catch
+ {
+ // skip inaccessible files
+ }
+ }
+
+ // For non-thumbnail items, also include subdirectories
+ if (itemId != "Thumbnails")
+ {
+ foreach (var dir in Directory.EnumerateDirectories(path))
+ {
+ try
+ {
+ foreach (var file in Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories))
+ {
+ try
+ {
+ size += new FileInfo(file).Length;
+ }
+ catch
+ {
+ // skip inaccessible files
+ }
+ }
+ }
+ catch
+ {
+ // skip inaccessible directories
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.LogWarning(ex, "Error calculating size for {ItemId} at {Path}", itemId, path);
+ }
+
+ return size;
+ }
+
+ private long DeleteFilesInDirectory(string path, string itemId)
+ {
+ if (!Directory.Exists(path))
+ return 0;
+
+ long freed = 0;
+ var searchPattern = itemId == "Thumbnails" ? "thumbcache_*" : "*";
+
+ // Delete files
+ foreach (var file in Directory.EnumerateFiles(path, searchPattern, SearchOption.TopDirectoryOnly))
+ {
+ try
+ {
+ var length = new FileInfo(file).Length;
+ File.Delete(file);
+ freed += length;
+ }
+ catch (Exception ex)
+ {
+ logger.LogDebug(ex, "Could not delete file: {File}", file);
+ }
+ }
+
+ // For non-thumbnail items, also delete subdirectory contents
+ if (itemId != "Thumbnails")
+ {
+ foreach (var dir in Directory.EnumerateDirectories(path))
+ {
+ try
+ {
+ foreach (var file in Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories))
+ {
+ try
+ {
+ var length = new FileInfo(file).Length;
+ File.Delete(file);
+ freed += length;
+ }
+ catch
+ {
+ // skip locked files
+ }
+ }
+
+ // Try to remove empty directories
+ try
+ {
+ Directory.Delete(dir, true);
+ }
+ catch
+ {
+ // directory may not be empty if some files were locked
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.LogDebug(ex, "Could not access directory: {Dir}", dir);
+ }
+ }
+ }
+
+ return freed;
+ }
+}
diff --git a/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs
new file mode 100644
index 0000000..d2eaa2b
--- /dev/null
+++ b/optimizerDuck/UI/ViewModels/Pages/DiskCleanupViewModel.cs
@@ -0,0 +1,148 @@
+using System.Collections.ObjectModel;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.Logging;
+using optimizerDuck.Core.Models.Cleanup;
+using optimizerDuck.Resources.Languages;
+using optimizerDuck.Services;
+using Wpf.Ui;
+using Wpf.Ui.Controls;
+
+namespace optimizerDuck.UI.ViewModels.Pages;
+
+public partial class DiskCleanupViewModel(
+ DiskCleanupService diskCleanupService,
+ ISnackbarService snackbarService,
+ ILogger<DiskCleanupViewModel> logger) : ViewModel
+{
+ [ObservableProperty] private ObservableCollection<CleanupItem> _cleanupItems = [];
+ [ObservableProperty] private bool _isLoading;
+ [ObservableProperty] private bool _isScanning;
+ [ObservableProperty] private bool _isCleaning;
+
+ public bool HasData => CleanupItems.Count > 0 && !IsLoading;
+ public bool IsAllScanned => CleanupItems.Count > 0 && CleanupItems.All(i => i.IsScanned);
+ public int SelectedCount => CleanupItems.Count(i => i.IsSelected);
+ public long TotalSelectedSizeBytes => CleanupItems.Where(i => i.IsSelected).Sum(i => i.SizeBytes);
+ public string TotalSelectedSizeFormatted => CleanupItem.FormatBytes(TotalSelectedSizeBytes);
+ public long TotalSizeBytes => CleanupItems.Sum(i => i.SizeBytes);
+ public string TotalSizeFormatted => CleanupItem.FormatBytes(TotalSizeBytes);
+ public bool CanClean => SelectedCount > 0 && TotalSelectedSizeBytes > 0 && !IsCleaning && !IsScanning;
+ public bool IsAllSelected => CleanupItems.Count > 0 && CleanupItems.All(i => i.IsSelected);
+
+ private bool _initialized;
+
+ public override async Task OnNavigatedToAsync()
+ {
+ if (_initialized) return;
+ _initialized = true;
+
+ IsLoading = true;
+ try
+ {
+ var items = diskCleanupService.GetCleanupItems();
+ CleanupItems = new ObservableCollection<CleanupItem>(items);
+
+ foreach (var item in CleanupItems)
+ {
+ item.PropertyChanged += (_, e) =>
+ {
+ if (e.PropertyName is nameof(CleanupItem.IsSelected) or nameof(CleanupItem.SizeBytes))
+ UpdateProperties();
+ };
+ }
+
+ UpdateProperties();
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to load cleanup items");
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+
+ // Automatically start scanning
+ await ScanAsync();
+ }
+
+ [RelayCommand]
+ private async Task ScanAsync()
+ {
+ if (IsScanning) return;
+
+ IsScanning = true;
+ try
+ {
+ await diskCleanupService.ScanAllAsync(CleanupItems);
+ UpdateProperties();
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to scan cleanup items");
+ }
+ finally
+ {
+ IsScanning = false;
+ }
+ }
+
+ [RelayCommand]
+ private async Task CleanSelectedAsync()
+ {
+ if (!CanClean) return;
+
+ IsCleaning = true;
+ try
+ {
+ var freedBytes = await diskCleanupService.CleanSelectedAsync(CleanupItems);
+ UpdateProperties();
+
+ snackbarService.Show(
+ Translations.DiskCleanup_Complete_Title,
+ string.Format(Translations.DiskCleanup_Complete_Message, CleanupItem.FormatBytes(freedBytes)),
+ ControlAppearance.Success,
+ new SymbolIcon { Symbol = SymbolRegular.CheckmarkCircle24, Filled = true },
+ TimeSpan.FromSeconds(5));
+
+ logger.LogInformation("Disk cleanup completed, freed {Size}", CleanupItem.FormatBytes(freedBytes));
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to clean selected items");
+ snackbarService.Show(
+ Translations.DiskCleanup_Error_Title,
+ Translations.DiskCleanup_Error_Message,
+ ControlAppearance.Danger,
+ new SymbolIcon { Symbol = SymbolRegular.ErrorCircle24, Filled = true },
+ TimeSpan.FromSeconds(5));
+ }
+ finally
+ {
+ IsCleaning = false;
+ }
+ }
+
+ [RelayCommand]
+ private void SelectAll()
+ {
+ var shouldSelect = !IsAllSelected;
+ foreach (var item in CleanupItems)
+ item.IsSelected = shouldSelect;
+ UpdateProperties();
+ }
+
+ private void UpdateProperties()
+ {
+ OnPropertyChanged(nameof(HasData));
+ OnPropertyChanged(nameof(IsAllScanned));
+ OnPropertyChanged(nameof(SelectedCount));
+ OnPropertyChanged(nameof(TotalSelectedSizeBytes));
+ OnPropertyChanged(nameof(TotalSelectedSizeFormatted));
+ OnPropertyChanged(nameof(TotalSizeBytes));
+ OnPropertyChanged(nameof(TotalSizeFormatted));
+ OnPropertyChanged(nameof(CanClean));
+ OnPropertyChanged(nameof(IsAllSelected));
+ }
+}
diff --git a/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml b/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml
new file mode 100644
index 0000000..d0a8fa7
--- /dev/null
+++ b/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml
@@ -0,0 +1,277 @@
+<Page
+ Foreground="{DynamicResource TextFillColorPrimaryBrush}"
+ Margin="0,32,0,0"
+ ScrollViewer.CanContentScroll="False"
+ Title="DiskCleanupPage"
+ d:DataContext="{d:DesignInstance local:DiskCleanupPage}"
+ d:DesignHeight="1200"
+ d:DesignWidth="800"
+ mc:Ignorable="d"
+ ui:Design.Background="Black"
+ ui:Design.Foreground="White"
+ x:Class="optimizerDuck.UI.Views.Pages.DiskCleanupPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:cleanup="clr-namespace:optimizerDuck.Core.Models.Cleanup"
+ xmlns:converters="clr-namespace:optimizerDuck.Common.Helpers.Converters"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:ext="clr-namespace:optimizerDuck.Common.Extensions"
+ xmlns:local="clr-namespace:optimizerDuck.UI.Views.Pages"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+ <Page.Resources>
+ <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+ <converters:GreaterThanZeroToVisibilityConverter x:Key="GreaterThanZeroToVisibilityConverter" />
+ <converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
+ </Page.Resources>
+
+ <Grid RowDefinitions="Auto *">
+ <!-- Header -->
+ <StackPanel Margin="0,0,0,20">
+ <ui:TextBlock
+ FontTypography="Title"
+ Text="{ext:Loc DiskCleanup.Header.Title}"
+ TextWrapping="Wrap" />
+ <ui:TextBlock
+ Appearance="Secondary"
+ FontTypography="Body"
+ Margin="0,4,0,0"
+ Text="{ext:Loc DiskCleanup.Header.Description}"
+ TextWrapping="Wrap" />
+ </StackPanel>
+
+ <!-- Loading -->
+ <Border Grid.Row="1" Visibility="{Binding ViewModel.IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}">
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+ <ui:ProgressRing
+ HorizontalAlignment="Center"
+ IsIndeterminate="True"
+ Margin="0,0,0,5"
+ VerticalAlignment="Center" />
+ <ui:TextBlock
+ FontTypography="BodyStrong"
+ HorizontalAlignment="Center"
+ Text="{ext:Loc DiskCleanup.Loading}"
+ VerticalAlignment="Center" />
+ </StackPanel>
+ </Border>
+
+ <!-- Main content -->
+ <Border
+ Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}"
+ CornerRadius="6"
+ Grid.Row="1"
+ Padding="8"
+ Visibility="{Binding ViewModel.HasData, Converter={StaticResource BooleanToVisibilityConverter}}">
+ <Grid RowDefinitions="Auto,Auto,*">
+
+ <!-- Summary card -->
+ <ui:CardControl
+ Grid.Row="0"
+ Icon="{ui:SymbolIcon HardDrive20}"
+ Margin="0,0,0,8">
+ <ui:CardControl.Header>
+ <StackPanel>
+ <ui:TextBlock
+ Appearance="Primary"
+ FontTypography="BodyStrong"
+ Text="{ext:Loc DiskCleanup.TotalSpace}" />
+ <ui:TextBlock
+ Appearance="Secondary"
+ FontTypography="Body">
+ <ui:TextBlock.Text>
+ <MultiBinding StringFormat="{}{0} ({1} items selected)">
+ <Binding Path="ViewModel.TotalSelectedSizeFormatted" />
+ <Binding Path="ViewModel.SelectedCount" />
+ </MultiBinding>
+ </ui:TextBlock.Text>
+ </ui:TextBlock>
+ </StackPanel>
+ </ui:CardControl.Header>
+ </ui:CardControl>
+
+ <!-- Action buttons -->
+ <StackPanel
+ Grid.Row="1"
+ Margin="0,0,0,8"
+ Orientation="Horizontal">
+
+ <!-- Scan button -->
+ <ui:Button
+ Appearance="Primary"
+ Command="{Binding ViewModel.ScanCommand}"
+ Content="{ext:Loc DiskCleanup.Button.Scan}"
+ Icon="{ui:SymbolIcon Search24,
+ FontSize=18}"
+ IsEnabled="{Binding ViewModel.IsScanning, Converter={StaticResource InverseBooleanConverter}}" />
+
+ <Separator Margin="3,0,3,0" />
+
+ <!-- Clean button -->
+ <ui:Button
+ Appearance="Danger"
+ Command="{Binding ViewModel.CleanSelectedCommand}"
+ IsEnabled="{Binding ViewModel.CanClean}">
+ <ui:Button.Content>
+ <StackPanel Orientation="Horizontal">
+ <ui:SymbolIcon FontSize="18" Margin="0,0,6,0" Symbol="Delete24" />
+ <TextBlock>
+ <TextBlock.Text>
+ <MultiBinding StringFormat="{}Clean Selected ({0})">
+ <Binding Path="ViewModel.TotalSelectedSizeFormatted" />
+ </MultiBinding>
+ </TextBlock.Text>
+ </TextBlock>
+ </StackPanel>
+ </ui:Button.Content>
+ </ui:Button>
+
+ <Separator Margin="3,0,3,0" />
+
+ <!-- Select/Deselect All -->
+ <ui:Button Command="{Binding ViewModel.SelectAllCommand}">
+ <ui:Button.Style>
+ <Style BasedOn="{StaticResource {x:Type ui:Button}}" TargetType="ui:Button">
+ <Setter Property="Appearance" Value="Success" />
+ <Setter Property="Content" Value="{ext:Loc DiskCleanup.Button.SelectAll}" />
+ <Setter Property="Icon">
+ <Setter.Value>
+ <ui:SymbolIcon FontSize="18" Symbol="CheckboxChecked24" />
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding ViewModel.IsAllSelected}" Value="True">
+ <Setter Property="Appearance" Value="Caution" />
+ <Setter Property="Content" Value="{ext:Loc DiskCleanup.Button.DeselectAll}" />
+ <Setter Property="Icon">
+ <Setter.Value>
+ <ui:SymbolIcon FontSize="18" Symbol="CheckboxUnchecked24" />
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ui:Button.Style>
+ </ui:Button>
+ </StackPanel>
+
+ <!-- Scanning indicator -->
+ <StackPanel
+ Grid.Row="2"
+ HorizontalAlignment="Center"
+ Orientation="Horizontal"
+ VerticalAlignment="Top"
+ Margin="0,0,0,8"
+ Visibility="{Binding ViewModel.IsScanning, Converter={StaticResource BooleanToVisibilityConverter}}">
+ <ui:ProgressRing
+ Height="16"
+ IsIndeterminate="True"
+ Margin="0,0,8,0"
+ Width="16" />
+ <ui:TextBlock
+ Appearance="Secondary"
+ FontTypography="Caption"
+ Text="{ext:Loc DiskCleanup.Scanning}" />
+ </StackPanel>
+
+ <!-- Items list -->
+ <ScrollViewer
+ Grid.Row="2"
+ HorizontalScrollBarVisibility="Disabled"
+ Margin="0,28,0,0"
+ VerticalScrollBarVisibility="Auto">
+ <ItemsControl ItemsSource="{Binding ViewModel.CleanupItems}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate DataType="{x:Type cleanup:CleanupItem}">
+ <Border
+ Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
+ CornerRadius="6"
+ Margin="0,0,0,4"
+ Padding="12">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+
+ <!-- Checkbox -->
+ <CheckBox
+ Grid.Column="0"
+ IsChecked="{Binding IsSelected, Mode=TwoWay}"
+ Margin="0,4,12,0"
+ VerticalAlignment="Top" />
+
+ <!-- Icon -->
+ <ui:SymbolIcon
+ FontSize="24"
+ Grid.Column="1"
+ Margin="0,4,12,0"
+ Symbol="{Binding Icon}"
+ VerticalAlignment="Top" />
+
+ <!-- Info -->
+ <StackPanel Grid.Column="2">
+ <ui:TextBlock FontTypography="BodyStrong" Text="{Binding Name}" />
+ <ui:TextBlock
+ Appearance="Disabled"
+ FontTypography="Body"
+ Margin="0,2,0,0"
+ Text="{Binding Description}"
+ TextWrapping="Wrap" />
+ <ui:TextBlock
+ Appearance="Secondary"
+ FontTypography="Caption"
+ Margin="0,2,0,0"
+ Text="{Binding Path}"
+ TextTrimming="CharacterEllipsis" />
+ </StackPanel>
+
+ <!-- Size / Status indicator -->
+ <StackPanel
+ Grid.Column="3"
+ HorizontalAlignment="Right"
+ Margin="12,0,0,0"
+ VerticalAlignment="Center">
+ <!-- Scanning spinner -->
+ <ui:ProgressRing
+ Height="20"
+ IsIndeterminate="True"
+ Visibility="{Binding IsScanning, Converter={StaticResource BooleanToVisibilityConverter}}"
+ Width="20" />
+ <!-- Cleaning spinner -->
+ <ui:ProgressRing
+ Height="20"
+ IsIndeterminate="True"
+ Visibility="{Binding IsCleaning, Converter={StaticResource BooleanToVisibilityConverter}}"
+ Width="20" />
+ <!-- Size display -->
+ <ui:TextBlock
+ FontTypography="BodyStrong"
+ Text="{Binding FormattedSize}"
+ Visibility="{Binding IsScanned, Converter={StaticResource BooleanToVisibilityConverter}}">
+ <ui:TextBlock.Style>
+ <Style BasedOn="{StaticResource {x:Type ui:TextBlock}}" TargetType="ui:TextBlock">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsScanning}" Value="True">
+ <Setter Property="Visibility" Value="Collapsed" />
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IsCleaning}" Value="True">
+ <Setter Property="Visibility" Value="Collapsed" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ui:TextBlock.Style>
+ </ui:TextBlock>
+ </StackPanel>
+ </Grid>
+ </Border>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </Grid>
+ </Border>
+ </Grid>
+</Page>
diff --git a/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml.cs b/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml.cs
new file mode 100644
index 0000000..d20f6ce
--- /dev/null
+++ b/optimizerDuck/UI/Views/Pages/DiskCleanupPage.xaml.cs
@@ -0,0 +1,17 @@
+using optimizerDuck.UI.ViewModels.Pages;
+using Wpf.Ui.Abstractions.Controls;
+
+namespace optimizerDuck.UI.Views.Pages;
+
+public partial class DiskCleanupPage : INavigableView<DiskCleanupViewModel>
+{
+ public DiskCleanupPage(DiskCleanupViewModel viewModel)
+ {
+ ViewModel = viewModel;
+ DataContext = this;
+
+ InitializeComponent();
+ }
+
+ public DiskCleanupViewModel ViewModel { get; }
+}
diff --git a/optimizerDuck/UI/Views/Windows/MainWindow.xaml b/optimizerDuck/UI/Views/Windows/MainWindow.xaml
index 686ef6b..f14b995 100644
--- a/optimizerDuck/UI/Views/Windows/MainWindow.xaml
+++ b/optimizerDuck/UI/Views/Windows/MainWindow.xaml
@@ -51,6 +51,11 @@
Content="{extensions:Loc Sidebar.Bloatware}"
Icon="{ui:SymbolIcon Delete24}"
TargetPageType="{x:Type pages:BloatwarePage}" />
+
+ <ui:NavigationViewItem
+ Content="{extensions:Loc Sidebar.DiskCleanup}"
+ Icon="{ui:SymbolIcon HardDrive20}"
+ TargetPageType="{x:Type pages:DiskCleanupPage}" />
</ui:NavigationView.MenuItems>
<ui:NavigationView.FooterMenuItems>