Improve & simplify the overview/apply changes pages (#505)

This commit is contained in:
Jeffrey
2026-03-07 14:49:29 +01:00
committed by GitHub
parent b5b67290de
commit a1907c2a78
13 changed files with 1072 additions and 924 deletions

View File

@@ -221,15 +221,7 @@ function Show-MainWindow {
$script:CurrentAppLoadJob = $null
$script:CurrentAppLoadJobStartTime = $null
# Apply Tab UI Elements
$consoleOutput = $window.FindName('ConsoleOutput')
$consoleScrollViewer = $window.FindName('ConsoleScrollViewer')
$finishBtn = $window.FindName('FinishBtn')
$finishBtnText = $window.FindName('FinishBtnText')
# Set script-level variables for Write-ToConsole function
$script:GuiConsoleOutput = $consoleOutput
$script:GuiConsoleScrollViewer = $consoleScrollViewer
# Set script-level variable for GUI window reference
$script:GuiWindow = $window
# Updates app selection status text in the App Selection tab
@@ -972,8 +964,7 @@ function Show-MainWindow {
$totalTabs = $tabControl.Items.Count
$homeIndex = 0
$overviewIndex = $totalTabs - 2
$applyIndex = $totalTabs - 1
$overviewIndex = $totalTabs - 1
# Navigation button visibility
if ($currentIndex -eq $homeIndex) {
@@ -982,26 +973,23 @@ function Show-MainWindow {
} elseif ($currentIndex -eq $overviewIndex) {
$nextBtn.Visibility = 'Collapsed'
$previousBtn.Visibility = 'Visible'
} elseif ($currentIndex -eq $applyIndex) {
$nextBtn.Visibility = 'Collapsed'
$previousBtn.Visibility = 'Collapsed'
} else {
$nextBtn.Visibility = 'Visible'
$previousBtn.Visibility = 'Visible'
}
# Update progress indicators
# Tab indices: 0=Home, 1=App Removal, 2=Tweaks, 3=Overview, 4=Apply
# Tab indices: 0=Home, 1=App Removal, 2=Tweaks, 3=Deployment Settings
$blueColor = "#0067c0"
$greyColor = "#808080"
$progressIndicator1 = $window.FindName('ProgressIndicator1') # App Removal
$progressIndicator2 = $window.FindName('ProgressIndicator2') # Tweaks
$progressIndicator3 = $window.FindName('ProgressIndicator3') # Overview
$progressIndicator3 = $window.FindName('ProgressIndicator3') # Deployment Settings
$bottomNavGrid = $window.FindName('BottomNavGrid')
# Hide bottom navigation on home page and apply tab
if ($currentIndex -eq 0 -or $currentIndex -eq $applyIndex) {
# Hide bottom navigation on home page
if ($currentIndex -eq 0) {
$bottomNavGrid.Visibility = 'Collapsed'
} else {
$bottomNavGrid.Visibility = 'Visible'
@@ -1022,7 +1010,7 @@ function Show-MainWindow {
$progressIndicator2.Fill = $greyColor
}
# Indicator 3 (Overview) - tab index 3
# Indicator 3 (Deployment Settings) - tab index 3
if ($currentIndex -ge 3) {
$progressIndicator3.Fill = $blueColor
} else {
@@ -1142,8 +1130,6 @@ function Show-MainWindow {
function GenerateOverview {
# Load Features.json
$featuresJson = LoadJsonFile -filePath $script:FeaturesFilePath -expectedVersion "1.0"
$overviewChangesPanel = $window.FindName('OverviewChangesPanel')
$overviewChangesPanel.Children.Clear()
$changesList = @()
@@ -1155,7 +1141,7 @@ function Show-MainWindow {
}
}
if ($selectedAppsCount -gt 0) {
$changesList += "Remove $selectedAppsCount selected application(s)"
$changesList += "Remove $selectedAppsCount application(s)"
}
# Update app removal scope section based on whether apps are selected
@@ -1206,20 +1192,19 @@ function Show-MainWindow {
}
}
return $changesList
}
function ShowChangesOverview {
$changesList = GenerateOverview
if ($changesList.Count -eq 0) {
$textBlock = New-Object System.Windows.Controls.TextBlock
$textBlock.Text = "No changes selected"
$textBlock.Style = $window.Resources["OverviewNoChangesTextStyle"]
$overviewChangesPanel.Children.Add($textBlock) | Out-Null
}
else {
foreach ($change in $changesList) {
$bullet = New-Object System.Windows.Controls.TextBlock
$bullet.Text = "- $change"
$bullet.Style = $window.Resources["OverviewChangeBulletStyle"]
$overviewChangesPanel.Children.Add($bullet) | Out-Null
}
Show-MessageBox -Message 'No changes have been selected.' -Title 'Selected Changes' -Button 'OK' -Icon 'Information'
return
}
$message = ($changesList | ForEach-Object { "- $_" }) -join "`n"
Show-MessageBox -Message $message -Title 'Selected Changes' -Button 'OK' -Icon 'None' -Width 600
}
$previousBtn.Add_Click({
@@ -1261,14 +1246,20 @@ function Show-MainWindow {
}
}
# Navigate directly to the Overview tab
# Navigate directly to the Deployment Settings tab
$tabControl.SelectedIndex = 3
UpdateNavigationButtons
})
# Handle Overview Apply Changes button - validates and immediately starts applying changes
$overviewApplyBtn = $window.FindName('OverviewApplyBtn')
$overviewApplyBtn.Add_Click({
# Handle Review Changes link button
$reviewChangesBtn = $window.FindName('ReviewChangesBtn')
$reviewChangesBtn.Add_Click({
ShowChangesOverview
})
# Handle Apply Changes button - validates and immediately starts applying changes
$deploymentApplyBtn = $window.FindName('DeploymentApplyBtn')
$deploymentApplyBtn.Add_Click({
if (-not (ValidateOtherUsername)) {
Show-MessageBox -Message "Please enter a valid username." -Title "Invalid Username" -Button 'OK' -Icon 'Warning' | Out-Null
return
@@ -1381,47 +1372,15 @@ function Show-MainWindow {
SaveSettings
# Navigate to Apply tab (last tab) and start applying changes
$tabControl.SelectedIndex = $tabControl.Items.Count - 1
# Clear console and set initial status
$consoleOutput.Text = ""
# Check if user wants to restart explorer
$restartExplorerCheckBox = $window.FindName('RestartExplorerCheckBox')
$shouldRestartExplorer = $restartExplorerCheckBox -and $restartExplorerCheckBox.IsChecked
Write-ToConsole "Applying changes to $(if ($script:Params.ContainsKey("Sysprep")) { "default user template" } else { "user $(GetUserName)" })"
Write-ToConsole "Total changes to apply: $totalChanges"
Write-ToConsole ""
# Run changes in background to keep UI responsive
$window.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
try {
ExecuteAllChanges
# Check if user wants to restart explorer (from checkbox)
$restartExplorerCheckBox = $window.FindName('RestartExplorerCheckBox')
if ($restartExplorerCheckBox -and $restartExplorerCheckBox.IsChecked -and -not $script:CancelRequested) {
RestartExplorer
}
Write-ToConsole ""
if ($script:CancelRequested) {
Write-ToConsole "Script execution was cancelled by the user. Some changes may not have been applied."
} else {
Write-ToConsole "All changes have been applied. Please check the output above for any errors."
}
$finishBtn.Dispatcher.Invoke([action]{
$finishBtn.IsEnabled = $true
$finishBtnText.Text = "Close Win11Debloat"
})
}
catch {
Write-ToConsole "Error: $($_.Exception.Message)"
$finishBtn.Dispatcher.Invoke([action]{
$finishBtn.IsEnabled = $true
$finishBtnText.Text = "Close Win11Debloat"
})
}
})
# Show the apply changes window
Show-ApplyModal -Owner $window -RestartExplorer $shouldRestartExplorer
# Close the main window after the apply dialog closes
$window.Close()
})
# Initialize UI elements on window load
@@ -1460,15 +1419,6 @@ function Show-MainWindow {
UpdateNavigationButtons
})
# Add event handler for tab changes
$tabControl.Add_SelectionChanged({
# Regenerate overview when switching to Overview tab
if ($tabControl.SelectedIndex -eq ($tabControl.Items.Count - 2)) {
GenerateOverview
}
UpdateNavigationButtons
})
# Handle Load Defaults button
$loadDefaultsBtn = $window.FindName('LoadDefaultsBtn')
$loadDefaultsBtn.Add_Click({
@@ -1552,17 +1502,6 @@ function Show-MainWindow {
}
}
}
# Also uncheck RestorePointCheckBox
$restorePointCheckBox = $window.FindName('RestorePointCheckBox')
if ($restorePointCheckBox) {
$restorePointCheckBox.IsChecked = $false
}
})
# Finish (Close Win11Debloat) button handler
$finishBtn.Add_Click({
$window.Close()
})
# Show the window