mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-25 23:16:15 +01:00
Improve backup validation (#849)
This commit is contained in:
@@ -31,7 +31,10 @@ function Show-MessageBox {
|
||||
[System.Windows.Window]$Owner = $null,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$Width = 0
|
||||
[int]$Width = 0,
|
||||
|
||||
[ValidateSet('OK', 'Cancel', 'Yes', 'No')]
|
||||
[string]$DefaultResult
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase | Out-Null
|
||||
@@ -91,7 +94,8 @@ function Show-MessageBox {
|
||||
default { [System.Windows.MessageBoxImage]::None }
|
||||
}
|
||||
|
||||
$nativeResult = [System.Windows.MessageBox]::Show($Message, $Title, $nativeButton, $nativeIcon)
|
||||
$nativeDefault = if ($DefaultResult) { [System.Windows.MessageBoxResult]::$DefaultResult } else { [System.Windows.MessageBoxResult]::None }
|
||||
$nativeResult = [System.Windows.MessageBox]::Show($Message, $Title, $nativeButton, $nativeIcon, $nativeDefault)
|
||||
return [string]$nativeResult
|
||||
}
|
||||
$reader = [System.Xml.XmlReader]::Create([System.IO.StringReader]::new($xaml))
|
||||
@@ -187,6 +191,14 @@ function Show-MessageBox {
|
||||
}
|
||||
}
|
||||
|
||||
if ($DefaultResult) {
|
||||
$useSecondButton = $DefaultResult -in @('Cancel', 'No')
|
||||
$button1.IsDefault = -not $useSecondButton
|
||||
$button2.IsDefault = $useSecondButton
|
||||
$defaultButton = if ($useSecondButton) { $button2 } else { $button1 }
|
||||
$msgWindow.Add_ContentRendered({ $null = $defaultButton.Focus() })
|
||||
}
|
||||
|
||||
# Title bar drag to move window
|
||||
$titleBar.Add_MouseLeftButtonDown({
|
||||
$msgWindow.DragMove()
|
||||
|
||||
Reference in New Issue
Block a user