Skip to content

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

feat: add bloatware functions

itsfatduck78023c840189
diff --git a/optimizerDuck/App.xaml.cs b/optimizerDuck/App.xaml.cs
index 8b0f2dc..b73686a 100644
--- a/optimizerDuck/App.xaml.cs
+++ b/optimizerDuck/App.xaml.cs
@@ -168,6 +168,7 @@ public partial class App : Application
// Services
services.AddSingleton<OptimizationRegistry>();
services.AddSingleton<OptimizationService>();
+ services.AddSingleton<BloatwareService>();
services.AddSingleton<SystemInfoService>();
services.AddSingleton<StreamService>();
services.AddSingleton<UpdaterService>();
diff --git a/optimizerDuck/Common/Helpers/Shared.cs b/optimizerDuck/Common/Helpers/Shared.cs
index dcb1c82..94b0a11 100644
--- a/optimizerDuck/Common/Helpers/Shared.cs
+++ b/optimizerDuck/Common/Helpers/Shared.cs
@@ -44,4 +44,75 @@ public static class Shared
public static string RevertDirectory =>
Path.Combine(RootDirectory, "Revert");
+
+ public static readonly Dictionary<string, string> SafeApps = new()
+ {
+ // bing
+ ["Microsoft.BingWeather"] = "Weather",
+ ["Microsoft.BingNews"] = "Bing News",
+ ["Microsoft.BingSearch"] = "Bing Search",
+
+ ["Microsoft.GetHelp"] = "Get Help",
+ ["Microsoft.GetStarted"] = "Get Started / Tips",
+ ["Microsoft.Messaging"] = "Messaging",
+ ["Microsoft.Microsoft3DViewer"] = "3D Viewer",
+ ["Microsoft.MicrosoftSolitaireCollection"] = "Solitaire Collection",
+ ["Microsoft.MicrosoftStickyNotes"] = "Sticky Notes",
+ ["Microsoft.MixedReality.Portal"] = "Mixed Reality Portal",
+ ["Microsoft.OneConnect"] = "OneConnect (Connect App)",
+ ["Microsoft.People"] = "People",
+ ["Microsoft.Print3D"] = "Print 3D",
+ ["SkypeApp"] = "Skype",
+ ["Microsoft.WindowsAlarms"] = "Alarms & Clock",
+ ["Microsoft.WindowsCamera"] = "Camera",
+ ["Microsoft.WindowsMaps"] = "Maps",
+ ["Microsoft.WindowsFeedbackHub"] = "Feedback Hub",
+ ["Microsoft.WindowsSoundRecorder"] = "Voice Recorder",
+ ["Microsoft.ZuneMusic"] = "Media Player / Groove",
+ ["Microsoft.Sway"] = "Microsoft Sway",
+ ["Microsoft.3DBuilder"] = "3D Builder (legacy)",
+ ["Microsoft.DrawboardPDF"] = "Drawboard PDF (OEM)",
+ ["WindowsPhone"] = "Windows Phone (old)",
+ ["CommsPhone"] = "Communications Phone (old)",
+ ["Microsoft.Todos"] = "Microsoft To Do",
+ ["Microsoft.WindowsCommunicationsApps"] = "Mail and Calendar",
+ ["MicrosoftCorporationII.QuickAssist"] = "Quick Assist",
+ ["Microsoft.Office.OneNote"] = "OneNote",
+ ["Microsoft.YourPhone"] = "Phone Link",
+ ["Microsoft.MicrosoftNews"] = "Microsoft News",
+ ["Microsoft.MicrosoftOfficeHub"] = "Office Hub"
+ };
+
+
+ public static readonly Dictionary<string, string> CautionApps = new()
+ {
+ ["Microsoft.WindowsCalculator"] = "Calculator",
+ ["Microsoft.Windows.Photos"] = "Photos",
+ ["Microsoft.MSPaint"] = "Paint",
+ ["Microsoft.Paint3D"] = "Paint 3D",
+ ["Microsoft.ScreenSketch"] = "Snipping Tool & Sketch",
+ ["Microsoft.WindowsStore"] = "Microsoft Store",
+ ["Microsoft.XboxIdentityProvider"] = "Xbox Identity Provider",
+ ["Microsoft.WindowsTerminal"] = "Windows Terminal",
+ ["Microsoft.WindowsTerminalPreview"] = "Windows Terminal (Preview)",
+ ["Clipchamp.Clipchamp"] = "Clipchamp (Video Editor)",
+ ["Microsoft.WindowsNotepad"] = "Notepad",
+ ["Microsoft.PowerAutomateDesktop"] = "Power Automate",
+ ["MicrosoftTeams"] = "Microsoft Teams",
+ ["MicrosoftCorporationII.MicrosoftFamily"] = "Microsoft Family Safety",
+ ["MicrosoftCorporationII.MicrosoftSupportDiagnosticTool"] = "Support Diagnostic Tool",
+ // Extensions
+ ["Microsoft.HEIFImageExtension"] = "HEIF Image Extension",
+ ["Microsoft.WebMediaExtensions"] = "Web Media Extensions",
+ ["Microsoft.WebpImageExtension"] = "WebP Image Extension",
+ ["Microsoft.RawImageExtension"] = "Raw Image Extension",
+ ["Microsoft.VP9VideoExtensions"] = "VP9 Video Extension",
+ ["Microsoft.AV1VideoExtension"] = "AV1 Video Extension",
+ // Xbox / Game Bar
+ ["Microsoft.XboxSpeechToTextOverlay"] = "Xbox Speech Overlay",
+ ["Microsoft.XboxGameOverlay"] = "Xbox Game Overlay",
+ ["Microsoft.XboxGamingOverlay"] = "Xbox Game Bar",
+ ["Microsoft.XboxApp"] = "Xbox Console Companion",
+ ["Microsoft.Xbox.TCUI"] = "Xbox TCUI"
+ };
}
\ No newline at end of file
diff --git a/optimizerDuck/Core/Models/Bloatware/AppxPackage.cs b/optimizerDuck/Core/Models/Bloatware/AppxPackage.cs
index 4531962..7bdaafe 100644
--- a/optimizerDuck/Core/Models/Bloatware/AppxPackage.cs
+++ b/optimizerDuck/Core/Models/Bloatware/AppxPackage.cs
@@ -1,14 +1,21 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+
namespace optimizerDuck.Core.Models.Bloatware;
-public record AppxPackage
+public enum AppRisk
+{
+ Safe,
+ Caution
+}
+
+public partial class AppxPackage : ObservableObject
{
- public bool IsSelected { get; set; } = false;
-
+ [ObservableProperty] private bool _isSelected;
+
public string Name { get; init; }
public string PackageFullName { get; init; }
public string Publisher { get; init; }
public string Version { get; init; }
public string InstallLocation { get; init; }
- public DateTime InstallDate { get; init; }
- public bool NonRemovable { get; init; }
+ public AppRisk Risk { get; init; }
};
\ No newline at end of file
diff --git a/optimizerDuck/Services/BloatwareService.cs b/optimizerDuck/Services/BloatwareService.cs
new file mode 100644
index 0000000..fe43198
--- /dev/null
+++ b/optimizerDuck/Services/BloatwareService.cs
@@ -0,0 +1,85 @@
+using Microsoft.Extensions.Logging;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using optimizerDuck.Common.Helpers;
+using optimizerDuck.Common.Helpers.Converters;
+using optimizerDuck.Core.Models.Bloatware;
+using optimizerDuck.Services.OptimizationServices;
+using JsonSerializer = System.Text.Json.JsonSerializer;
+
+namespace optimizerDuck.Services;
+
+public class BloatwareService(ILogger<BloatwareService> logger)
+{
+ public async Task<List<AppxPackage>> GetAppXPackagesAsync()
+ {
+ try
+ {
+ var result = await ShellService.PowerShellAsync($$"""
+ # list the SAFE_APPS
+ $safeApps = @({{string.Join(", ", Shared.SafeApps.Keys.Select(x => $"\"{x}\""))}})
+
+ # list the CAUTION_APPS
+ $cautionApps = @({{string.Join(", ", Shared.CautionApps.Keys.Select(x => $"\"{x}\""))}})
+
+ # get installed removable apps
+ $installedApps = Get-AppxPackage -AllUsers | Where-Object { $_.NonRemovable -eq 0 }
+
+ $result = @()
+
+ foreach ($app in $installedApps) {
+
+ $nameLower = $app.Name.ToLower()
+ $risk = "Unknown"
+
+ foreach ($s in $safeApps) {
+ if ($nameLower -like "*$($s.ToLower())*") {
+ $risk = "Safe"
+ break
+ }
+ }
+
+ if ($risk -eq "Unknown") {
+ foreach ($s in $cautionApps) {
+ if ($nameLower -like "*$($s.ToLower())*") {
+ $risk = "Caution"
+ break
+ }
+ }
+ }
+
+ if ($risk -ne "Unknown") {
+ $result += [PSCustomObject]@{
+ Name = $app.Name
+ PackageFullName = $app.PackageFullName
+ Publisher = $app.Publisher
+ Version = $app.Version
+ InstallLocation = $app.InstallLocation
+ Risk = $risk
+ }
+ }
+ }
+
+ $result | ConvertTo-Json -Depth 4
+ """);
+
+
+ var options = new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter()}
+ };
+
+ var apps = JsonSerializer.Deserialize<List<AppxPackage>>(result.Stdout, options);
+
+ logger.LogInformation("Found {AppCount} AppX packages", apps.Count);
+
+ return apps;
+ }
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Failed to get bloatware choices");
+ return [];
+ }
+ }
+}
\ No newline at end of file
diff --git a/optimizerDuck/Services/OptimizationServices/ShellService.cs b/optimizerDuck/Services/OptimizationServices/ShellService.cs
index 73e6c61..4863c6d 100644
--- a/optimizerDuck/Services/OptimizationServices/ShellService.cs
+++ b/optimizerDuck/Services/OptimizationServices/ShellService.cs
@@ -195,6 +195,155 @@ public static class ShellService
}
}
+ private static async Task<ShellResult> RunAsync(
+ string fileName,
+ string arguments,
+ string command,
+ string serviceName,
+ ShellRevertStep? revertStep,
+ ShellPolicy? policy = null,
+ CancellationToken ct = default)
+ {
+ policy ??= ShellPolicy.Default;
+
+ var commandForUser = arguments.Contains("-EncodedCommand", StringComparison.OrdinalIgnoreCase)
+ ? command.DecodeBase64().Replace("$ProgressPreference='SilentlyContinue'; ", "")
+ : command;
+
+ var fullCommandForUser =
+ $"{fileName} {arguments.Replace("-EncodedCommand", "-Command", StringComparison.OrdinalIgnoreCase)} {commandForUser}";
+
+ var psi = new ProcessStartInfo
+ {
+ FileName = fileName,
+ Arguments = $"{arguments} {command}",
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ StandardOutputEncoding = Encoding.UTF8,
+ StandardErrorEncoding = Encoding.UTF8,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ };
+
+ try
+ {
+ using var process = new Process();
+ process.StartInfo = psi;
+
+ var stdoutBuilder = new StringBuilder();
+ var stderrBuilder = new StringBuilder();
+
+ process.OutputDataReceived += (_, e) =>
+ {
+ if (e.Data != null) stdoutBuilder.AppendLine(e.Data);
+ };
+
+ process.ErrorDataReceived += (_, e) =>
+ {
+ if (e.Data != null) stderrBuilder.AppendLine(e.Data);
+ };
+
+ var sw = Stopwatch.StartNew();
+
+ process.Start();
+ process.BeginOutputReadLine();
+ process.BeginErrorReadLine();
+
+ var timeout = _options?.CurrentValue.Optimize.ShellTimeoutMs ?? 120000;
+
+ using var timeoutCts = new CancellationTokenSource(timeout);
+ using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, ct);
+
+ try
+ {
+ await process.WaitForExitAsync(linkedCts.Token);
+ }
+ catch (OperationCanceledException)
+ {
+ try
+ {
+ process.Kill(true);
+ }
+ catch
+ {
+ }
+ }
+
+ sw.Stop();
+
+ var timedOut = !process.HasExited;
+ if (!process.HasExited)
+ process.WaitForExit(2000);
+
+ var stdout = stdoutBuilder.ToString().Trim();
+ var stderr = stderrBuilder.ToString().ParseCliXml().Trim();
+
+ var result = new ShellResult(
+ fullCommandForUser,
+ stdout,
+ stderr,
+ timedOut ? -1 : process.ExitCode,
+ sw.Elapsed);
+
+ var success = policy.IsSuccess(result);
+
+ ServiceTracker.Track(serviceName, success);
+
+ ServiceTracker.LogInfo("[{Service}][{Status}][EC={ExitCode}][D={Duration}] {Command}",
+ serviceName,
+ timedOut ? "TIMEOUT" : success ? "OK" : "FAIL",
+ result.ExitCode,
+ sw.Elapsed.FormatTime(),
+ fullCommandForUser);
+
+ ServiceTracker.LogTrace("[{Service}][STDOUT] {Stdout}",
+ serviceName,
+ string.IsNullOrWhiteSpace(stdout) ? "N/A" : stdout);
+
+ ServiceTracker.LogTrace("[{Service}][STDERR] {Stderr}",
+ serviceName,
+ string.IsNullOrWhiteSpace(stderr) ? "N/A" : stderr);
+
+ var error = success ? null : policy.ErrorFactory(result);
+
+ ServiceTracker.TrackStep(
+ "Shell",
+ fullCommandForUser,
+ success,
+ error,
+ async () =>
+ policy.IsSuccess(await RunAsync(fileName, arguments, command, serviceName, revertStep, policy, ct))
+ );
+
+ if (success && revertStep is not null)
+ RevertManager.Record(revertStep);
+
+ return result;
+ }
+ catch (Exception ex)
+ {
+ var result = new ShellResult(
+ fullCommandForUser,
+ string.Empty,
+ ex.Message,
+ -2,
+ TimeSpan.Zero);
+
+ ServiceTracker.Track(serviceName, false);
+ ServiceTracker.LogError(ex, "[{Service}][FAIL][EXCEPTION] {Command}", serviceName, fullCommandForUser);
+
+ ServiceTracker.TrackStep(
+ "Shell",
+ fullCommandForUser,
+ false,
+ ex.Message,
+ () => Task.FromResult(false));
+
+ return result;
+ }
+ }
+
+
#region Command Prompt methods
public static ShellResult CMD(string command, ShellRevertStep? revertStep = null, ShellPolicy? policy = null)
@@ -202,6 +351,23 @@ public static class ShellService
return Run("cmd.exe", "/c", command, nameof(CMD), revertStep, policy);
}
+ public static Task<ShellResult> CMDAsync(
+ string command,
+ ShellRevertStep? revertStep = null,
+ ShellPolicy? policy = null,
+ CancellationToken ct = default)
+ {
+ return RunAsync(
+ "cmd.exe",
+ "/c",
+ command,
+ nameof(CMD),
+ revertStep,
+ policy,
+ ct);
+ }
+
+
public static ShellResult CMD(string command, string revertCommand, ShellPolicy? policy = null)
{
return CMD(command, new ShellRevertStep
@@ -235,6 +401,21 @@ public static class ShellService
policy);
}
+ public static Task<ShellResult> PowerShellAsync(
+ string command,
+ ShellRevertStep? revertStep = null,
+ ShellPolicy? policy = null,
+ CancellationToken ct = default)
+ {
+ command = "$ProgressPreference='SilentlyContinue'; " + command;
+ return RunAsync("powershell.exe",
+ "-NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand",
+ command.EncodeBase64(),
+ nameof(PowerShell),
+ revertStep,
+ policy, ct);
+ }
+
public static ShellResult PowerShell(string command, string revertCommand, ShellPolicy? policy = null)
{
return PowerShell(command, new ShellRevertStep
diff --git a/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs b/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
index 41eec23..b69c265 100644
--- a/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Pages/BloatwareViewModel.cs
@@ -1,69 +1,92 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
using optimizerDuck.Core.Models.Bloatware;
+using optimizerDuck.Services;
+using optimizerDuck.UI.ViewModels;
namespace optimizerDuck.UI.ViewModels.Pages;
-public class BloatwareViewModel
+public partial class BloatwareViewModel : ViewModel
{
- public ObservableCollection<AppxPackage> AppxPackages { get; private set; } = new();
+ private bool _isInitialized;
- public BloatwareViewModel()
+ private readonly BloatwareService _bloatwareService;
+
+
+ public ObservableCollection<AppxPackage> AppxPackages { get; set; } = [];
+
+ public bool HasSelectedItems => AppxPackages.Any(x => x.IsSelected);
+ public int SelectedCount => AppxPackages.Count(x => x.IsSelected);
+
+ public BloatwareViewModel(BloatwareService bloatwareService)
{
- // generate sample AppxPackages
- AppxPackages.Add(new AppxPackage
- {
- Name = "Microsoft.WindowsCalculator",
- PackageFullName = "Microsoft.WindowsCalculator_11.2401.0.0_x64__8wekyb3d8bbwe",
- Publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
- Version = "11.2401.0.0",
- InstallLocation =
- @"C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_11.2401.0.0_x64__8wekyb3d8bbwe",
- InstallDate = DateTime.Now.AddDays(-30),
- NonRemovable = false,
- });
-
- AppxPackages.Add(new AppxPackage
- {
- Name = "Microsoft.WindowsStore",
- PackageFullName = "Microsoft.WindowsStore_22401.1401.3.0_x64__8wekyb3d8bbwe",
- Publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
- Version = "22401.1401.3.0",
- InstallLocation = @"C:\Program Files\WindowsApps\Microsoft.WindowsStore_22401.1401.3.0_x64__8wekyb3d8bbwe",
- InstallDate = DateTime.Now.AddMonths(-2),
- NonRemovable = true, // system protected
- });
-
- AppxPackages.Add(new AppxPackage
- {
- Name = "Contoso.MediaPlayer",
- PackageFullName = "Contoso.MediaPlayer_2.5.3.0_x64__abcd1234efgh",
- Publisher = "CN=Contoso Software Ltd, O=Contoso Ltd, C=US",
- Version = "2.5.3.0",
- InstallLocation = @"C:\Program Files\WindowsApps\Contoso.MediaPlayer_2.5.3.0_x64__abcd1234efgh",
- InstallDate = DateTime.Now.AddDays(-7),
- NonRemovable = false,
- });
-
- AppxPackages.Add(new AppxPackage
+ _bloatwareService = bloatwareService;
+
+ AppxPackages.CollectionChanged += (_, e) =>
{
- Name = "Fabrikam.PhotoEditor",
- PackageFullName = "Fabrikam.PhotoEditor_5.0.1.0_x86__xyz987654321",
- Publisher = "CN=Fabrikam Inc, O=Fabrikam Inc, C=US",
- Version = "5.0.1.0",
- InstallLocation = @"C:\Program Files\WindowsApps\Fabrikam.PhotoEditor_5.0.1.0_x86__xyz987654321",
- InstallDate = DateTime.Now.AddDays(-120),
- NonRemovable = false,
- });
-
- AppxPackages.Add(new AppxPackage
+ if (e.NewItems != null)
+ foreach (AppxPackage p in e.NewItems)
+ p.PropertyChanged += Item_PropertyChanged;
+
+ if (e.OldItems != null)
+ foreach (AppxPackage p in e.OldItems)
+ p.PropertyChanged -= Item_PropertyChanged;
+
+ UpdateProperties();
+ RemoveSelectedCommand.NotifyCanExecuteChanged();
+ };
+ }
+
+ public override async Task OnNavigatedToAsync()
+ {
+ if (_isInitialized)
+ return;
+
+ var appxPackages = await _bloatwareService.GetAppXPackagesAsync();
+ foreach (var package in appxPackages)
+ AppxPackages.Add(package);
+
+ _isInitialized = true;
+ }
+
+ #region Commands
+
+ [RelayCommand(CanExecute = nameof(CanRemoveSelected))]
+ private void RemoveSelected()
+ {
+ var toRemove = AppxPackages.Where(x => x.IsSelected).ToList();
+
+ foreach (var item in toRemove)
+ AppxPackages.Remove(item);
+ }
+
+ private bool CanRemoveSelected() => HasSelectedItems;
+
+ #endregion
+
+ #region Property Changed
+
+ private void Item_PropertyChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == nameof(AppxPackage.IsSelected))
{
- Name = "Microsoft.VCLibs.140.00",
- PackageFullName = "Microsoft.VCLibs.140.00_14.0.32530.0_x64__8wekyb3d8bbwe",
- Publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
- Version = "14.0.32530.0",
- InstallLocation = @"C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00_14.0.32530.0_x64__8wekyb3d8bbwe",
- InstallDate = DateTime.Now.AddYears(-1),
- NonRemovable = true, // framework
- });
+ UpdateProperties();
+ RemoveSelectedCommand.NotifyCanExecuteChanged();
+ }
+ }
+
+ #endregion
+
+ #region Helpers
+
+ private void UpdateProperties()
+ {
+ OnPropertyChanged(nameof(HasSelectedItems));
+ OnPropertyChanged(nameof(SelectedCount));
}
+
+ #endregion
}
\ No newline at end of file
diff --git a/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml b/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
index 7d8f8cf..cbfd741 100644
--- a/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
+++ b/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
@@ -3,6 +3,7 @@
Margin="0,32,0,0"
ScrollViewer.CanContentScroll="False"
Title="BloatwarePage"
+ d:DataContext="{d:DesignInstance local:BloatwarePage}"
d:DesignHeight="1200"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -19,127 +20,132 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
- <converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
+ <converters:ZeroToVisibilityConverter x:Key="ZeroToVisibilityConverter" />
+ <converters:GreaterThanZeroToVisibilityConverter x:Key="GreaterThanZeroToVisibilityConverter" />
</Page.Resources>
-
- <StackPanel>
+ <Grid RowDefinitions="Auto *">
<ui:TextBlock
FontTypography="Title"
Margin="0,0,0,20"
Text="{ext:Loc Bloatware.Header.Title}"
TextWrapping="Wrap" />
+ <Border Grid.Row="1" Visibility="{Binding ViewModel.AppxPackages.Count, Converter={StaticResource ZeroToVisibilityConverter}}">
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+ <ui:ProgressRing
+ HorizontalAlignment="Center"
+ IsIndeterminate="True"
+ VerticalAlignment="Center" />
+ <ui:TextBlock
+ HorizontalAlignment="Center"
+ Text="Getting AppX packages..."
+ VerticalAlignment="Center" />
+ </StackPanel>
+ </Border>
+
<Border
Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}"
CornerRadius="6"
- Padding="8">
- <ui:VirtualizingItemsControl ItemsSource="{Binding ViewModel.AppxPackages}" ScrollViewer.VerticalScrollBarVisibility="Auto">
- <!-- Layout panel -->
- <ui:VirtualizingItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <VirtualizingStackPanel />
- </ItemsPanelTemplate>
- </ui:VirtualizingItemsControl.ItemsPanel>
-
- <!-- Item template -->
- <ui:VirtualizingItemsControl.ItemTemplate>
- <DataTemplate DataType="{x:Type bloatware:AppxPackage}">
- <Border
- Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
- CornerRadius="6"
- Margin="0,0,0,8"
- Padding="12">
-
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
-
- <!-- Checkbox -->
- <CheckBox
- Grid.Column="0"
- IsChecked="{Binding IsSelected, Mode=TwoWay}"
- IsEnabled="{Binding NonRemovable, Converter={StaticResource InverseBooleanConverter}}"
- Margin="0,4,12,0"
- VerticalAlignment="Top" />
-
- <!-- Content -->
- <StackPanel Grid.Column="1">
-
- <!-- Top row -->
- <DockPanel LastChildFill="False">
-
- <!-- App Name -->
- <ui:TextBlock FontTypography="BodyStrong" Text="{Binding Name}" />
-
- <!-- Version -->
+ Grid.Row="1"
+ Padding="8"
+ Visibility="{Binding ViewModel.AppxPackages.Count, Converter={StaticResource GreaterThanZeroToVisibilityConverter}}">
+ <Grid RowDefinitions="Auto *">
+ <Menu>
+ <ui:MenuItem
+ Command="{Binding ViewModel.RemoveSelectedCommand}"
+ Header="{Binding ViewModel.SelectedCount, StringFormat='Remove ({0})'}"
+ Icon="{ui:SymbolIcon Delete24,
+ FontSize=18}" />
+ <ui:MenuItem Header="Refresh" Icon="{ui:SymbolIcon ArrowClockwise24, FontSize=18}" />
+ </Menu>
+ <ui:VirtualizingItemsControl Grid.Row="1" ItemsSource="{Binding ViewModel.AppxPackages}">
+ <ui:VirtualizingItemsControl.Template>
+ <ControlTemplate TargetType="ItemsControl">
+ <ScrollViewer HorizontalScrollBarVisibility="Disabled">
+ <ItemsPresenter />
+ </ScrollViewer>
+ </ControlTemplate>
+ </ui:VirtualizingItemsControl.Template>
+ <!-- Layout panel -->
+ <ui:VirtualizingItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <VirtualizingStackPanel />
+ </ItemsPanelTemplate>
+ </ui:VirtualizingItemsControl.ItemsPanel>
+
+ <!-- Item template -->
+ <ui:VirtualizingItemsControl.ItemTemplate>
+ <DataTemplate DataType="{x:Type bloatware:AppxPackage}">
+ <Border
+ Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
+ CornerRadius="6"
+ Margin="0,0,0,8"
+ Padding="12">
+
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <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" />
+
+ <!-- Content -->
+ <StackPanel Grid.Column="1">
+
+ <!-- Top row -->
+ <DockPanel LastChildFill="False">
+
+ <!-- App Name -->
+ <ui:TextBlock FontTypography="BodyStrong" Text="{Binding Name}" />
+
+ <!-- Version -->
+ <ui:TextBlock
+ Appearance="Tertiary"
+ FontTypography="Body"
+ Margin="5,0,0,0"
+ Text="{Binding Version, StringFormat=' v{0}'}"
+ VerticalAlignment="Center" />
+
+ </DockPanel>
+
+ <!-- Publisher -->
<ui:TextBlock
- Appearance="Tertiary"
+ Appearance="Secondary"
FontTypography="Body"
- Margin="5,0,0,0"
- Text="{Binding Version, StringFormat=' v{0}'}"
- VerticalAlignment="Center" />
+ Margin="0,2,0,0"
+ Text="{Binding Publisher}"
+ TextTrimming="CharacterEllipsis" />
- </DockPanel>
-
- <!-- Publisher -->
- <ui:TextBlock
- Appearance="Secondary"
- FontTypography="Body"
- Margin="0,2,0,0"
- Text="{Binding Publisher}"
- TextTrimming="CharacterEllipsis" />
-
- <!-- Install info -->
- <ui:TextBlock
- Appearance="Tertiary"
- FontTypography="Body"
- Margin="0,2,0,0">
- <Run Text="Installed: " />
- <Run Text="{Binding InstallDate, StringFormat='{}{0:yyyy-MM-dd}'}" />
- </ui:TextBlock>
-
- <!-- Install location -->
- <ui:TextBlock
- Appearance="Disabled"
- FontTypography="Body"
- Margin="0,2,0,0"
- Text="{Binding InstallLocation}"
- TextTrimming="CharacterEllipsis" />
-
- <!-- Package full name (technical, nhỏ hơn) -->
- <ui:TextBlock
- Appearance="Disabled"
- FontTypography="Caption"
- Margin="0,4,0,0"
- Text="{Binding PackageFullName}"
- TextTrimming="CharacterEllipsis" />
- </StackPanel>
-
- <!-- NonRemovable Badge -->
- <Border
- Background="#AAFF3B30"
- CornerRadius="12"
- Grid.Column="2"
- Padding="8,4"
- VerticalAlignment="Top"
- Visibility="{Binding NonRemovable, Converter={StaticResource BooleanToVisibilityConverter}}">
-
- <TextBlock
- FontSize="11"
- FontWeight="SemiBold"
- Foreground="White"
- Text="System" />
- </Border>
+ <!-- Install location -->
+ <ui:TextBlock
+ Appearance="Disabled"
+ FontTypography="Body"
+ Margin="0,2,0,0"
+ Text="{Binding InstallLocation}"
+ TextTrimming="CharacterEllipsis" />
- </Grid>
- </Border>
- </DataTemplate>
- </ui:VirtualizingItemsControl.ItemTemplate>
- </ui:VirtualizingItemsControl>
+ <!-- Package full name (technical, nhỏ hơn) -->
+ <ui:TextBlock
+ Appearance="Disabled"
+ FontTypography="Caption"
+ Margin="0,4,0,0"
+ Text="{Binding PackageFullName}"
+ TextTrimming="CharacterEllipsis" />
+ </StackPanel>
+ </Grid>
+ </Border>
+ </DataTemplate>
+ </ui:VirtualizingItemsControl.ItemTemplate>
+ </ui:VirtualizingItemsControl>
+ </Grid>
</Border>
- </StackPanel>
+ </Grid>
</Page>
diff --git a/optimizerDuck/UI/Views/Pages/DashboardPage.xaml b/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
index fb16f9e..bca3236 100644
--- a/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
+++ b/optimizerDuck/UI/Views/Pages/DashboardPage.xaml
@@ -3,6 +3,7 @@
Margin="0,32,0,0"
ScrollViewer.CanContentScroll="False"
Title="Dashboard"
+ d:DataContext="{d:DesignInstance pages:DashboardPage}"
d:DesignHeight="650"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -14,6 +15,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ext="clr-namespace:optimizerDuck.Common.Extensions"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:pages="clr-namespace:optimizerDuck.UI.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
diff --git a/optimizerDuck/UI/Views/Pages/Optimizations/OptimizationPage.xaml b/optimizerDuck/UI/Views/Pages/Optimizations/OptimizationPage.xaml
index bf09212..da06caa 100644
--- a/optimizerDuck/UI/Views/Pages/Optimizations/OptimizationPage.xaml
+++ b/optimizerDuck/UI/Views/Pages/Optimizations/OptimizationPage.xaml
@@ -3,6 +3,7 @@
Margin="0,32,0,0"
ScrollViewer.CanContentScroll="False"
Title="OptimizationPage"
+ d:DataContext="{d:DesignInstance optimizations:OptimizationPage}"
d:DesignHeight="650"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -13,6 +14,7 @@
xmlns:converters="clr-namespace:optimizerDuck.Common.Helpers.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:optimizations="clr-namespace:optimizerDuck.UI.Views.Pages.Optimizations"
xmlns:optimizers="clr-namespace:optimizerDuck.Core.Optimizers"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
diff --git a/optimizerDuck/UI/Views/Pages/OptimizePage.xaml b/optimizerDuck/UI/Views/Pages/OptimizePage.xaml
index d479a45..016dcdb 100644
--- a/optimizerDuck/UI/Views/Pages/OptimizePage.xaml
+++ b/optimizerDuck/UI/Views/Pages/OptimizePage.xaml
@@ -3,6 +3,7 @@
Margin="0,32,0,0"
ScrollViewer.CanContentScroll="False"
Title="OptimizerPage"
+ d:DataContext="{d:DesignInstance pages:OptimizePage}"
d:DesignHeight="650"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -12,6 +13,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:pages="clr-namespace:optimizerDuck.UI.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
diff --git a/optimizerDuck/UI/Views/Pages/SettingsPage.xaml b/optimizerDuck/UI/Views/Pages/SettingsPage.xaml
index 29c246c..77a1378 100644
--- a/optimizerDuck/UI/Views/Pages/SettingsPage.xaml
+++ b/optimizerDuck/UI/Views/Pages/SettingsPage.xaml
@@ -2,6 +2,7 @@
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Margin="0,32,0,0"
Title="SettingsPage"
+ d:DataContext="{d:DesignInstance pages:SettingsPage}"
d:DesignHeight="1200"
d:DesignWidth="800"
mc:Ignorable="d"
@@ -13,6 +14,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ext="clr-namespace:optimizerDuck.Common.Extensions"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:pages="clr-namespace:optimizerDuck.UI.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
diff --git a/optimizerDuck/UI/Views/Windows/MainWindow.xaml b/optimizerDuck/UI/Views/Windows/MainWindow.xaml
index 8331013..686ef6b 100644
--- a/optimizerDuck/UI/Views/Windows/MainWindow.xaml
+++ b/optimizerDuck/UI/Views/Windows/MainWindow.xaml
@@ -9,6 +9,7 @@
WindowBackdropType="Mica"
WindowCornerPreference="Round"
WindowStartupLocation="CenterScreen"
+ d:DataContext="{d:DesignInstance windows:MainWindow}"
mc:Ignorable="d"
ui:Design.Background="Black"
ui:Design.Foreground="White"
@@ -19,6 +20,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:optimizerDuck.UI.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ xmlns:windows="clr-namespace:optimizerDuck.UI.Views.Windows"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<ui:NavigationView