Improve backup validation (#849)

This commit is contained in:
Jeffrey
2026-10-21 22:47:01 +02:00
committed by GitHub
parent 97f3f805ef
commit 039ef80a8b
18 changed files with 1504 additions and 46 deletions
+14 -2
View File
@@ -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()