mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-18 11:46:18 +00:00
Add setting details in config import/export interface (#562)
This commit is contained in:
@@ -43,7 +43,8 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<StackPanel Grid.Row="1" x:Name="ContentPanel" Margin="20,12,20,9">
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Padding="0,0,8,0">
|
||||||
|
<StackPanel x:Name="ContentPanel" Margin="20,12,20,9">
|
||||||
<TextBlock x:Name="PromptText"
|
<TextBlock x:Name="PromptText"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
@@ -53,6 +54,7 @@
|
|||||||
<!-- Checkboxes are added dynamically at runtime -->
|
<!-- Checkboxes are added dynamically at runtime -->
|
||||||
<StackPanel x:Name="CheckboxPanel"/>
|
<StackPanel x:Name="CheckboxPanel"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
<!-- Button Footer -->
|
<!-- Button Footer -->
|
||||||
<Border Grid.Row="2"
|
<Border Grid.Row="2"
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ function Show-ImportExportConfigWindow {
|
|||||||
[string]$Title,
|
[string]$Title,
|
||||||
[string]$Prompt,
|
[string]$Prompt,
|
||||||
[string[]]$Categories = @('Applications', 'System Tweaks', 'Deployment Settings'),
|
[string[]]$Categories = @('Applications', 'System Tweaks', 'Deployment Settings'),
|
||||||
[string[]]$DisabledCategories = @()
|
[string[]]$DisabledCategories = @(),
|
||||||
|
[hashtable]$CategoryDetails = @()
|
||||||
)
|
)
|
||||||
|
|
||||||
# Show overlay on owner window
|
# Show overlay on owner window
|
||||||
@@ -64,11 +65,18 @@ function Show-ImportExportConfigWindow {
|
|||||||
$checkboxPanel = $dlg.FindName('CheckboxPanel')
|
$checkboxPanel = $dlg.FindName('CheckboxPanel')
|
||||||
$checkboxes = @{}
|
$checkboxes = @{}
|
||||||
foreach ($cat in $Categories) {
|
foreach ($cat in $Categories) {
|
||||||
|
# Create a container for the checkbox and details
|
||||||
|
$container = New-Object System.Windows.Controls.StackPanel
|
||||||
|
$container.Orientation = [System.Windows.Controls.Orientation]::Vertical
|
||||||
|
$container.Margin = [System.Windows.Thickness]::new(0,0,0,12)
|
||||||
|
|
||||||
|
# Create checkbox
|
||||||
$cb = New-Object System.Windows.Controls.CheckBox
|
$cb = New-Object System.Windows.Controls.CheckBox
|
||||||
$cb.Content = $cat
|
$cb.Content = $cat
|
||||||
$cb.IsChecked = $true
|
$cb.IsChecked = $true
|
||||||
$cb.Margin = [System.Windows.Thickness]::new(0,0,0,8)
|
$cb.Margin = [System.Windows.Thickness]::new(0,0,0,4)
|
||||||
$cb.FontSize = 14
|
$cb.FontSize = 14
|
||||||
|
$cb.FontWeight = [System.Windows.FontWeights]::Medium
|
||||||
$cb.Foreground = $dlg.FindResource('FgColor')
|
$cb.Foreground = $dlg.FindResource('FgColor')
|
||||||
if ($DisabledCategories -contains $cat) {
|
if ($DisabledCategories -contains $cat) {
|
||||||
$cb.IsChecked = $false
|
$cb.IsChecked = $false
|
||||||
@@ -76,7 +84,22 @@ function Show-ImportExportConfigWindow {
|
|||||||
$cb.Opacity = 0.65
|
$cb.Opacity = 0.65
|
||||||
$cb.ToolTip = 'No selected settings available in this category.'
|
$cb.ToolTip = 'No selected settings available in this category.'
|
||||||
}
|
}
|
||||||
$checkboxPanel.Children.Add($cb) | Out-Null
|
|
||||||
|
$container.Children.Add($cb) | Out-Null
|
||||||
|
|
||||||
|
# Add details if available
|
||||||
|
if ($CategoryDetails -and $CategoryDetails[$cat]) {
|
||||||
|
$detailsText = New-Object System.Windows.Controls.TextBlock
|
||||||
|
$detailsText.Text = $CategoryDetails[$cat]
|
||||||
|
$detailsText.FontSize = 12
|
||||||
|
$detailsText.Foreground = $dlg.FindResource('FgColor')
|
||||||
|
$detailsText.Margin = [System.Windows.Thickness]::new(30,0,0,0)
|
||||||
|
$detailsText.Opacity = 0.75
|
||||||
|
$detailsText.TextWrapping = [System.Windows.TextWrapping]::Wrap
|
||||||
|
$container.Children.Add($detailsText) | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkboxPanel.Children.Add($container) | Out-Null
|
||||||
$checkboxes[$cat] = $cb
|
$checkboxes[$cat] = $cb
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +232,72 @@ function Get-AvailableImportExportCategories {
|
|||||||
return $availableCategories
|
return $availableCategories
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-DeploymentCategoryDetailString {
|
||||||
|
param (
|
||||||
|
[array]$DeploymentSettings
|
||||||
|
)
|
||||||
|
|
||||||
|
$lookup = @{}
|
||||||
|
foreach ($setting in @($DeploymentSettings)) {
|
||||||
|
if ($setting -and $setting.Name) {
|
||||||
|
$lookup[$setting.Name] = $setting.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$line1 = @()
|
||||||
|
|
||||||
|
if ($lookup.ContainsKey('UserSelectionIndex')) {
|
||||||
|
switch ([int]$lookup['UserSelectionIndex']) {
|
||||||
|
0 { $line1 += 'User: Current User' }
|
||||||
|
1 { if ($lookup['OtherUsername']) { $line1 += "User: $($lookup['OtherUsername'])" } }
|
||||||
|
2 { $line1 += 'User: Sysprep' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($lookup.ContainsKey('AppRemovalScopeIndex')) {
|
||||||
|
switch ([int]$lookup['AppRemovalScopeIndex']) {
|
||||||
|
0 { $line1 += 'App Removal: All Users' }
|
||||||
|
1 { $line1 += 'App Removal: Current User' }
|
||||||
|
2 { if ($lookup['OtherUsername']) { $line1 += "App Removal: $($lookup['OtherUsername'])" } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = @()
|
||||||
|
if ($lookup.ContainsKey('CreateRestorePoint') -and [bool]$lookup['CreateRestorePoint']) { $options += 'Restore Point' }
|
||||||
|
if ($lookup.ContainsKey('RestartExplorer') -and [bool]$lookup['RestartExplorer']) { $options += 'Restart Explorer' }
|
||||||
|
|
||||||
|
$lines = @()
|
||||||
|
if ($line1.Count -gt 0) { $lines += $line1 -join ', ' }
|
||||||
|
if ($options.Count -gt 0) { $lines += "Options: $($options -join ', ')" }
|
||||||
|
|
||||||
|
if ($lines.Count -gt 0) { return $lines -join "`n" }
|
||||||
|
return 'Default deployment settings'
|
||||||
|
}
|
||||||
|
|
||||||
|
function Build-CategoryDetails {
|
||||||
|
param (
|
||||||
|
[int]$AppCount = 0,
|
||||||
|
[int]$TweakCount = 0,
|
||||||
|
[array]$DeploymentSettings
|
||||||
|
)
|
||||||
|
|
||||||
|
$details = @{}
|
||||||
|
|
||||||
|
if ($AppCount -gt 0) {
|
||||||
|
$details['Applications'] = "$AppCount app$(if ($AppCount -ne 1) { 's' })"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($TweakCount -gt 0) {
|
||||||
|
$details['System Tweaks'] = "$TweakCount tweak$(if ($TweakCount -ne 1) { 's' })"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($DeploymentSettings) {
|
||||||
|
$details['Deployment Settings'] = Get-DeploymentCategoryDetailString -DeploymentSettings $DeploymentSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
return $details
|
||||||
|
}
|
||||||
|
|
||||||
function Apply-ImportedApplications {
|
function Apply-ImportedApplications {
|
||||||
param (
|
param (
|
||||||
[System.Windows.Controls.Panel]$AppsPanel,
|
[System.Windows.Controls.Panel]$AppsPanel,
|
||||||
@@ -287,7 +376,10 @@ function Export-Configuration {
|
|||||||
if ($selectedApps.Count -eq 0) { $disabledCategories += 'Applications' }
|
if ($selectedApps.Count -eq 0) { $disabledCategories += 'Applications' }
|
||||||
if ($tweakSettings.Count -eq 0) { $disabledCategories += 'System Tweaks' }
|
if ($tweakSettings.Count -eq 0) { $disabledCategories += 'System Tweaks' }
|
||||||
|
|
||||||
$categories = Show-ImportExportConfigWindow -Owner $Owner -UsesDarkMode $UsesDarkMode -Title 'Export Configuration' -Prompt 'Select which settings to include in the export:' -DisabledCategories $disabledCategories
|
$deploymentSettings = Get-DeploymentSettings -Owner $Owner -UserSelectionCombo $UserSelectionCombo -OtherUsernameTextBox $OtherUsernameTextBox
|
||||||
|
$categoryDetails = Build-CategoryDetails -AppCount $selectedApps.Count -TweakCount $tweakSettings.Count -DeploymentSettings $deploymentSettings
|
||||||
|
|
||||||
|
$categories = Show-ImportExportConfigWindow -Owner $Owner -UsesDarkMode $UsesDarkMode -Title 'Export Configuration' -Prompt 'Select which settings to include in the export:' -DisabledCategories $disabledCategories -CategoryDetails $categoryDetails
|
||||||
if (-not $categories) { return }
|
if (-not $categories) { return }
|
||||||
|
|
||||||
$config = @{ Version = '1.0' }
|
$config = @{ Version = '1.0' }
|
||||||
@@ -299,7 +391,7 @@ function Export-Configuration {
|
|||||||
$config['Tweaks'] = @($tweakSettings)
|
$config['Tweaks'] = @($tweakSettings)
|
||||||
}
|
}
|
||||||
if ($categories -contains 'Deployment Settings') {
|
if ($categories -contains 'Deployment Settings') {
|
||||||
$config['Deployment'] = @(Get-DeploymentSettings -Owner $Owner -UserSelectionCombo $UserSelectionCombo -OtherUsernameTextBox $OtherUsernameTextBox)
|
$config['Deployment'] = @($deploymentSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show native save-file dialog
|
# Show native save-file dialog
|
||||||
@@ -357,7 +449,11 @@ function Import-Configuration {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = Show-ImportExportConfigWindow -Owner $Owner -UsesDarkMode $UsesDarkMode -Title 'Import Configuration' -Prompt 'Select which settings to import:' -Categories $availableCategories
|
$appCount = @($config.Apps | Where-Object { $_ -is [string] -and -not [string]::IsNullOrWhiteSpace($_) }).Count
|
||||||
|
$tweakCount = @($config.Tweaks | Where-Object { $_ -and $_.Name -and $_.Value -eq $true }).Count
|
||||||
|
$categoryDetails = Build-CategoryDetails -AppCount $appCount -TweakCount $tweakCount -DeploymentSettings @($config.Deployment)
|
||||||
|
|
||||||
|
$categories = Show-ImportExportConfigWindow -Owner $Owner -UsesDarkMode $UsesDarkMode -Title 'Import Configuration' -Prompt 'Select which settings to import:' -Categories $availableCategories -CategoryDetails $categoryDetails
|
||||||
if (-not $categories) { return }
|
if (-not $categories) { return }
|
||||||
|
|
||||||
if ($categories -contains 'Applications' -and $config.Apps) {
|
if ($categories -contains 'Applications' -and $config.Apps) {
|
||||||
|
|||||||
Reference in New Issue
Block a user