Add overlay and block app list during install/uninstall (#3385)

* Implement app installation progress overlay and refactor progress bar handling

* Add overlay background color settings and ensure minimum progress bar value

* Add busy overlay functionality and progress bar updates for installation process

* Refactor busy overlay implementation to dynamically adjust size based on app area dimensions
This commit is contained in:
Martin Wiethan
2025-06-26 19:11:38 +02:00
committed by GitHub
parent 6b22c63d28
commit 91de389c8f
9 changed files with 118 additions and 46 deletions

View File

@ -5,6 +5,8 @@
This is used as the parent object for all category and app entries on the install tab
Used to as part of the Install Tab UI generation
Also creates an overlay with a progress bar and text to indicate that an install or uninstall is in progress
.PARAMETER TargetElement
The element to which the AppArea shoud be added
@ -17,6 +19,7 @@
$Border = New-Object Windows.Controls.Border
$Border.VerticalAlignment = "Stretch"
$Border.SetResourceReference([Windows.Controls.Control]::StyleProperty, "BorderStyle")
$sync.InstallAppAreaBorder = $Border
# Add a ScrollViewer, because the ItemsControl does not support scrolling by itself
$scrollViewer = New-Object Windows.Controls.ScrollViewer
@ -24,11 +27,19 @@
$scrollViewer.HorizontalAlignment = 'Stretch'
$scrollViewer.VerticalAlignment = 'Stretch'
$scrollViewer.CanContentScroll = $true
$sync.InstallAppAreaScrollViewer = $scrollViewer
$Border.Child = $scrollViewer
# Initialize the Blur Effect for the ScrollViewer, which will be used to indicate that an install/uninstall is in progress
$blurEffect = New-Object Windows.Media.Effects.BlurEffect
$blurEffect.Radius = 0
$scrollViewer.Effect = $blurEffect
## Create the ItemsControl, which will be the parent of all the app entries
$itemsControl = New-Object Windows.Controls.ItemsControl
$itemsControl.HorizontalAlignment = 'Stretch'
$itemsControl.VerticalAlignment = 'Stretch'
$scrollViewer.Content = $itemsControl
# Enable virtualization for the ItemsControl to improve performance (It's hard to test if this is actually working, so if you know what you're doing, please check this)
$itemsPanelTemplate = New-Object Windows.Controls.ItemsPanelTemplate
@ -38,8 +49,64 @@
$itemsControl.SetValue([Windows.Controls.VirtualizingStackPanel]::IsVirtualizingProperty, $true)
$itemsControl.SetValue([Windows.Controls.VirtualizingStackPanel]::VirtualizationModeProperty, [Windows.Controls.VirtualizationMode]::Recycling)
$scrollViewer.Content = $itemsControl
$Border.Child = $scrollViewer
$null = $targetGrid.Children.Add($Border)
# Add the Border containing the App Area to the target Grid
$targetGrid.Children.Add($Border) | Out-Null
$overlay = New-Object Windows.Controls.Border
$overlay.CornerRadius = New-Object Windows.CornerRadius(10)
$overlay.SetResourceReference([Windows.Controls.Control]::BackgroundProperty, "AppInstallOverlayBackgroundColor")
$overlay.Visibility = [Windows.Visibility]::Collapsed
# Also add the overlay to the target Grid on top of the App Area
$targetGrid.Children.Add($overlay) | Out-Null
$sync.InstallAppAreaOverlay = $overlay
$overlayText = New-Object Windows.Controls.TextBlock
$overlayText.Text = "Installing apps..."
$overlayText.HorizontalAlignment = 'Center'
$overlayText.VerticalAlignment = 'Center'
$overlayText.SetResourceReference([Windows.Controls.TextBlock]::ForegroundProperty, "MainForegroundColor")
$overlayText.Background = "Transparent"
$overlayText.SetResourceReference([Windows.Controls.TextBlock]::FontSizeProperty, "HeaderFontSize")
$overlayText.SetResourceReference([Windows.Controls.TextBlock]::FontFamilyProperty, "MainFontFamily")
$overlayText.SetResourceReference([Windows.Controls.TextBlock]::FontWeightProperty, "MainFontWeight")
$overlayText.SetResourceReference([Windows.Controls.TextBlock]::MarginProperty, "MainMargin")
$sync.InstallAppAreaOverlayText = $overlayText
$progressbar = New-Object Windows.Controls.ProgressBar
$progressbar.Name = "ProgressBar"
$progressbar.Width = 250
$progressbar.Height = 50
$sync.ProgressBar = $progressbar
# Add a TextBlock overlay for the progress bar text
$progressBarTextBlock = New-Object Windows.Controls.TextBlock
$progressBarTextBlock.Name = "progressBarTextBlock"
$progressBarTextBlock.FontWeight = [Windows.FontWeights]::Bold
$progressBarTextBlock.FontSize = 16
$progressBarTextBlock.Width = $progressbar.Width
$progressBarTextBlock.Height = $progressbar.Height
$progressBarTextBlock.SetResourceReference([Windows.Controls.TextBlock]::ForegroundProperty, "ProgressBarTextColor")
$progressBarTextBlock.TextTrimming = "CharacterEllipsis"
$progressBarTextBlock.Background = "Transparent"
$sync.progressBarTextBlock = $progressBarTextBlock
# Create a Grid to overlay the text on the progress bar
$progressGrid = New-Object Windows.Controls.Grid
$progressGrid.Width = $progressbar.Width
$progressGrid.Height = $progressbar.Height
$progressGrid.Margin = "0,10,0,10"
$progressGrid.Children.Add($progressbar) | Out-Null
$progressGrid.Children.Add($progressBarTextBlock) | Out-Null
$overlayStackPanel = New-Object Windows.Controls.StackPanel
$overlayStackPanel.Orientation = "Vertical"
$overlayStackPanel.HorizontalAlignment = 'Center'
$overlayStackPanel.VerticalAlignment = 'Center'
$overlayStackPanel.Children.Add($overlayText) | Out-Null
$overlayStackPanel.Children.Add($progressGrid) | Out-Null
$overlay.Child = $overlayStackPanel
return $itemsControl
}