mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-28 08:51:31 -06:00
49 lines
1.8 KiB
PowerShell
49 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 "=================================="
|
|
|
|
}
|
|
}
|