mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-09 15:57:27 +00:00
Remove -NoUi (#4572)
* Made -NoUi not exit the window * Update start.ps1 * Update main.ps1 * Update main.ps1 * Update Set-WinUtilProgressbar.ps1 * Update Invoke-WPFImpex.ps1 * Update Invoke-WPFUIThread.ps1 * Update start.ps1 * Update Invoke-WPFUIThread.ps1 * Update main.ps1 * Update main.ps1
This commit is contained in:
@@ -14,10 +14,6 @@ function Set-WinUtilProgressbar{
|
|||||||
[int]$Percent
|
[int]$Percent
|
||||||
)
|
)
|
||||||
|
|
||||||
if($PARAM_NOUI) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.Text = $label}
|
Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.Text = $label}
|
||||||
Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.ToolTip = $label}
|
Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.ToolTip = $label}
|
||||||
if ($percent -lt 5 ) {
|
if ($percent -lt 5 ) {
|
||||||
|
|||||||
@@ -92,17 +92,6 @@ function Invoke-WPFImpex {
|
|||||||
$sync.selectedFeatures = [System.Collections.Generic.List[string]]::new()
|
$sync.selectedFeatures = [System.Collections.Generic.List[string]]::new()
|
||||||
|
|
||||||
Update-WinUtilSelections -flatJson $flattenedJson
|
Update-WinUtilSelections -flatJson $flattenedJson
|
||||||
|
|
||||||
if (!$PARAM_NOUI) {
|
|
||||||
# Set flag so toggle Checked/Unchecked events don't trigger registry writes
|
|
||||||
# while we're programmatically restoring UI state from the imported config
|
|
||||||
$sync.ImportInProgress = $true
|
|
||||||
try {
|
|
||||||
Reset-WPFCheckBoxes -doToggles $true
|
|
||||||
} finally {
|
|
||||||
$sync.ImportInProgress = $false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "An error occurred while importing: $_"
|
Write-Error "An error occurred while importing: $_"
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
function Invoke-WPFUIThread {
|
function Invoke-WPFUIThread ($ScriptBlock) {
|
||||||
<#
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Creates and runs a task on Winutil's WPF Forms thread.
|
|
||||||
|
|
||||||
.PARAMETER ScriptBlock
|
|
||||||
The scriptblock to invoke in the thread
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
|
||||||
Param (
|
|
||||||
$ScriptBlock
|
|
||||||
)
|
|
||||||
|
|
||||||
if ($PARAM_NOUI) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sync.form.Dispatcher.Invoke([action]$ScriptBlock)
|
$sync.form.Dispatcher.Invoke([action]$ScriptBlock)
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-42
@@ -35,13 +35,11 @@ $maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
|||||||
|
|
||||||
# Create a new session state for parsing variables into our runspace
|
# Create a new session state for parsing variables into our runspace
|
||||||
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
|
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
|
||||||
$uiVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_NOUI',$PARAM_NOUI,$Null
|
|
||||||
$offlineVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_OFFLINE',$PARAM_OFFLINE,$Null
|
$offlineVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_OFFLINE',$PARAM_OFFLINE,$Null
|
||||||
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
|
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
|
||||||
|
|
||||||
# Add the variable to the session state
|
# Add the variable to the session state
|
||||||
$InitialSessionState.Variables.Add($hashVars)
|
$InitialSessionState.Variables.Add($hashVars)
|
||||||
$InitialSessionState.Variables.Add($uiVar)
|
|
||||||
$InitialSessionState.Variables.Add($offlineVar)
|
$InitialSessionState.Variables.Add($offlineVar)
|
||||||
|
|
||||||
# Get every private function and add them to the session state
|
# Get every private function and add them to the session state
|
||||||
@@ -91,8 +89,6 @@ $sync.configs.applications.PSObject.Properties | ForEach-Object {
|
|||||||
Set-Preferences
|
Set-Preferences
|
||||||
|
|
||||||
if ($Preset) {
|
if ($Preset) {
|
||||||
Show-CTTLogo
|
|
||||||
|
|
||||||
# Selects the tweaks from $Preset varible
|
# Selects the tweaks from $Preset varible
|
||||||
Update-WinUtilSelections -flatJson $sync.configs.preset.$Preset
|
Update-WinUtilSelections -flatJson $sync.configs.preset.$Preset
|
||||||
|
|
||||||
@@ -107,27 +103,17 @@ if ($Preset) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PARAM_NOUI) {
|
if ($Config) {
|
||||||
Show-CTTLogo
|
Invoke-WPFImpex -type "import" -Config $Config
|
||||||
if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) {
|
|
||||||
Write-Host "Running config file tasks..."
|
|
||||||
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
|
||||||
Invoke-WinUtilAutoRun
|
|
||||||
|
|
||||||
$sync.runspace.Dispose()
|
Invoke-WinUtilAutoRun
|
||||||
$sync.runspace.Close()
|
|
||||||
[System.GC]::Collect()
|
# Cleanup and exit
|
||||||
Stop-Transcript
|
$sync.runspace.Dispose()
|
||||||
exit 1
|
$sync.runspace.Close()
|
||||||
}
|
[System.GC]::Collect()
|
||||||
else {
|
Stop-Transcript
|
||||||
Write-Host "Cannot automatically run without a config file provided."
|
return
|
||||||
$sync.runspace.Dispose()
|
|
||||||
$sync.runspace.Close()
|
|
||||||
[System.GC]::Collect()
|
|
||||||
Stop-Transcript
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||||
@@ -400,27 +386,16 @@ $sync["Form"].Add_ContentRendered({
|
|||||||
Invoke-WPFTab "WPFTab1BT" # Default to install tab
|
Invoke-WPFTab "WPFTab1BT" # Default to install tab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $PARAM_CONFIG -and (Test-Path "$winutildir\lastrun.json")) {
|
if (-not $Config -and (Test-Path "$winutildir\lastrun.json")) {
|
||||||
try {
|
$drifted = @(Get-Content "$winutildir\lastrun.json" | ConvertFrom-Json | Where-Object { $_ -notin (Invoke-WinUtilCurrentSystem -CheckBox "tweaks") })
|
||||||
$drifted = @(Get-Content "$winutildir\lastrun.json" | ConvertFrom-Json | Where-Object { $_ -notin (Invoke-WinUtilCurrentSystem -CheckBox "tweaks") })
|
if ($drifted.Count -gt 0 -and [System.Windows.MessageBox]::Show("$($drifted.Count) tweak(s) were reverted since last run. Re-select them?", "Winutil", "YesNo", "Question") -eq "Yes") {
|
||||||
if ($drifted.Count -gt 0 -and [System.Windows.MessageBox]::Show("$($drifted.Count) tweak(s) were reverted since last run. Re-select them?", "Winutil", "YesNo", "Question") -eq "Yes") {
|
Update-WinUtilSelections -flatJson $drifted
|
||||||
Update-WinUtilSelections -flatJson $drifted
|
Reset-WPFCheckBoxes -doToggles $false
|
||||||
Reset-WPFCheckBoxes -doToggles $false
|
Invoke-WPFTab "WPFTab2BT"
|
||||||
Invoke-WPFTab "WPFTab2BT"
|
|
||||||
}
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sync["Form"].Focus()
|
|
||||||
|
|
||||||
if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) {
|
|
||||||
Write-Host "Running config file tasks..."
|
|
||||||
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
|
||||||
Invoke-WPFRunspace -ScriptBlock {
|
|
||||||
Invoke-WinUtilAutoRun
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sync["Form"].Focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
# The SearchBarTimer is used to delay the search operation until the user has stopped typing for a short period
|
# The SearchBarTimer is used to delay the search operation until the user has stopped typing for a short period
|
||||||
|
|||||||
@@ -10,19 +10,9 @@ param (
|
|||||||
[string]$Config,
|
[string]$Config,
|
||||||
[ValidateSet("Standard", "Minimal", "Advanced", "")]
|
[ValidateSet("Standard", "Minimal", "Advanced", "")]
|
||||||
[string]$Preset,
|
[string]$Preset,
|
||||||
[switch]$Noui,
|
|
||||||
[switch]$Offline
|
[switch]$Offline
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($Config) {
|
|
||||||
$PARAM_CONFIG = $Config
|
|
||||||
}
|
|
||||||
|
|
||||||
$PARAM_NOUI = $false
|
|
||||||
if ($Noui) {
|
|
||||||
$PARAM_NOUI = $true
|
|
||||||
}
|
|
||||||
|
|
||||||
$PARAM_OFFLINE = $false
|
$PARAM_OFFLINE = $false
|
||||||
if ($Offline) {
|
if ($Offline) {
|
||||||
$PARAM_OFFLINE = $true
|
$PARAM_OFFLINE = $true
|
||||||
|
|||||||
Reference in New Issue
Block a user