Files
winutil/functions/private/Set-WinUtilProgressbar.ps1
T

31 lines
1.3 KiB
PowerShell
Raw Normal View History

function Set-WinUtilProgressbar{
<#
.SYNOPSIS
2024-08-06 15:50:36 -05:00
This function is used to Update the Progress Bar displayed in the winutil GUI.
It will be automatically hidden if the user clicks something and no process is running
.PARAMETER Label
The Text to be overlayed onto the Progress Bar
.PARAMETER PERCENT
2024-08-06 15:50:36 -05:00
The percentage of the Progress Bar that should be filled (0-100)
.PARAMETER Hide
If provided, the Progress Bar and the label will be hidden
#>
param(
[string]$Label,
[ValidateRange(0,100)]
[int]$Percent,
$Hide
)
if ($hide) {
2024-08-06 15:50:36 -05:00
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Collapsed"})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Collapsed"})
} else {
2024-08-06 15:50:36 -05:00
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Visible"})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Visible"})
}
2024-08-06 15:50:36 -05:00
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.Text = $label})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.ToolTip = $label})
$sync.form.Dispatcher.Invoke([action]{ $sync.ProgressBar.Value = $percent})
2024-08-06 15:50:36 -05:00
}