mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Improve & simplify the overview/apply changes pages (#505)
This commit is contained in:
@@ -16,7 +16,10 @@ function Show-MessageBox {
|
||||
[string]$Icon = 'None',
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[System.Windows.Window]$Owner = $null
|
||||
[System.Windows.Window]$Owner = $null,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$Width = 0
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase | Out-Null
|
||||
@@ -28,11 +31,15 @@ function Show-MessageBox {
|
||||
|
||||
# Show overlay if owner window exists
|
||||
$overlay = $null
|
||||
$overlayWasAlreadyVisible = $false
|
||||
if ($ownerWindow) {
|
||||
try {
|
||||
$overlay = $ownerWindow.FindName('ModalOverlay')
|
||||
if ($overlay) {
|
||||
$ownerWindow.Dispatcher.Invoke([action]{ $overlay.Visibility = 'Visible' })
|
||||
$overlayWasAlreadyVisible = ($overlay.Visibility -eq 'Visible')
|
||||
if (-not $overlayWasAlreadyVisible) {
|
||||
$ownerWindow.Dispatcher.Invoke([action]{ $overlay.Visibility = 'Visible' })
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
@@ -56,6 +63,11 @@ function Show-MessageBox {
|
||||
catch { }
|
||||
}
|
||||
|
||||
# Apply custom width if specified
|
||||
if ($Width -gt 0) {
|
||||
$msgWindow.Width = $Width
|
||||
}
|
||||
|
||||
# Apply theme resources
|
||||
SetWindowThemeResources -window $msgWindow -usesDarkMode $usesDarkMode
|
||||
|
||||
@@ -142,8 +154,8 @@ function Show-MessageBox {
|
||||
# Show dialog and return result from Tag
|
||||
$msgWindow.ShowDialog() | Out-Null
|
||||
|
||||
# Hide overlay after dialog closes
|
||||
if ($overlay) {
|
||||
# Hide overlay after dialog closes (only if this dialog was the one that showed it)
|
||||
if ($overlay -and -not $overlayWasAlreadyVisible) {
|
||||
try {
|
||||
$ownerWindow.Dispatcher.Invoke([action]{ $overlay.Visibility = 'Collapsed' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user