Add bubble hint to guide users to review the selected changes after clicking Default Mode button (#519)

This commit is contained in:
Jeffrey
2026-03-15 20:16:53 +01:00
committed by GitHub
parent 06f8f9eb6a
commit d187679cd0
7 changed files with 171 additions and 4 deletions

115
Scripts/GUI/Show-Bubble.ps1 Normal file
View File

@@ -0,0 +1,115 @@
function Hide-Bubble {
param (
[Parameter(Mandatory=$false)]
[switch]$Immediate
)
if ($script:BubbleTimer) {
$script:BubbleTimer.Stop()
$script:BubbleTimer = $null
}
if (-not $script:BubblePopup) { return }
if ($Immediate -or -not $script:BubblePopup.Child) {
$script:BubblePopup.IsOpen = $false
$script:BubblePopup = $null
$script:BubbleIsClosing = $false
return
}
if ($script:BubbleIsClosing) { return }
$script:BubbleIsClosing = $true
$bubblePanel = $script:BubblePopup.Child
$fadeOut = New-Object System.Windows.Media.Animation.DoubleAnimation
$fadeOut.From = [double]$bubblePanel.Opacity
$fadeOut.To = 0
$fadeOut.Duration = [System.Windows.Duration]::new([TimeSpan]::FromMilliseconds(220))
$fadeOut.Add_Completed({
if ($script:BubblePopup) {
$script:BubblePopup.IsOpen = $false
$script:BubblePopup = $null
}
$script:BubbleIsClosing = $false
})
$bubblePanel.BeginAnimation([System.Windows.UIElement]::OpacityProperty, $fadeOut)
}
function Show-Bubble {
param (
[Parameter(Mandatory=$true)]
[System.Windows.Controls.Control]$TargetControl,
[Parameter(Mandatory=$false)]
[string]$Message = 'View the selected changes here',
[Parameter(Mandatory=$false)]
[int]$DurationSeconds = 5
)
Add-Type -AssemblyName PresentationFramework,PresentationCore,WindowsBase | Out-Null
if (-not $TargetControl) { return }
Hide-Bubble -Immediate
$xaml = Get-Content -Path $script:BubbleHintSchema -Raw
$reader = [System.Xml.XmlReader]::Create([System.IO.StringReader]::new($xaml))
try {
$bubblePanel = [System.Windows.Markup.XamlReader]::Load($reader)
}
finally {
$reader.Close()
}
$bubbleText = $bubblePanel.FindName('BubbleText')
if ($bubbleText) {
$bubbleText.Text = $Message
}
$bubblePanel.BeginAnimation([System.Windows.UIElement]::OpacityProperty, $null)
$bubblePanel.Opacity = 0
$popup = New-Object System.Windows.Controls.Primitives.Popup
$popup.AllowsTransparency = $true
$popup.PopupAnimation = 'None'
$popup.StaysOpen = $true
$popup.PlacementTarget = $TargetControl
$popup.Placement = [System.Windows.Controls.Primitives.PlacementMode]::Top
$popup.VerticalOffset = -1
$popup.Child = $bubblePanel
$popup.Add_Opened({
param($sender, $e)
if (-not $sender) { return }
$panel = $sender.Child
$target = $sender.PlacementTarget
if (-not $panel -or -not $target) { return }
$panel.Measure([System.Windows.Size]::new([double]::PositiveInfinity, [double]::PositiveInfinity))
$bubbleWidth = $panel.DesiredSize.Width
$targetWidth = $target.ActualWidth
$sender.HorizontalOffset = ($targetWidth - $bubbleWidth) / 2
$fadeIn = New-Object System.Windows.Media.Animation.DoubleAnimation
$fadeIn.From = 0
$fadeIn.To = 1
$fadeIn.BeginTime = [TimeSpan]::FromMilliseconds(30)
$fadeIn.Duration = [System.Windows.Duration]::new([TimeSpan]::FromMilliseconds(320))
$panel.BeginAnimation([System.Windows.UIElement]::OpacityProperty, $fadeIn)
})
$script:BubbleIsClosing = $false
$script:BubblePopup = $popup
$script:BubblePopup.IsOpen = $true
$script:BubbleTimer = New-Object System.Windows.Threading.DispatcherTimer
$script:BubbleTimer.Interval = [TimeSpan]::FromSeconds([Math]::Max(1, $DurationSeconds))
$script:BubbleTimer.Add_Tick({
Hide-Bubble
})
$script:BubbleTimer.Start()
}

View File

@@ -1208,6 +1208,7 @@ function Show-MainWindow {
}
$previousBtn.Add_Click({
Hide-Bubble -Immediate
if ($tabControl.SelectedIndex -gt 0) {
$tabControl.SelectedIndex--
UpdateNavigationButtons
@@ -1249,11 +1250,17 @@ function Show-MainWindow {
# Navigate directly to the Deployment Settings tab
$tabControl.SelectedIndex = 3
UpdateNavigationButtons
# Show contextual hint bubble for the Review Changes link
$window.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Loaded, [action]{
Show-Bubble -TargetControl $reviewChangesBtn -Message 'View the selected changes here'
}) | Out-Null
})
# Handle Review Changes link button
$reviewChangesBtn = $window.FindName('ReviewChangesBtn')
$reviewChangesBtn.Add_Click({
Hide-Bubble
ShowChangesOverview
})
@@ -1265,6 +1272,8 @@ function Show-MainWindow {
return
}
Hide-Bubble -Immediate
# App Removal - collect selected apps from integrated UI
$selectedApps = @()
foreach ($child in $appsPanel.Children) {