mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
e7328c2739
* Compile Winutil * first draft for Progress bar in GUI * small optimizations to the loading bar * Optimize the Winget Installation Function to make it more maintainable * Apply loading bar to Tweaks * Update colors * Add docs * Fix value range for the taskbar item * Remove winutil.ps1 from PR * Documention and fix an oversight in the uninstall logic * Reduce even more repeaded code --------- Co-authored-by: Marterich <Marterich@users.noreply.github.com>
48 lines
1.8 KiB
PowerShell
48 lines
1.8 KiB
PowerShell
function Invoke-WPFundoall {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Undoes every selected tweak
|
|
|
|
#>
|
|
|
|
if($sync.ProcessRunning){
|
|
$msg = "[Invoke-WPFundoall] Install process is currently running."
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
return
|
|
}
|
|
|
|
$tweaks = (Get-WinUtilCheckBoxes)["WPFtweaks"]
|
|
|
|
if ($tweaks.count -eq 0){
|
|
$msg = "Please check the tweaks you wish to undo."
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
return
|
|
}
|
|
|
|
Invoke-WPFRunspace -ArgumentList $tweaks -DebugPreference $DebugPreference -ScriptBlock {
|
|
param($tweaks, $DebugPreference)
|
|
|
|
$sync.ProcessRunning = $true
|
|
if ($tweaks.count -eq 1){
|
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
|
} else {
|
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
|
}
|
|
|
|
|
|
for ($i = 0; $i -lt $tweaks.Count; $i++){
|
|
Set-WinUtilProgressBar -Label "Undoing $($tweaks[$i])" -Percent ($i / $tweaks.Count * 100)
|
|
Invoke-WinUtiltweaks $tweaks[$i] -undo $true
|
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i/$tweaks.Count) })
|
|
}
|
|
|
|
Set-WinUtilProgressBar -Label "Undo Tweaks Finished" -Percent 100
|
|
$sync.ProcessRunning = $false
|
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
|
Write-Host "=================================="
|
|
Write-Host "--- Undo Tweaks are Finished ---"
|
|
Write-Host "=================================="
|
|
|
|
}
|
|
} |